vant.cjs.js 424 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161
  1. "use strict";
  2. Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
  3. const use = require("@vant/use");
  4. const vue = require("vue");
  5. const popperjs = require("@vant/popperjs");
  6. const isDef = (val) => val !== void 0 && val !== null;
  7. const isFunction = (val) => typeof val === "function";
  8. const isObject = (val) => val !== null && typeof val === "object";
  9. const isPromise = (val) => isObject(val) && isFunction(val.then) && isFunction(val.catch);
  10. const isDate = (val) => Object.prototype.toString.call(val) === "[object Date]" && !Number.isNaN(val.getTime());
  11. function isMobile(value) {
  12. value = value.replace(/[^-|\d]/g, "");
  13. return /^((\+86)|(86))?(1)\d{10}$/.test(value) || /^0[0-9-]{10,13}$/.test(value);
  14. }
  15. const isNumeric = (val) => typeof val === "number" || /^\d+(\.\d+)?$/.test(val);
  16. const isIOS$1 = () => inBrowser ? /ios|iphone|ipad|ipod/.test(navigator.userAgent.toLowerCase()) : false;
  17. function noop() {
  18. }
  19. const extend = Object.assign;
  20. const inBrowser = typeof window !== "undefined";
  21. function get(object, path) {
  22. const keys = path.split(".");
  23. let result = object;
  24. keys.forEach((key) => {
  25. var _a;
  26. result = isObject(result) ? (_a = result[key]) != null ? _a : "" : "";
  27. });
  28. return result;
  29. }
  30. function pick(obj, keys, ignoreUndefined) {
  31. return keys.reduce((ret, key) => {
  32. if (!ignoreUndefined || obj[key] !== void 0) {
  33. ret[key] = obj[key];
  34. }
  35. return ret;
  36. }, {});
  37. }
  38. const toArray = (item) => Array.isArray(item) ? item : [item];
  39. const unknownProp = null;
  40. const numericProp = [Number, String];
  41. const truthProp = {
  42. type: Boolean,
  43. default: true
  44. };
  45. const makeRequiredProp = (type) => ({
  46. type,
  47. required: true
  48. });
  49. const makeArrayProp = () => ({
  50. type: Array,
  51. default: () => []
  52. });
  53. const makeNumberProp = (defaultVal) => ({
  54. type: Number,
  55. default: defaultVal
  56. });
  57. const makeNumericProp = (defaultVal) => ({
  58. type: numericProp,
  59. default: defaultVal
  60. });
  61. const makeStringProp = (defaultVal) => ({
  62. type: String,
  63. default: defaultVal
  64. });
  65. function getScrollTop(el) {
  66. const top = "scrollTop" in el ? el.scrollTop : el.pageYOffset;
  67. return Math.max(top, 0);
  68. }
  69. function setScrollTop(el, value) {
  70. if ("scrollTop" in el) {
  71. el.scrollTop = value;
  72. } else {
  73. el.scrollTo(el.scrollX, value);
  74. }
  75. }
  76. function getRootScrollTop() {
  77. return window.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop || 0;
  78. }
  79. function setRootScrollTop(value) {
  80. setScrollTop(window, value);
  81. setScrollTop(document.body, value);
  82. }
  83. function getElementTop(el, scroller) {
  84. if (el === window) {
  85. return 0;
  86. }
  87. const scrollTop = scroller ? getScrollTop(scroller) : getRootScrollTop();
  88. return use.useRect(el).top + scrollTop;
  89. }
  90. const isIOS = isIOS$1();
  91. function resetScroll() {
  92. if (isIOS) {
  93. setRootScrollTop(getRootScrollTop());
  94. }
  95. }
  96. const stopPropagation = (event) => event.stopPropagation();
  97. function preventDefault(event, isStopPropagation) {
  98. if (typeof event.cancelable !== "boolean" || event.cancelable) {
  99. event.preventDefault();
  100. }
  101. if (isStopPropagation) {
  102. stopPropagation(event);
  103. }
  104. }
  105. function isHidden(elementRef) {
  106. const el = vue.unref(elementRef);
  107. if (!el) {
  108. return false;
  109. }
  110. const style = window.getComputedStyle(el);
  111. const hidden = style.display === "none";
  112. const parentHidden = el.offsetParent === null && style.position !== "fixed";
  113. return hidden || parentHidden;
  114. }
  115. const { width: windowWidth, height: windowHeight } = use.useWindowSize();
  116. function addUnit(value) {
  117. if (isDef(value)) {
  118. return isNumeric(value) ? `${value}px` : String(value);
  119. }
  120. return void 0;
  121. }
  122. function getSizeStyle(originSize) {
  123. if (isDef(originSize)) {
  124. if (Array.isArray(originSize)) {
  125. return {
  126. width: addUnit(originSize[0]),
  127. height: addUnit(originSize[1])
  128. };
  129. }
  130. const size = addUnit(originSize);
  131. return {
  132. width: size,
  133. height: size
  134. };
  135. }
  136. }
  137. function getZIndexStyle(zIndex) {
  138. const style = {};
  139. if (zIndex !== void 0) {
  140. style.zIndex = +zIndex;
  141. }
  142. return style;
  143. }
  144. let rootFontSize;
  145. function getRootFontSize() {
  146. if (!rootFontSize) {
  147. const doc = document.documentElement;
  148. const fontSize = doc.style.fontSize || window.getComputedStyle(doc).fontSize;
  149. rootFontSize = parseFloat(fontSize);
  150. }
  151. return rootFontSize;
  152. }
  153. function convertRem(value) {
  154. value = value.replace(/rem/g, "");
  155. return +value * getRootFontSize();
  156. }
  157. function convertVw(value) {
  158. value = value.replace(/vw/g, "");
  159. return +value * windowWidth.value / 100;
  160. }
  161. function convertVh(value) {
  162. value = value.replace(/vh/g, "");
  163. return +value * windowHeight.value / 100;
  164. }
  165. function unitToPx(value) {
  166. if (typeof value === "number") {
  167. return value;
  168. }
  169. if (inBrowser) {
  170. if (value.includes("rem")) {
  171. return convertRem(value);
  172. }
  173. if (value.includes("vw")) {
  174. return convertVw(value);
  175. }
  176. if (value.includes("vh")) {
  177. return convertVh(value);
  178. }
  179. }
  180. return parseFloat(value);
  181. }
  182. const camelizeRE = /-(\w)/g;
  183. const camelize = (str) => str.replace(camelizeRE, (_, c) => c.toUpperCase());
  184. const kebabCase = (str) => str.replace(/([A-Z])/g, "-$1").toLowerCase().replace(/^-/, "");
  185. function padZero(num, targetLength = 2) {
  186. let str = num + "";
  187. while (str.length < targetLength) {
  188. str = "0" + str;
  189. }
  190. return str;
  191. }
  192. const clamp = (num, min, max) => Math.min(Math.max(num, min), max);
  193. function trimExtraChar(value, char, regExp) {
  194. const index = value.indexOf(char);
  195. if (index === -1) {
  196. return value;
  197. }
  198. if (char === "-" && index !== 0) {
  199. return value.slice(0, index);
  200. }
  201. return value.slice(0, index + 1) + value.slice(index).replace(regExp, "");
  202. }
  203. function formatNumber(value, allowDot = true, allowMinus = true) {
  204. if (allowDot) {
  205. value = trimExtraChar(value, ".", /\./g);
  206. } else {
  207. value = value.split(".")[0];
  208. }
  209. if (allowMinus) {
  210. value = trimExtraChar(value, "-", /-/g);
  211. } else {
  212. value = value.replace(/-/, "");
  213. }
  214. const regExp = allowDot ? /[^-0-9.]/g : /[^-0-9]/g;
  215. return value.replace(regExp, "");
  216. }
  217. function addNumber(num1, num2) {
  218. const cardinal = 10 ** 10;
  219. return Math.round((num1 + num2) * cardinal) / cardinal;
  220. }
  221. const { hasOwnProperty } = Object.prototype;
  222. function assignKey(to, from, key) {
  223. const val = from[key];
  224. if (!isDef(val)) {
  225. return;
  226. }
  227. if (!hasOwnProperty.call(to, key) || !isObject(val)) {
  228. to[key] = val;
  229. } else {
  230. to[key] = deepAssign(Object(to[key]), val);
  231. }
  232. }
  233. function deepAssign(to, from) {
  234. Object.keys(from).forEach((key) => {
  235. assignKey(to, from, key);
  236. });
  237. return to;
  238. }
  239. var stdin_default$1E = {
  240. name: "\u59D3\u540D",
  241. tel: "\u7535\u8BDD",
  242. save: "\u4FDD\u5B58",
  243. confirm: "\u786E\u8BA4",
  244. cancel: "\u53D6\u6D88",
  245. delete: "\u5220\u9664",
  246. loading: "\u52A0\u8F7D\u4E2D...",
  247. noCoupon: "\u6682\u65E0\u4F18\u60E0\u5238",
  248. nameEmpty: "\u8BF7\u586B\u5199\u59D3\u540D",
  249. addContact: "\u6DFB\u52A0\u8054\u7CFB\u4EBA",
  250. telInvalid: "\u8BF7\u586B\u5199\u6B63\u786E\u7684\u7535\u8BDD",
  251. vanCalendar: {
  252. end: "\u7ED3\u675F",
  253. start: "\u5F00\u59CB",
  254. title: "\u65E5\u671F\u9009\u62E9",
  255. weekdays: ["\u65E5", "\u4E00", "\u4E8C", "\u4E09", "\u56DB", "\u4E94", "\u516D"],
  256. monthTitle: (year, month) => `${year}\u5E74${month}\u6708`,
  257. rangePrompt: (maxRange) => `\u6700\u591A\u9009\u62E9 ${maxRange} \u5929`
  258. },
  259. vanCascader: {
  260. select: "\u8BF7\u9009\u62E9"
  261. },
  262. vanPagination: {
  263. prev: "\u4E0A\u4E00\u9875",
  264. next: "\u4E0B\u4E00\u9875"
  265. },
  266. vanPullRefresh: {
  267. pulling: "\u4E0B\u62C9\u5373\u53EF\u5237\u65B0...",
  268. loosing: "\u91CA\u653E\u5373\u53EF\u5237\u65B0..."
  269. },
  270. vanSubmitBar: {
  271. label: "\u5408\u8BA1:"
  272. },
  273. vanCoupon: {
  274. unlimited: "\u65E0\u95E8\u69DB",
  275. discount: (discount) => `${discount}\u6298`,
  276. condition: (condition) => `\u6EE1${condition}\u5143\u53EF\u7528`
  277. },
  278. vanCouponCell: {
  279. title: "\u4F18\u60E0\u5238",
  280. count: (count) => `${count}\u5F20\u53EF\u7528`
  281. },
  282. vanCouponList: {
  283. exchange: "\u5151\u6362",
  284. close: "\u4E0D\u4F7F\u7528",
  285. enable: "\u53EF\u7528",
  286. disabled: "\u4E0D\u53EF\u7528",
  287. placeholder: "\u8F93\u5165\u4F18\u60E0\u7801"
  288. },
  289. vanAddressEdit: {
  290. area: "\u5730\u533A",
  291. postal: "\u90AE\u653F\u7F16\u7801",
  292. areaEmpty: "\u8BF7\u9009\u62E9\u5730\u533A",
  293. addressEmpty: "\u8BF7\u586B\u5199\u8BE6\u7EC6\u5730\u5740",
  294. postalEmpty: "\u90AE\u653F\u7F16\u7801\u4E0D\u6B63\u786E",
  295. addressDetail: "\u8BE6\u7EC6\u5730\u5740",
  296. defaultAddress: "\u8BBE\u4E3A\u9ED8\u8BA4\u6536\u8D27\u5730\u5740"
  297. },
  298. vanAddressList: {
  299. add: "\u65B0\u589E\u5730\u5740"
  300. }
  301. };
  302. const lang = vue.ref("zh-CN");
  303. const messages = vue.reactive({
  304. "zh-CN": stdin_default$1E
  305. });
  306. const Locale = {
  307. messages() {
  308. return messages[lang.value];
  309. },
  310. use(newLang, newMessages) {
  311. lang.value = newLang;
  312. this.add({ [newLang]: newMessages });
  313. },
  314. add(newMessages = {}) {
  315. deepAssign(messages, newMessages);
  316. }
  317. };
  318. var stdin_default$1D = Locale;
  319. function createTranslate(name2) {
  320. const prefix = camelize(name2) + ".";
  321. return (path, ...args) => {
  322. const messages2 = stdin_default$1D.messages();
  323. const message = get(messages2, prefix + path) || get(messages2, path);
  324. return isFunction(message) ? message(...args) : message;
  325. };
  326. }
  327. function genBem(name2, mods) {
  328. if (!mods) {
  329. return "";
  330. }
  331. if (typeof mods === "string") {
  332. return ` ${name2}--${mods}`;
  333. }
  334. if (Array.isArray(mods)) {
  335. return mods.reduce(
  336. (ret, item) => ret + genBem(name2, item),
  337. ""
  338. );
  339. }
  340. return Object.keys(mods).reduce(
  341. (ret, key) => ret + (mods[key] ? genBem(name2, key) : ""),
  342. ""
  343. );
  344. }
  345. function createBEM(name2) {
  346. return (el, mods) => {
  347. if (el && typeof el !== "string") {
  348. mods = el;
  349. el = "";
  350. }
  351. el = el ? `${name2}__${el}` : name2;
  352. return `${el}${genBem(el, mods)}`;
  353. };
  354. }
  355. function createNamespace(name2) {
  356. const prefixedName = `van-${name2}`;
  357. return [
  358. prefixedName,
  359. createBEM(prefixedName),
  360. createTranslate(prefixedName)
  361. ];
  362. }
  363. const BORDER = "van-hairline";
  364. const BORDER_TOP = `${BORDER}--top`;
  365. const BORDER_LEFT = `${BORDER}--left`;
  366. const BORDER_BOTTOM = `${BORDER}--bottom`;
  367. const BORDER_SURROUND = `${BORDER}--surround`;
  368. const BORDER_TOP_BOTTOM = `${BORDER}--top-bottom`;
  369. const BORDER_UNSET_TOP_BOTTOM = `${BORDER}-unset--top-bottom`;
  370. const HAPTICS_FEEDBACK = "van-haptics-feedback";
  371. const FORM_KEY = Symbol("van-form");
  372. function callInterceptor(interceptor, {
  373. args = [],
  374. done,
  375. canceled
  376. }) {
  377. if (interceptor) {
  378. const returnVal = interceptor.apply(null, args);
  379. if (isPromise(returnVal)) {
  380. returnVal.then((value) => {
  381. if (value) {
  382. done();
  383. } else if (canceled) {
  384. canceled();
  385. }
  386. }).catch(noop);
  387. } else if (returnVal) {
  388. done();
  389. } else if (canceled) {
  390. canceled();
  391. }
  392. } else {
  393. done();
  394. }
  395. }
  396. function withInstall(options) {
  397. options.install = (app) => {
  398. const { name: name2 } = options;
  399. if (name2) {
  400. app.component(name2, options);
  401. app.component(camelize(`-${name2}`), options);
  402. }
  403. };
  404. return options;
  405. }
  406. const POPUP_TOGGLE_KEY = Symbol();
  407. function onPopupReopen(callback) {
  408. const popupToggleStatus = vue.inject(POPUP_TOGGLE_KEY, null);
  409. if (popupToggleStatus) {
  410. vue.watch(popupToggleStatus, (show) => {
  411. if (show) {
  412. callback();
  413. }
  414. });
  415. }
  416. }
  417. const useHeight = (element, withSafeArea) => {
  418. const height = vue.ref();
  419. const setHeight = () => {
  420. height.value = use.useRect(element).height;
  421. };
  422. vue.onMounted(() => {
  423. vue.nextTick(setHeight);
  424. if (withSafeArea) {
  425. for (let i = 1; i <= 3; i++) {
  426. setTimeout(setHeight, 100 * i);
  427. }
  428. }
  429. });
  430. onPopupReopen(() => vue.nextTick(setHeight));
  431. return height;
  432. };
  433. function usePlaceholder(contentRef, bem2) {
  434. const height = useHeight(contentRef, true);
  435. return (renderContent) => vue.createVNode("div", {
  436. "class": bem2("placeholder"),
  437. "style": {
  438. height: height.value ? `${height.value}px` : void 0
  439. }
  440. }, [renderContent()]);
  441. }
  442. const [name$1v, bem$1r] = createNamespace("action-bar");
  443. const ACTION_BAR_KEY = Symbol(name$1v);
  444. const actionBarProps = {
  445. placeholder: Boolean,
  446. safeAreaInsetBottom: truthProp
  447. };
  448. var stdin_default$1C = vue.defineComponent({
  449. name: name$1v,
  450. props: actionBarProps,
  451. setup(props, {
  452. slots
  453. }) {
  454. const root = vue.ref();
  455. const renderPlaceholder = usePlaceholder(root, bem$1r);
  456. const {
  457. linkChildren
  458. } = use.useChildren(ACTION_BAR_KEY);
  459. linkChildren();
  460. const renderActionBar = () => {
  461. var _a;
  462. return vue.createVNode("div", {
  463. "ref": root,
  464. "class": [bem$1r(), {
  465. "van-safe-area-bottom": props.safeAreaInsetBottom
  466. }]
  467. }, [(_a = slots.default) == null ? void 0 : _a.call(slots)]);
  468. };
  469. return () => {
  470. if (props.placeholder) {
  471. return renderPlaceholder(renderActionBar);
  472. }
  473. return renderActionBar();
  474. };
  475. }
  476. });
  477. const ActionBar = withInstall(stdin_default$1C);
  478. function useExpose(apis) {
  479. const instance2 = vue.getCurrentInstance();
  480. if (instance2) {
  481. extend(instance2.proxy, apis);
  482. }
  483. }
  484. const routeProps = {
  485. to: [String, Object],
  486. url: String,
  487. replace: Boolean
  488. };
  489. function route({
  490. to,
  491. url,
  492. replace,
  493. $router: router
  494. }) {
  495. if (to && router) {
  496. router[replace ? "replace" : "push"](to);
  497. } else if (url) {
  498. replace ? location.replace(url) : location.href = url;
  499. }
  500. }
  501. function useRoute() {
  502. const vm = vue.getCurrentInstance().proxy;
  503. return () => route(vm);
  504. }
  505. const [name$1u, bem$1q] = createNamespace("badge");
  506. const badgeProps = {
  507. dot: Boolean,
  508. max: numericProp,
  509. tag: makeStringProp("div"),
  510. color: String,
  511. offset: Array,
  512. content: numericProp,
  513. showZero: truthProp,
  514. position: makeStringProp("top-right")
  515. };
  516. var stdin_default$1B = vue.defineComponent({
  517. name: name$1u,
  518. props: badgeProps,
  519. setup(props, {
  520. slots
  521. }) {
  522. const hasContent = () => {
  523. if (slots.content) {
  524. return true;
  525. }
  526. const {
  527. content,
  528. showZero
  529. } = props;
  530. return isDef(content) && content !== "" && (showZero || content !== 0 && content !== "0");
  531. };
  532. const renderContent = () => {
  533. const {
  534. dot,
  535. max,
  536. content
  537. } = props;
  538. if (!dot && hasContent()) {
  539. if (slots.content) {
  540. return slots.content();
  541. }
  542. if (isDef(max) && isNumeric(content) && +content > max) {
  543. return `${max}+`;
  544. }
  545. return content;
  546. }
  547. };
  548. const style = vue.computed(() => {
  549. const style2 = {
  550. background: props.color
  551. };
  552. if (props.offset) {
  553. const [x, y] = props.offset;
  554. if (slots.default) {
  555. style2.top = addUnit(y);
  556. if (typeof x === "number") {
  557. style2.right = addUnit(-x);
  558. } else {
  559. style2.right = x.startsWith("-") ? x.replace("-", "") : `-${x}`;
  560. }
  561. } else {
  562. style2.marginTop = addUnit(y);
  563. style2.marginLeft = addUnit(x);
  564. }
  565. }
  566. return style2;
  567. });
  568. const renderBadge = () => {
  569. if (hasContent() || props.dot) {
  570. return vue.createVNode("div", {
  571. "class": bem$1q([props.position, {
  572. dot: props.dot,
  573. fixed: !!slots.default
  574. }]),
  575. "style": style.value
  576. }, [renderContent()]);
  577. }
  578. };
  579. return () => {
  580. if (slots.default) {
  581. const {
  582. tag
  583. } = props;
  584. return vue.createVNode(tag, {
  585. "class": bem$1q("wrapper")
  586. }, {
  587. default: () => [slots.default(), renderBadge()]
  588. });
  589. }
  590. return renderBadge();
  591. };
  592. }
  593. });
  594. const Badge = withInstall(stdin_default$1B);
  595. let globalZIndex = 2e3;
  596. const useGlobalZIndex = () => ++globalZIndex;
  597. const setGlobalZIndex = (val) => {
  598. globalZIndex = val;
  599. };
  600. const [name$1t, bem$1p] = createNamespace("config-provider");
  601. const CONFIG_PROVIDER_KEY = Symbol(name$1t);
  602. const configProviderProps = {
  603. tag: makeStringProp("div"),
  604. zIndex: Number,
  605. themeVars: Object,
  606. iconPrefix: String
  607. };
  608. function mapThemeVarsToCSSVars(themeVars) {
  609. const cssVars = {};
  610. Object.keys(themeVars).forEach((key) => {
  611. cssVars[`--van-${kebabCase(key)}`] = themeVars[key];
  612. });
  613. return cssVars;
  614. }
  615. var stdin_default$1A = vue.defineComponent({
  616. name: name$1t,
  617. props: configProviderProps,
  618. setup(props, {
  619. slots
  620. }) {
  621. const style = vue.computed(() => {
  622. if (props.themeVars) {
  623. return mapThemeVarsToCSSVars(props.themeVars);
  624. }
  625. });
  626. vue.provide(CONFIG_PROVIDER_KEY, props);
  627. vue.watchEffect(() => {
  628. if (props.zIndex !== void 0) {
  629. setGlobalZIndex(props.zIndex);
  630. }
  631. });
  632. return () => vue.createVNode(props.tag, {
  633. "class": bem$1p(),
  634. "style": style.value
  635. }, {
  636. default: () => {
  637. var _a;
  638. return [(_a = slots.default) == null ? void 0 : _a.call(slots)];
  639. }
  640. });
  641. }
  642. });
  643. const [name$1s, bem$1o] = createNamespace("icon");
  644. const isImage = (name2) => name2 == null ? void 0 : name2.includes("/");
  645. const iconProps = {
  646. dot: Boolean,
  647. tag: makeStringProp("i"),
  648. name: String,
  649. size: numericProp,
  650. badge: numericProp,
  651. color: String,
  652. badgeProps: Object,
  653. classPrefix: String
  654. };
  655. var stdin_default$1z = vue.defineComponent({
  656. name: name$1s,
  657. props: iconProps,
  658. setup(props, {
  659. slots
  660. }) {
  661. const config = vue.inject(CONFIG_PROVIDER_KEY, null);
  662. const classPrefix = vue.computed(() => props.classPrefix || (config == null ? void 0 : config.iconPrefix) || bem$1o());
  663. return () => {
  664. const {
  665. tag,
  666. dot,
  667. name: name2,
  668. size,
  669. badge,
  670. color
  671. } = props;
  672. const isImageIcon = isImage(name2);
  673. return vue.createVNode(Badge, vue.mergeProps({
  674. "dot": dot,
  675. "tag": tag,
  676. "class": [classPrefix.value, isImageIcon ? "" : `${classPrefix.value}-${name2}`],
  677. "style": {
  678. color,
  679. fontSize: addUnit(size)
  680. },
  681. "content": badge
  682. }, props.badgeProps), {
  683. default: () => {
  684. var _a;
  685. return [(_a = slots.default) == null ? void 0 : _a.call(slots), isImageIcon && vue.createVNode("img", {
  686. "class": bem$1o("image"),
  687. "src": name2
  688. }, null)];
  689. }
  690. });
  691. };
  692. }
  693. });
  694. const Icon = withInstall(stdin_default$1z);
  695. const [name$1r, bem$1n] = createNamespace("loading");
  696. const SpinIcon = Array(12).fill(null).map((_, index) => vue.createVNode("i", {
  697. "class": bem$1n("line", String(index + 1))
  698. }, null));
  699. const CircularIcon = vue.createVNode("svg", {
  700. "class": bem$1n("circular"),
  701. "viewBox": "25 25 50 50"
  702. }, [vue.createVNode("circle", {
  703. "cx": "50",
  704. "cy": "50",
  705. "r": "20",
  706. "fill": "none"
  707. }, null)]);
  708. const loadingProps = {
  709. size: numericProp,
  710. type: makeStringProp("circular"),
  711. color: String,
  712. vertical: Boolean,
  713. textSize: numericProp,
  714. textColor: String
  715. };
  716. var stdin_default$1y = vue.defineComponent({
  717. name: name$1r,
  718. props: loadingProps,
  719. setup(props, {
  720. slots
  721. }) {
  722. const spinnerStyle = vue.computed(() => extend({
  723. color: props.color
  724. }, getSizeStyle(props.size)));
  725. const renderText = () => {
  726. var _a;
  727. if (slots.default) {
  728. return vue.createVNode("span", {
  729. "class": bem$1n("text"),
  730. "style": {
  731. fontSize: addUnit(props.textSize),
  732. color: (_a = props.textColor) != null ? _a : props.color
  733. }
  734. }, [slots.default()]);
  735. }
  736. };
  737. return () => {
  738. const {
  739. type,
  740. vertical
  741. } = props;
  742. return vue.createVNode("div", {
  743. "class": bem$1n([type, {
  744. vertical
  745. }]),
  746. "aria-live": "polite",
  747. "aria-busy": true
  748. }, [vue.createVNode("span", {
  749. "class": bem$1n("spinner", type),
  750. "style": spinnerStyle.value
  751. }, [type === "spinner" ? SpinIcon : CircularIcon]), renderText()]);
  752. };
  753. }
  754. });
  755. const Loading = withInstall(stdin_default$1y);
  756. const [name$1q, bem$1m] = createNamespace("button");
  757. const buttonProps = extend({}, routeProps, {
  758. tag: makeStringProp("button"),
  759. text: String,
  760. icon: String,
  761. type: makeStringProp("default"),
  762. size: makeStringProp("normal"),
  763. color: String,
  764. block: Boolean,
  765. plain: Boolean,
  766. round: Boolean,
  767. square: Boolean,
  768. loading: Boolean,
  769. hairline: Boolean,
  770. disabled: Boolean,
  771. iconPrefix: String,
  772. nativeType: makeStringProp("button"),
  773. loadingSize: numericProp,
  774. loadingText: String,
  775. loadingType: String,
  776. iconPosition: makeStringProp("left")
  777. });
  778. var stdin_default$1x = vue.defineComponent({
  779. name: name$1q,
  780. props: buttonProps,
  781. emits: ["click"],
  782. setup(props, {
  783. emit,
  784. slots
  785. }) {
  786. const route2 = useRoute();
  787. const renderLoadingIcon = () => {
  788. if (slots.loading) {
  789. return slots.loading();
  790. }
  791. return vue.createVNode(Loading, {
  792. "size": props.loadingSize,
  793. "type": props.loadingType,
  794. "class": bem$1m("loading")
  795. }, null);
  796. };
  797. const renderIcon = () => {
  798. if (props.loading) {
  799. return renderLoadingIcon();
  800. }
  801. if (slots.icon) {
  802. return vue.createVNode("div", {
  803. "class": bem$1m("icon")
  804. }, [slots.icon()]);
  805. }
  806. if (props.icon) {
  807. return vue.createVNode(Icon, {
  808. "name": props.icon,
  809. "class": bem$1m("icon"),
  810. "classPrefix": props.iconPrefix
  811. }, null);
  812. }
  813. };
  814. const renderText = () => {
  815. let text;
  816. if (props.loading) {
  817. text = props.loadingText;
  818. } else {
  819. text = slots.default ? slots.default() : props.text;
  820. }
  821. if (text) {
  822. return vue.createVNode("span", {
  823. "class": bem$1m("text")
  824. }, [text]);
  825. }
  826. };
  827. const getStyle = () => {
  828. const {
  829. color,
  830. plain
  831. } = props;
  832. if (color) {
  833. const style = {
  834. color: plain ? color : "white"
  835. };
  836. if (!plain) {
  837. style.background = color;
  838. }
  839. if (color.includes("gradient")) {
  840. style.border = 0;
  841. } else {
  842. style.borderColor = color;
  843. }
  844. return style;
  845. }
  846. };
  847. const onClick = (event) => {
  848. if (props.loading) {
  849. preventDefault(event);
  850. } else if (!props.disabled) {
  851. emit("click", event);
  852. route2();
  853. }
  854. };
  855. return () => {
  856. const {
  857. tag,
  858. type,
  859. size,
  860. block,
  861. round,
  862. plain,
  863. square,
  864. loading,
  865. disabled,
  866. hairline,
  867. nativeType,
  868. iconPosition
  869. } = props;
  870. const classes = [bem$1m([type, size, {
  871. plain,
  872. block,
  873. round,
  874. square,
  875. loading,
  876. disabled,
  877. hairline
  878. }]), {
  879. [BORDER_SURROUND]: hairline
  880. }];
  881. return vue.createVNode(tag, {
  882. "type": nativeType,
  883. "class": classes,
  884. "style": getStyle(),
  885. "disabled": disabled,
  886. "onClick": onClick
  887. }, {
  888. default: () => [vue.createVNode("div", {
  889. "class": bem$1m("content")
  890. }, [iconPosition === "left" && renderIcon(), renderText(), iconPosition === "right" && renderIcon()])]
  891. });
  892. };
  893. }
  894. });
  895. const Button = withInstall(stdin_default$1x);
  896. const [name$1p, bem$1l] = createNamespace("action-bar-button");
  897. const actionBarButtonProps = extend({}, routeProps, {
  898. type: String,
  899. text: String,
  900. icon: String,
  901. color: String,
  902. loading: Boolean,
  903. disabled: Boolean
  904. });
  905. var stdin_default$1w = vue.defineComponent({
  906. name: name$1p,
  907. props: actionBarButtonProps,
  908. setup(props, {
  909. slots
  910. }) {
  911. const route2 = useRoute();
  912. const {
  913. parent,
  914. index
  915. } = use.useParent(ACTION_BAR_KEY);
  916. const isFirst = vue.computed(() => {
  917. if (parent) {
  918. const prev = parent.children[index.value - 1];
  919. return !(prev && "isButton" in prev);
  920. }
  921. });
  922. const isLast = vue.computed(() => {
  923. if (parent) {
  924. const next = parent.children[index.value + 1];
  925. return !(next && "isButton" in next);
  926. }
  927. });
  928. useExpose({
  929. isButton: true
  930. });
  931. return () => {
  932. const {
  933. type,
  934. icon,
  935. text,
  936. color,
  937. loading,
  938. disabled
  939. } = props;
  940. return vue.createVNode(Button, {
  941. "class": bem$1l([type, {
  942. last: isLast.value,
  943. first: isFirst.value
  944. }]),
  945. "size": "large",
  946. "type": type,
  947. "icon": icon,
  948. "color": color,
  949. "loading": loading,
  950. "disabled": disabled,
  951. "onClick": route2
  952. }, {
  953. default: () => [slots.default ? slots.default() : text]
  954. });
  955. };
  956. }
  957. });
  958. const ActionBarButton = withInstall(stdin_default$1w);
  959. const [name$1o, bem$1k] = createNamespace("action-bar-icon");
  960. const actionBarIconProps = extend({}, routeProps, {
  961. dot: Boolean,
  962. text: String,
  963. icon: String,
  964. color: String,
  965. badge: numericProp,
  966. iconClass: unknownProp,
  967. badgeProps: Object,
  968. iconPrefix: String
  969. });
  970. var stdin_default$1v = vue.defineComponent({
  971. name: name$1o,
  972. props: actionBarIconProps,
  973. setup(props, {
  974. slots
  975. }) {
  976. const route2 = useRoute();
  977. use.useParent(ACTION_BAR_KEY);
  978. const renderIcon = () => {
  979. const {
  980. dot,
  981. badge,
  982. icon,
  983. color,
  984. iconClass,
  985. badgeProps: badgeProps2,
  986. iconPrefix
  987. } = props;
  988. if (slots.icon) {
  989. return vue.createVNode(Badge, vue.mergeProps({
  990. "dot": dot,
  991. "class": bem$1k("icon"),
  992. "content": badge
  993. }, badgeProps2), {
  994. default: slots.icon
  995. });
  996. }
  997. return vue.createVNode(Icon, {
  998. "tag": "div",
  999. "dot": dot,
  1000. "name": icon,
  1001. "badge": badge,
  1002. "color": color,
  1003. "class": [bem$1k("icon"), iconClass],
  1004. "badgeProps": badgeProps2,
  1005. "classPrefix": iconPrefix
  1006. }, null);
  1007. };
  1008. return () => vue.createVNode("div", {
  1009. "role": "button",
  1010. "class": bem$1k(),
  1011. "tabindex": 0,
  1012. "onClick": route2
  1013. }, [renderIcon(), slots.default ? slots.default() : props.text]);
  1014. }
  1015. });
  1016. const ActionBarIcon = withInstall(stdin_default$1v);
  1017. const popupSharedProps = {
  1018. show: Boolean,
  1019. zIndex: numericProp,
  1020. overlay: truthProp,
  1021. duration: numericProp,
  1022. teleport: [String, Object],
  1023. lockScroll: truthProp,
  1024. lazyRender: truthProp,
  1025. beforeClose: Function,
  1026. overlayStyle: Object,
  1027. overlayClass: unknownProp,
  1028. transitionAppear: Boolean,
  1029. closeOnClickOverlay: truthProp
  1030. };
  1031. const popupSharedPropKeys = Object.keys(
  1032. popupSharedProps
  1033. );
  1034. function getDirection(x, y) {
  1035. if (x > y) {
  1036. return "horizontal";
  1037. }
  1038. if (y > x) {
  1039. return "vertical";
  1040. }
  1041. return "";
  1042. }
  1043. function useTouch() {
  1044. const startX = vue.ref(0);
  1045. const startY = vue.ref(0);
  1046. const deltaX = vue.ref(0);
  1047. const deltaY = vue.ref(0);
  1048. const offsetX = vue.ref(0);
  1049. const offsetY = vue.ref(0);
  1050. const direction = vue.ref("");
  1051. const isVertical = () => direction.value === "vertical";
  1052. const isHorizontal = () => direction.value === "horizontal";
  1053. const reset = () => {
  1054. deltaX.value = 0;
  1055. deltaY.value = 0;
  1056. offsetX.value = 0;
  1057. offsetY.value = 0;
  1058. direction.value = "";
  1059. };
  1060. const start = (event) => {
  1061. reset();
  1062. startX.value = event.touches[0].clientX;
  1063. startY.value = event.touches[0].clientY;
  1064. };
  1065. const move = (event) => {
  1066. const touch = event.touches[0];
  1067. deltaX.value = (touch.clientX < 0 ? 0 : touch.clientX) - startX.value;
  1068. deltaY.value = touch.clientY - startY.value;
  1069. offsetX.value = Math.abs(deltaX.value);
  1070. offsetY.value = Math.abs(deltaY.value);
  1071. const LOCK_DIRECTION_DISTANCE = 10;
  1072. if (!direction.value || offsetX.value < LOCK_DIRECTION_DISTANCE && offsetY.value < LOCK_DIRECTION_DISTANCE) {
  1073. direction.value = getDirection(offsetX.value, offsetY.value);
  1074. }
  1075. };
  1076. return {
  1077. move,
  1078. start,
  1079. reset,
  1080. startX,
  1081. startY,
  1082. deltaX,
  1083. deltaY,
  1084. offsetX,
  1085. offsetY,
  1086. direction,
  1087. isVertical,
  1088. isHorizontal
  1089. };
  1090. }
  1091. let totalLockCount = 0;
  1092. const BODY_LOCK_CLASS = "van-overflow-hidden";
  1093. function useLockScroll(rootRef, shouldLock) {
  1094. const touch = useTouch();
  1095. const DIRECTION_UP = "01";
  1096. const DIRECTION_DOWN = "10";
  1097. const onTouchMove = (event) => {
  1098. touch.move(event);
  1099. const direction = touch.deltaY.value > 0 ? DIRECTION_DOWN : DIRECTION_UP;
  1100. const el = use.getScrollParent(
  1101. event.target,
  1102. rootRef.value
  1103. );
  1104. const { scrollHeight, offsetHeight, scrollTop } = el;
  1105. let status = "11";
  1106. if (scrollTop === 0) {
  1107. status = offsetHeight >= scrollHeight ? "00" : "01";
  1108. } else if (scrollTop + offsetHeight >= scrollHeight) {
  1109. status = "10";
  1110. }
  1111. if (status !== "11" && touch.isVertical() && !(parseInt(status, 2) & parseInt(direction, 2))) {
  1112. preventDefault(event, true);
  1113. }
  1114. };
  1115. const lock = () => {
  1116. document.addEventListener("touchstart", touch.start);
  1117. document.addEventListener("touchmove", onTouchMove, { passive: false });
  1118. if (!totalLockCount) {
  1119. document.body.classList.add(BODY_LOCK_CLASS);
  1120. }
  1121. totalLockCount++;
  1122. };
  1123. const unlock = () => {
  1124. if (totalLockCount) {
  1125. document.removeEventListener("touchstart", touch.start);
  1126. document.removeEventListener("touchmove", onTouchMove);
  1127. totalLockCount--;
  1128. if (!totalLockCount) {
  1129. document.body.classList.remove(BODY_LOCK_CLASS);
  1130. }
  1131. }
  1132. };
  1133. const init = () => shouldLock() && lock();
  1134. const destroy = () => shouldLock() && unlock();
  1135. use.onMountedOrActivated(init);
  1136. vue.onDeactivated(destroy);
  1137. vue.onBeforeUnmount(destroy);
  1138. vue.watch(shouldLock, (value) => {
  1139. value ? lock() : unlock();
  1140. });
  1141. }
  1142. function useLazyRender(show) {
  1143. const inited = vue.ref(false);
  1144. vue.watch(
  1145. show,
  1146. (value) => {
  1147. if (value) {
  1148. inited.value = value;
  1149. }
  1150. },
  1151. { immediate: true }
  1152. );
  1153. return (render) => () => inited.value ? render() : null;
  1154. }
  1155. const [name$1n, bem$1j] = createNamespace("overlay");
  1156. const overlayProps = {
  1157. show: Boolean,
  1158. zIndex: numericProp,
  1159. duration: numericProp,
  1160. className: unknownProp,
  1161. lockScroll: truthProp,
  1162. lazyRender: truthProp,
  1163. customStyle: Object
  1164. };
  1165. var stdin_default$1u = vue.defineComponent({
  1166. name: name$1n,
  1167. props: overlayProps,
  1168. setup(props, {
  1169. slots
  1170. }) {
  1171. const root = vue.ref();
  1172. const lazyRender = useLazyRender(() => props.show || !props.lazyRender);
  1173. const onTouchMove = (event) => {
  1174. if (props.lockScroll) {
  1175. preventDefault(event, true);
  1176. }
  1177. };
  1178. const renderOverlay = lazyRender(() => {
  1179. var _a;
  1180. const style = extend(getZIndexStyle(props.zIndex), props.customStyle);
  1181. if (isDef(props.duration)) {
  1182. style.animationDuration = `${props.duration}s`;
  1183. }
  1184. return vue.withDirectives(vue.createVNode("div", {
  1185. "ref": root,
  1186. "style": style,
  1187. "class": [bem$1j(), props.className]
  1188. }, [(_a = slots.default) == null ? void 0 : _a.call(slots)]), [[vue.vShow, props.show]]);
  1189. });
  1190. use.useEventListener("touchmove", onTouchMove, {
  1191. target: root
  1192. });
  1193. return () => vue.createVNode(vue.Transition, {
  1194. "name": "van-fade",
  1195. "appear": true
  1196. }, {
  1197. default: renderOverlay
  1198. });
  1199. }
  1200. });
  1201. const Overlay = withInstall(stdin_default$1u);
  1202. const popupProps$2 = extend({}, popupSharedProps, {
  1203. round: Boolean,
  1204. position: makeStringProp("center"),
  1205. closeIcon: makeStringProp("cross"),
  1206. closeable: Boolean,
  1207. transition: String,
  1208. iconPrefix: String,
  1209. closeOnPopstate: Boolean,
  1210. closeIconPosition: makeStringProp("top-right"),
  1211. safeAreaInsetTop: Boolean,
  1212. safeAreaInsetBottom: Boolean
  1213. });
  1214. const [name$1m, bem$1i] = createNamespace("popup");
  1215. var stdin_default$1t = vue.defineComponent({
  1216. name: name$1m,
  1217. inheritAttrs: false,
  1218. props: popupProps$2,
  1219. emits: ["open", "close", "opened", "closed", "keydown", "update:show", "click-overlay", "click-close-icon"],
  1220. setup(props, {
  1221. emit,
  1222. attrs,
  1223. slots
  1224. }) {
  1225. let opened;
  1226. let shouldReopen;
  1227. const zIndex = vue.ref();
  1228. const popupRef = vue.ref();
  1229. const lazyRender = useLazyRender(() => props.show || !props.lazyRender);
  1230. const style = vue.computed(() => {
  1231. const style2 = {
  1232. zIndex: zIndex.value
  1233. };
  1234. if (isDef(props.duration)) {
  1235. const key = props.position === "center" ? "animationDuration" : "transitionDuration";
  1236. style2[key] = `${props.duration}s`;
  1237. }
  1238. return style2;
  1239. });
  1240. const open = () => {
  1241. if (!opened) {
  1242. opened = true;
  1243. zIndex.value = props.zIndex !== void 0 ? +props.zIndex : useGlobalZIndex();
  1244. emit("open");
  1245. }
  1246. };
  1247. const close = () => {
  1248. if (opened) {
  1249. callInterceptor(props.beforeClose, {
  1250. done() {
  1251. opened = false;
  1252. emit("close");
  1253. emit("update:show", false);
  1254. }
  1255. });
  1256. }
  1257. };
  1258. const onClickOverlay = (event) => {
  1259. emit("click-overlay", event);
  1260. if (props.closeOnClickOverlay) {
  1261. close();
  1262. }
  1263. };
  1264. const renderOverlay = () => {
  1265. if (props.overlay) {
  1266. return vue.createVNode(Overlay, {
  1267. "show": props.show,
  1268. "class": props.overlayClass,
  1269. "zIndex": zIndex.value,
  1270. "duration": props.duration,
  1271. "customStyle": props.overlayStyle,
  1272. "role": props.closeOnClickOverlay ? "button" : void 0,
  1273. "tabindex": props.closeOnClickOverlay ? 0 : void 0,
  1274. "onClick": onClickOverlay
  1275. }, {
  1276. default: slots["overlay-content"]
  1277. });
  1278. }
  1279. };
  1280. const onClickCloseIcon = (event) => {
  1281. emit("click-close-icon", event);
  1282. close();
  1283. };
  1284. const renderCloseIcon = () => {
  1285. if (props.closeable) {
  1286. return vue.createVNode(Icon, {
  1287. "role": "button",
  1288. "tabindex": 0,
  1289. "name": props.closeIcon,
  1290. "class": [bem$1i("close-icon", props.closeIconPosition), HAPTICS_FEEDBACK],
  1291. "classPrefix": props.iconPrefix,
  1292. "onClick": onClickCloseIcon
  1293. }, null);
  1294. }
  1295. };
  1296. const onOpened = () => emit("opened");
  1297. const onClosed = () => emit("closed");
  1298. const onKeydown = (event) => emit("keydown", event);
  1299. const renderPopup = lazyRender(() => {
  1300. var _a;
  1301. const {
  1302. round,
  1303. position,
  1304. safeAreaInsetTop,
  1305. safeAreaInsetBottom
  1306. } = props;
  1307. return vue.withDirectives(vue.createVNode("div", vue.mergeProps({
  1308. "ref": popupRef,
  1309. "style": style.value,
  1310. "role": "dialog",
  1311. "tabindex": 0,
  1312. "class": [bem$1i({
  1313. round,
  1314. [position]: position
  1315. }), {
  1316. "van-safe-area-top": safeAreaInsetTop,
  1317. "van-safe-area-bottom": safeAreaInsetBottom
  1318. }],
  1319. "onKeydown": onKeydown
  1320. }, attrs), [(_a = slots.default) == null ? void 0 : _a.call(slots), renderCloseIcon()]), [[vue.vShow, props.show]]);
  1321. });
  1322. const renderTransition = () => {
  1323. const {
  1324. position,
  1325. transition,
  1326. transitionAppear
  1327. } = props;
  1328. const name2 = position === "center" ? "van-fade" : `van-popup-slide-${position}`;
  1329. return vue.createVNode(vue.Transition, {
  1330. "name": transition || name2,
  1331. "appear": transitionAppear,
  1332. "onAfterEnter": onOpened,
  1333. "onAfterLeave": onClosed
  1334. }, {
  1335. default: renderPopup
  1336. });
  1337. };
  1338. vue.watch(() => props.show, (show) => {
  1339. if (show && !opened) {
  1340. open();
  1341. if (attrs.tabindex === 0) {
  1342. vue.nextTick(() => {
  1343. var _a;
  1344. (_a = popupRef.value) == null ? void 0 : _a.focus();
  1345. });
  1346. }
  1347. }
  1348. if (!show && opened) {
  1349. opened = false;
  1350. emit("close");
  1351. }
  1352. });
  1353. useExpose({
  1354. popupRef
  1355. });
  1356. useLockScroll(popupRef, () => props.show && props.lockScroll);
  1357. use.useEventListener("popstate", () => {
  1358. if (props.closeOnPopstate) {
  1359. close();
  1360. shouldReopen = false;
  1361. }
  1362. });
  1363. vue.onMounted(() => {
  1364. if (props.show) {
  1365. open();
  1366. }
  1367. });
  1368. vue.onActivated(() => {
  1369. if (shouldReopen) {
  1370. emit("update:show", true);
  1371. shouldReopen = false;
  1372. }
  1373. });
  1374. vue.onDeactivated(() => {
  1375. if (props.show && props.teleport) {
  1376. close();
  1377. shouldReopen = true;
  1378. }
  1379. });
  1380. vue.provide(POPUP_TOGGLE_KEY, () => props.show);
  1381. return () => {
  1382. if (props.teleport) {
  1383. return vue.createVNode(vue.Teleport, {
  1384. "to": props.teleport
  1385. }, {
  1386. default: () => [renderOverlay(), renderTransition()]
  1387. });
  1388. }
  1389. return vue.createVNode(vue.Fragment, null, [renderOverlay(), renderTransition()]);
  1390. };
  1391. }
  1392. });
  1393. const Popup = withInstall(stdin_default$1t);
  1394. const [name$1l, bem$1h] = createNamespace("action-sheet");
  1395. const actionSheetProps = extend({}, popupSharedProps, {
  1396. title: String,
  1397. round: truthProp,
  1398. actions: makeArrayProp(),
  1399. closeIcon: makeStringProp("cross"),
  1400. closeable: truthProp,
  1401. cancelText: String,
  1402. description: String,
  1403. closeOnPopstate: truthProp,
  1404. closeOnClickAction: Boolean,
  1405. safeAreaInsetBottom: truthProp
  1406. });
  1407. const popupInheritKeys$2 = [...popupSharedPropKeys, "round", "closeOnPopstate", "safeAreaInsetBottom"];
  1408. var stdin_default$1s = vue.defineComponent({
  1409. name: name$1l,
  1410. props: actionSheetProps,
  1411. emits: ["select", "cancel", "update:show"],
  1412. setup(props, {
  1413. slots,
  1414. emit
  1415. }) {
  1416. const updateShow = (show) => emit("update:show", show);
  1417. const onCancel = () => {
  1418. updateShow(false);
  1419. emit("cancel");
  1420. };
  1421. const renderHeader = () => {
  1422. if (props.title) {
  1423. return vue.createVNode("div", {
  1424. "class": bem$1h("header")
  1425. }, [props.title, props.closeable && vue.createVNode(Icon, {
  1426. "name": props.closeIcon,
  1427. "class": [bem$1h("close"), HAPTICS_FEEDBACK],
  1428. "onClick": onCancel
  1429. }, null)]);
  1430. }
  1431. };
  1432. const renderCancel = () => {
  1433. if (slots.cancel || props.cancelText) {
  1434. return [vue.createVNode("div", {
  1435. "class": bem$1h("gap")
  1436. }, null), vue.createVNode("button", {
  1437. "type": "button",
  1438. "class": bem$1h("cancel"),
  1439. "onClick": onCancel
  1440. }, [slots.cancel ? slots.cancel() : props.cancelText])];
  1441. }
  1442. };
  1443. const renderActionContent = (action, index) => {
  1444. if (action.loading) {
  1445. return vue.createVNode(Loading, {
  1446. "class": bem$1h("loading-icon")
  1447. }, null);
  1448. }
  1449. if (slots.action) {
  1450. return slots.action({
  1451. action,
  1452. index
  1453. });
  1454. }
  1455. return [vue.createVNode("span", {
  1456. "class": bem$1h("name")
  1457. }, [action.name]), action.subname && vue.createVNode("div", {
  1458. "class": bem$1h("subname")
  1459. }, [action.subname])];
  1460. };
  1461. const renderAction = (action, index) => {
  1462. const {
  1463. color,
  1464. loading,
  1465. callback,
  1466. disabled,
  1467. className
  1468. } = action;
  1469. const onClick = () => {
  1470. if (disabled || loading) {
  1471. return;
  1472. }
  1473. if (callback) {
  1474. callback(action);
  1475. }
  1476. if (props.closeOnClickAction) {
  1477. updateShow(false);
  1478. }
  1479. vue.nextTick(() => emit("select", action, index));
  1480. };
  1481. return vue.createVNode("button", {
  1482. "type": "button",
  1483. "style": {
  1484. color
  1485. },
  1486. "class": [bem$1h("item", {
  1487. loading,
  1488. disabled
  1489. }), className],
  1490. "onClick": onClick
  1491. }, [renderActionContent(action, index)]);
  1492. };
  1493. const renderDescription = () => {
  1494. if (props.description || slots.description) {
  1495. const content = slots.description ? slots.description() : props.description;
  1496. return vue.createVNode("div", {
  1497. "class": bem$1h("description")
  1498. }, [content]);
  1499. }
  1500. };
  1501. return () => vue.createVNode(Popup, vue.mergeProps({
  1502. "class": bem$1h(),
  1503. "position": "bottom",
  1504. "onUpdate:show": updateShow
  1505. }, pick(props, popupInheritKeys$2)), {
  1506. default: () => {
  1507. var _a;
  1508. return [renderHeader(), renderDescription(), vue.createVNode("div", {
  1509. "class": bem$1h("content")
  1510. }, [props.actions.map(renderAction), (_a = slots.default) == null ? void 0 : _a.call(slots)]), renderCancel()];
  1511. }
  1512. });
  1513. }
  1514. });
  1515. const ActionSheet = withInstall(stdin_default$1s);
  1516. function deepClone(obj) {
  1517. if (!isDef(obj)) {
  1518. return obj;
  1519. }
  1520. if (Array.isArray(obj)) {
  1521. return obj.map((item) => deepClone(item));
  1522. }
  1523. if (isObject(obj)) {
  1524. const to = {};
  1525. Object.keys(obj).forEach((key) => {
  1526. to[key] = deepClone(obj[key]);
  1527. });
  1528. return to;
  1529. }
  1530. return obj;
  1531. }
  1532. const DEFAULT_DURATION = 200;
  1533. const MOMENTUM_LIMIT_TIME = 300;
  1534. const MOMENTUM_LIMIT_DISTANCE = 15;
  1535. const [name$1k, bem$1g] = createNamespace("picker-column");
  1536. function getElementTranslateY(element) {
  1537. const {
  1538. transform
  1539. } = window.getComputedStyle(element);
  1540. const translateY = transform.slice(7, transform.length - 1).split(", ")[5];
  1541. return Number(translateY);
  1542. }
  1543. const PICKER_KEY = Symbol(name$1k);
  1544. const isOptionDisabled = (option) => isObject(option) && option.disabled;
  1545. var stdin_default$1r = vue.defineComponent({
  1546. name: name$1k,
  1547. props: {
  1548. textKey: makeRequiredProp(String),
  1549. readonly: Boolean,
  1550. allowHtml: Boolean,
  1551. className: unknownProp,
  1552. itemHeight: makeRequiredProp(Number),
  1553. defaultIndex: makeNumberProp(0),
  1554. swipeDuration: makeRequiredProp(numericProp),
  1555. initialOptions: makeArrayProp(),
  1556. visibleItemCount: makeRequiredProp(numericProp)
  1557. },
  1558. emits: ["change"],
  1559. setup(props, {
  1560. emit,
  1561. slots
  1562. }) {
  1563. let moving;
  1564. let startOffset;
  1565. let touchStartTime;
  1566. let momentumOffset;
  1567. let transitionEndTrigger;
  1568. const root = vue.ref();
  1569. const wrapper = vue.ref();
  1570. const state = vue.reactive({
  1571. index: props.defaultIndex,
  1572. offset: 0,
  1573. duration: 0,
  1574. options: deepClone(props.initialOptions)
  1575. });
  1576. const touch = useTouch();
  1577. const count = () => state.options.length;
  1578. const baseOffset = () => props.itemHeight * (+props.visibleItemCount - 1) / 2;
  1579. const adjustIndex = (index) => {
  1580. index = clamp(index, 0, count());
  1581. for (let i = index; i < count(); i++) {
  1582. if (!isOptionDisabled(state.options[i]))
  1583. return i;
  1584. }
  1585. for (let i = index - 1; i >= 0; i--) {
  1586. if (!isOptionDisabled(state.options[i]))
  1587. return i;
  1588. }
  1589. };
  1590. const setIndex = (index, emitChange) => {
  1591. index = adjustIndex(index) || 0;
  1592. const offset = -index * props.itemHeight;
  1593. const trigger = () => {
  1594. if (index !== state.index) {
  1595. state.index = index;
  1596. if (emitChange) {
  1597. emit("change", index);
  1598. }
  1599. }
  1600. };
  1601. if (moving && offset !== state.offset) {
  1602. transitionEndTrigger = trigger;
  1603. } else {
  1604. trigger();
  1605. }
  1606. state.offset = offset;
  1607. };
  1608. const setOptions = (options) => {
  1609. if (JSON.stringify(options) !== JSON.stringify(state.options)) {
  1610. state.options = deepClone(options);
  1611. setIndex(props.defaultIndex);
  1612. }
  1613. };
  1614. const onClickItem = (index) => {
  1615. if (moving || props.readonly) {
  1616. return;
  1617. }
  1618. transitionEndTrigger = null;
  1619. state.duration = DEFAULT_DURATION;
  1620. setIndex(index, true);
  1621. };
  1622. const getOptionText = (option) => {
  1623. if (isObject(option) && props.textKey in option) {
  1624. return option[props.textKey];
  1625. }
  1626. return option;
  1627. };
  1628. const getIndexByOffset = (offset) => clamp(Math.round(-offset / props.itemHeight), 0, count() - 1);
  1629. const momentum = (distance, duration) => {
  1630. const speed = Math.abs(distance / duration);
  1631. distance = state.offset + speed / 3e-3 * (distance < 0 ? -1 : 1);
  1632. const index = getIndexByOffset(distance);
  1633. state.duration = +props.swipeDuration;
  1634. setIndex(index, true);
  1635. };
  1636. const stopMomentum = () => {
  1637. moving = false;
  1638. state.duration = 0;
  1639. if (transitionEndTrigger) {
  1640. transitionEndTrigger();
  1641. transitionEndTrigger = null;
  1642. }
  1643. };
  1644. const onTouchStart = (event) => {
  1645. if (props.readonly) {
  1646. return;
  1647. }
  1648. touch.start(event);
  1649. if (moving) {
  1650. const translateY = getElementTranslateY(wrapper.value);
  1651. state.offset = Math.min(0, translateY - baseOffset());
  1652. startOffset = state.offset;
  1653. } else {
  1654. startOffset = state.offset;
  1655. }
  1656. state.duration = 0;
  1657. touchStartTime = Date.now();
  1658. momentumOffset = startOffset;
  1659. transitionEndTrigger = null;
  1660. };
  1661. const onTouchMove = (event) => {
  1662. if (props.readonly) {
  1663. return;
  1664. }
  1665. touch.move(event);
  1666. if (touch.isVertical()) {
  1667. moving = true;
  1668. preventDefault(event, true);
  1669. }
  1670. state.offset = clamp(startOffset + touch.deltaY.value, -(count() * props.itemHeight), props.itemHeight);
  1671. const now = Date.now();
  1672. if (now - touchStartTime > MOMENTUM_LIMIT_TIME) {
  1673. touchStartTime = now;
  1674. momentumOffset = state.offset;
  1675. }
  1676. };
  1677. const onTouchEnd = () => {
  1678. if (props.readonly) {
  1679. return;
  1680. }
  1681. const distance = state.offset - momentumOffset;
  1682. const duration = Date.now() - touchStartTime;
  1683. const allowMomentum = duration < MOMENTUM_LIMIT_TIME && Math.abs(distance) > MOMENTUM_LIMIT_DISTANCE;
  1684. if (allowMomentum) {
  1685. momentum(distance, duration);
  1686. return;
  1687. }
  1688. const index = getIndexByOffset(state.offset);
  1689. state.duration = DEFAULT_DURATION;
  1690. setIndex(index, true);
  1691. setTimeout(() => {
  1692. moving = false;
  1693. }, 0);
  1694. };
  1695. const renderOptions = () => {
  1696. const optionStyle = {
  1697. height: `${props.itemHeight}px`
  1698. };
  1699. return state.options.map((option, index) => {
  1700. const text = getOptionText(option);
  1701. const disabled = isOptionDisabled(option);
  1702. const data = {
  1703. role: "button",
  1704. style: optionStyle,
  1705. tabindex: disabled ? -1 : 0,
  1706. class: bem$1g("item", {
  1707. disabled,
  1708. selected: index === state.index
  1709. }),
  1710. onClick: () => onClickItem(index)
  1711. };
  1712. const childData = {
  1713. class: "van-ellipsis",
  1714. [props.allowHtml ? "innerHTML" : "textContent"]: text
  1715. };
  1716. return vue.createVNode("li", data, [slots.option ? slots.option(option) : vue.createVNode("div", childData, null)]);
  1717. });
  1718. };
  1719. const setValue = (value) => {
  1720. const {
  1721. options
  1722. } = state;
  1723. for (let i = 0; i < options.length; i++) {
  1724. if (getOptionText(options[i]) === value) {
  1725. return setIndex(i);
  1726. }
  1727. }
  1728. };
  1729. const getValue = () => state.options[state.index];
  1730. const hasOptions = () => state.options.length;
  1731. setIndex(state.index);
  1732. use.useParent(PICKER_KEY);
  1733. useExpose({
  1734. state,
  1735. setIndex,
  1736. getValue,
  1737. setValue,
  1738. setOptions,
  1739. hasOptions,
  1740. stopMomentum
  1741. });
  1742. vue.watch(() => props.initialOptions, setOptions);
  1743. vue.watch(() => props.defaultIndex, (value) => setIndex(value));
  1744. use.useEventListener("touchmove", onTouchMove, {
  1745. target: root
  1746. });
  1747. return () => vue.createVNode("div", {
  1748. "ref": root,
  1749. "class": [bem$1g(), props.className],
  1750. "onTouchstartPassive": onTouchStart,
  1751. "onTouchend": onTouchEnd,
  1752. "onTouchcancel": onTouchEnd
  1753. }, [vue.createVNode("ul", {
  1754. "ref": wrapper,
  1755. "style": {
  1756. transform: `translate3d(0, ${state.offset + baseOffset()}px, 0)`,
  1757. transitionDuration: `${state.duration}ms`,
  1758. transitionProperty: state.duration ? "all" : "none"
  1759. },
  1760. "class": bem$1g("wrapper"),
  1761. "onTransitionend": stopMomentum
  1762. }, [renderOptions()])]);
  1763. }
  1764. });
  1765. const [name$1j, bem$1f, t$j] = createNamespace("picker");
  1766. const pickerSharedProps = {
  1767. title: String,
  1768. loading: Boolean,
  1769. readonly: Boolean,
  1770. allowHtml: Boolean,
  1771. itemHeight: makeNumericProp(44),
  1772. showToolbar: truthProp,
  1773. swipeDuration: makeNumericProp(1e3),
  1774. visibleItemCount: makeNumericProp(6),
  1775. cancelButtonText: String,
  1776. confirmButtonText: String
  1777. };
  1778. const pickerProps = extend({}, pickerSharedProps, {
  1779. columns: makeArrayProp(),
  1780. valueKey: String,
  1781. defaultIndex: makeNumericProp(0),
  1782. toolbarPosition: makeStringProp("top"),
  1783. columnsFieldNames: Object
  1784. });
  1785. var stdin_default$1q = vue.defineComponent({
  1786. name: name$1j,
  1787. props: pickerProps,
  1788. emits: ["confirm", "cancel", "change"],
  1789. setup(props, {
  1790. emit,
  1791. slots
  1792. }) {
  1793. if (process.env.NODE_ENV !== "production") {
  1794. if (slots.default) {
  1795. console.warn('[Vant] Picker: "default" slot is deprecated, please use "toolbar" slot instead.');
  1796. }
  1797. if (props.valueKey) {
  1798. console.warn('[Vant] Picker: "valueKey" prop is deprecated, please use "columnsFieldNames" prop instead.');
  1799. }
  1800. }
  1801. const hasOptions = vue.ref(false);
  1802. const columnsRef = vue.ref();
  1803. const formattedColumns = vue.ref([]);
  1804. const columnsFieldNames = vue.computed(() => {
  1805. const {
  1806. columnsFieldNames: columnsFieldNames2
  1807. } = props;
  1808. return {
  1809. text: (columnsFieldNames2 == null ? void 0 : columnsFieldNames2.text) || props.valueKey || "text",
  1810. values: (columnsFieldNames2 == null ? void 0 : columnsFieldNames2.values) || "values",
  1811. children: (columnsFieldNames2 == null ? void 0 : columnsFieldNames2.children) || "children"
  1812. };
  1813. });
  1814. const {
  1815. children,
  1816. linkChildren
  1817. } = use.useChildren(PICKER_KEY);
  1818. linkChildren();
  1819. const itemHeight = vue.computed(() => unitToPx(props.itemHeight));
  1820. const dataType = vue.computed(() => {
  1821. const firstColumn = props.columns[0];
  1822. if (typeof firstColumn === "object") {
  1823. if (columnsFieldNames.value.children in firstColumn) {
  1824. return "cascade";
  1825. }
  1826. if (columnsFieldNames.value.values in firstColumn) {
  1827. return "object";
  1828. }
  1829. }
  1830. return "plain";
  1831. });
  1832. const formatCascade = () => {
  1833. var _a;
  1834. const formatted = [];
  1835. let cursor = {
  1836. [columnsFieldNames.value.children]: props.columns
  1837. };
  1838. while (cursor && cursor[columnsFieldNames.value.children]) {
  1839. const children2 = cursor[columnsFieldNames.value.children];
  1840. let defaultIndex = (_a = cursor.defaultIndex) != null ? _a : +props.defaultIndex;
  1841. while (children2[defaultIndex] && children2[defaultIndex].disabled) {
  1842. if (defaultIndex < children2.length - 1) {
  1843. defaultIndex++;
  1844. } else {
  1845. defaultIndex = 0;
  1846. break;
  1847. }
  1848. }
  1849. formatted.push({
  1850. [columnsFieldNames.value.values]: cursor[columnsFieldNames.value.children],
  1851. className: cursor.className,
  1852. defaultIndex
  1853. });
  1854. cursor = children2[defaultIndex];
  1855. }
  1856. formattedColumns.value = formatted;
  1857. };
  1858. const format2 = () => {
  1859. const {
  1860. columns
  1861. } = props;
  1862. if (dataType.value === "plain") {
  1863. formattedColumns.value = [{
  1864. [columnsFieldNames.value.values]: columns
  1865. }];
  1866. } else if (dataType.value === "cascade") {
  1867. formatCascade();
  1868. } else {
  1869. formattedColumns.value = columns;
  1870. }
  1871. hasOptions.value = formattedColumns.value.some((item) => item[columnsFieldNames.value.values] && item[columnsFieldNames.value.values].length !== 0) || children.some((item) => item.hasOptions);
  1872. };
  1873. const getIndexes = () => children.map((child) => child.state.index);
  1874. const setColumnValues = (index, options) => {
  1875. const column = children[index];
  1876. if (column) {
  1877. column.setOptions(options);
  1878. hasOptions.value = true;
  1879. }
  1880. };
  1881. const onCascadeChange = (columnIndex) => {
  1882. let cursor = {
  1883. [columnsFieldNames.value.children]: props.columns
  1884. };
  1885. const indexes = getIndexes();
  1886. for (let i = 0; i <= columnIndex; i++) {
  1887. cursor = cursor[columnsFieldNames.value.children][indexes[i]];
  1888. }
  1889. while (cursor && cursor[columnsFieldNames.value.children]) {
  1890. columnIndex++;
  1891. setColumnValues(columnIndex, cursor[columnsFieldNames.value.children]);
  1892. cursor = cursor[columnsFieldNames.value.children][cursor.defaultIndex || 0];
  1893. }
  1894. };
  1895. const getChild = (index) => children[index];
  1896. const getColumnValue = (index) => {
  1897. const column = getChild(index);
  1898. if (column) {
  1899. return column.getValue();
  1900. }
  1901. };
  1902. const setColumnValue = (index, value) => {
  1903. const column = getChild(index);
  1904. if (column) {
  1905. column.setValue(value);
  1906. if (dataType.value === "cascade") {
  1907. onCascadeChange(index);
  1908. }
  1909. }
  1910. };
  1911. const getColumnIndex = (index) => {
  1912. const column = getChild(index);
  1913. if (column) {
  1914. return column.state.index;
  1915. }
  1916. };
  1917. const setColumnIndex = (columnIndex, optionIndex) => {
  1918. const column = getChild(columnIndex);
  1919. if (column) {
  1920. column.setIndex(optionIndex);
  1921. if (dataType.value === "cascade") {
  1922. onCascadeChange(columnIndex);
  1923. }
  1924. }
  1925. };
  1926. const getColumnValues = (index) => {
  1927. const column = getChild(index);
  1928. if (column) {
  1929. return column.state.options;
  1930. }
  1931. };
  1932. const getValues = () => children.map((child) => child.getValue());
  1933. const setValues = (values) => {
  1934. values.forEach((value, index) => {
  1935. setColumnValue(index, value);
  1936. });
  1937. };
  1938. const setIndexes = (indexes) => {
  1939. indexes.forEach((optionIndex, columnIndex) => {
  1940. setColumnIndex(columnIndex, optionIndex);
  1941. });
  1942. };
  1943. const emitAction = (event) => {
  1944. if (dataType.value === "plain") {
  1945. emit(event, getColumnValue(0), getColumnIndex(0));
  1946. } else {
  1947. emit(event, getValues(), getIndexes());
  1948. }
  1949. };
  1950. const onChange = (columnIndex) => {
  1951. if (dataType.value === "cascade") {
  1952. onCascadeChange(columnIndex);
  1953. }
  1954. if (dataType.value === "plain") {
  1955. emit("change", getColumnValue(0), getColumnIndex(0));
  1956. } else {
  1957. emit("change", getValues(), columnIndex);
  1958. }
  1959. };
  1960. const confirm = () => {
  1961. children.forEach((child) => child.stopMomentum());
  1962. emitAction("confirm");
  1963. };
  1964. const cancel = () => emitAction("cancel");
  1965. const renderTitle = () => {
  1966. if (slots.title) {
  1967. return slots.title();
  1968. }
  1969. if (props.title) {
  1970. return vue.createVNode("div", {
  1971. "class": [bem$1f("title"), "van-ellipsis"]
  1972. }, [props.title]);
  1973. }
  1974. };
  1975. const renderCancel = () => {
  1976. const text = props.cancelButtonText || t$j("cancel");
  1977. return vue.createVNode("button", {
  1978. "type": "button",
  1979. "class": [bem$1f("cancel"), HAPTICS_FEEDBACK],
  1980. "onClick": cancel
  1981. }, [slots.cancel ? slots.cancel() : text]);
  1982. };
  1983. const renderConfirm = () => {
  1984. const text = props.confirmButtonText || t$j("confirm");
  1985. return vue.createVNode("button", {
  1986. "type": "button",
  1987. "class": [bem$1f("confirm"), HAPTICS_FEEDBACK],
  1988. "onClick": confirm
  1989. }, [slots.confirm ? slots.confirm() : text]);
  1990. };
  1991. const renderToolbar = () => {
  1992. if (props.showToolbar) {
  1993. const slot = slots.toolbar || slots.default;
  1994. return vue.createVNode("div", {
  1995. "class": bem$1f("toolbar")
  1996. }, [slot ? slot() : [renderCancel(), renderTitle(), renderConfirm()]]);
  1997. }
  1998. };
  1999. const renderColumnItems = () => formattedColumns.value.map((item, columnIndex) => {
  2000. var _a;
  2001. return vue.createVNode(stdin_default$1r, {
  2002. "textKey": columnsFieldNames.value.text,
  2003. "readonly": props.readonly,
  2004. "allowHtml": props.allowHtml,
  2005. "className": item.className,
  2006. "itemHeight": itemHeight.value,
  2007. "defaultIndex": (_a = item.defaultIndex) != null ? _a : +props.defaultIndex,
  2008. "swipeDuration": props.swipeDuration,
  2009. "initialOptions": item[columnsFieldNames.value.values],
  2010. "visibleItemCount": props.visibleItemCount,
  2011. "onChange": () => onChange(columnIndex)
  2012. }, {
  2013. option: slots.option
  2014. });
  2015. });
  2016. const renderMask = (wrapHeight) => {
  2017. if (hasOptions.value) {
  2018. const frameStyle = {
  2019. height: `${itemHeight.value}px`
  2020. };
  2021. const maskStyle = {
  2022. backgroundSize: `100% ${(wrapHeight - itemHeight.value) / 2}px`
  2023. };
  2024. return [vue.createVNode("div", {
  2025. "class": bem$1f("mask"),
  2026. "style": maskStyle
  2027. }, null), vue.createVNode("div", {
  2028. "class": [BORDER_UNSET_TOP_BOTTOM, bem$1f("frame")],
  2029. "style": frameStyle
  2030. }, null)];
  2031. }
  2032. };
  2033. const renderColumns = () => {
  2034. const wrapHeight = itemHeight.value * +props.visibleItemCount;
  2035. const columnsStyle = {
  2036. height: `${wrapHeight}px`
  2037. };
  2038. return vue.createVNode("div", {
  2039. "ref": columnsRef,
  2040. "class": bem$1f("columns"),
  2041. "style": columnsStyle
  2042. }, [renderColumnItems(), renderMask(wrapHeight)]);
  2043. };
  2044. vue.watch(() => props.columns, format2, {
  2045. immediate: true
  2046. });
  2047. use.useEventListener("touchmove", preventDefault, {
  2048. target: columnsRef
  2049. });
  2050. useExpose({
  2051. confirm,
  2052. getValues,
  2053. setValues,
  2054. getIndexes,
  2055. setIndexes,
  2056. getColumnIndex,
  2057. setColumnIndex,
  2058. getColumnValue,
  2059. setColumnValue,
  2060. getColumnValues,
  2061. setColumnValues
  2062. });
  2063. return () => {
  2064. var _a, _b;
  2065. return vue.createVNode("div", {
  2066. "class": bem$1f()
  2067. }, [props.toolbarPosition === "top" ? renderToolbar() : null, props.loading ? vue.createVNode(Loading, {
  2068. "class": bem$1f("loading")
  2069. }, null) : null, (_a = slots["columns-top"]) == null ? void 0 : _a.call(slots), renderColumns(), (_b = slots["columns-bottom"]) == null ? void 0 : _b.call(slots), props.toolbarPosition === "bottom" ? renderToolbar() : null]);
  2070. };
  2071. }
  2072. });
  2073. const Picker = withInstall(stdin_default$1q);
  2074. const [name$1i, bem$1e] = createNamespace("area");
  2075. const EMPTY_CODE = "000000";
  2076. const INHERIT_SLOTS = ["title", "cancel", "confirm", "toolbar", "columns-top", "columns-bottom"];
  2077. const INHERIT_PROPS = ["title", "loading", "readonly", "itemHeight", "swipeDuration", "visibleItemCount", "cancelButtonText", "confirmButtonText"];
  2078. const isOverseaCode = (code) => code[0] === "9";
  2079. const areaProps = extend({}, pickerSharedProps, {
  2080. value: String,
  2081. columnsNum: makeNumericProp(3),
  2082. columnsPlaceholder: makeArrayProp(),
  2083. areaList: {
  2084. type: Object,
  2085. default: () => ({})
  2086. },
  2087. isOverseaCode: {
  2088. type: Function,
  2089. default: isOverseaCode
  2090. }
  2091. });
  2092. var stdin_default$1p = vue.defineComponent({
  2093. name: name$1i,
  2094. props: areaProps,
  2095. emits: ["change", "confirm", "cancel"],
  2096. setup(props, {
  2097. emit,
  2098. slots
  2099. }) {
  2100. const pickerRef = vue.ref();
  2101. const state = vue.reactive({
  2102. code: props.value,
  2103. columns: [{
  2104. values: []
  2105. }, {
  2106. values: []
  2107. }, {
  2108. values: []
  2109. }]
  2110. });
  2111. const areaList = vue.computed(() => {
  2112. const {
  2113. areaList: areaList2
  2114. } = props;
  2115. return {
  2116. province: areaList2.province_list || {},
  2117. city: areaList2.city_list || {},
  2118. county: areaList2.county_list || {}
  2119. };
  2120. });
  2121. const placeholderMap = vue.computed(() => {
  2122. const {
  2123. columnsPlaceholder
  2124. } = props;
  2125. return {
  2126. province: columnsPlaceholder[0] || "",
  2127. city: columnsPlaceholder[1] || "",
  2128. county: columnsPlaceholder[2] || ""
  2129. };
  2130. });
  2131. const getDefaultCode = () => {
  2132. if (props.columnsPlaceholder.length) {
  2133. return EMPTY_CODE;
  2134. }
  2135. const {
  2136. county,
  2137. city
  2138. } = areaList.value;
  2139. const countyCodes = Object.keys(county);
  2140. if (countyCodes[0]) {
  2141. return countyCodes[0];
  2142. }
  2143. const cityCodes = Object.keys(city);
  2144. if (cityCodes[0]) {
  2145. return cityCodes[0];
  2146. }
  2147. return "";
  2148. };
  2149. const getColumnValues = (type, code) => {
  2150. let column = [];
  2151. if (type !== "province" && !code) {
  2152. return column;
  2153. }
  2154. const list = areaList.value[type];
  2155. column = Object.keys(list).map((listCode) => ({
  2156. code: listCode,
  2157. name: list[listCode]
  2158. }));
  2159. if (code) {
  2160. if (type === "city" && props.isOverseaCode(code)) {
  2161. code = "9";
  2162. }
  2163. column = column.filter((item) => item.code.indexOf(code) === 0);
  2164. }
  2165. if (placeholderMap.value[type] && column.length) {
  2166. let codeFill = "";
  2167. if (type === "city") {
  2168. codeFill = EMPTY_CODE.slice(2, 4);
  2169. } else if (type === "county") {
  2170. codeFill = EMPTY_CODE.slice(4, 6);
  2171. }
  2172. column.unshift({
  2173. code: code + codeFill,
  2174. name: placeholderMap.value[type]
  2175. });
  2176. }
  2177. return column;
  2178. };
  2179. const getIndex = (type, code) => {
  2180. let compareNum = code.length;
  2181. if (type === "province") {
  2182. compareNum = props.isOverseaCode(code) ? 1 : 2;
  2183. }
  2184. if (type === "city") {
  2185. compareNum = 4;
  2186. }
  2187. code = code.slice(0, compareNum);
  2188. const list = getColumnValues(type, compareNum > 2 ? code.slice(0, compareNum - 2) : "");
  2189. for (let i = 0; i < list.length; i++) {
  2190. if (list[i].code.slice(0, compareNum) === code) {
  2191. return i;
  2192. }
  2193. }
  2194. return 0;
  2195. };
  2196. const setValues = () => {
  2197. const picker = pickerRef.value;
  2198. if (!picker) {
  2199. return;
  2200. }
  2201. let code = state.code || getDefaultCode();
  2202. const province = getColumnValues("province");
  2203. const city = getColumnValues("city", code.slice(0, 2));
  2204. picker.setColumnValues(0, province);
  2205. picker.setColumnValues(1, city);
  2206. if (city.length && code.slice(2, 4) === "00" && !props.isOverseaCode(code)) {
  2207. [{
  2208. code
  2209. }] = city;
  2210. }
  2211. picker.setColumnValues(2, getColumnValues("county", code.slice(0, 4)));
  2212. picker.setIndexes([getIndex("province", code), getIndex("city", code), getIndex("county", code)]);
  2213. };
  2214. const parseValues = (values) => values.map((value, index) => {
  2215. if (value) {
  2216. value = deepClone(value);
  2217. if (!value.code || value.name === props.columnsPlaceholder[index]) {
  2218. value.code = "";
  2219. value.name = "";
  2220. }
  2221. }
  2222. return value;
  2223. });
  2224. const getValues = () => {
  2225. if (pickerRef.value) {
  2226. const values = pickerRef.value.getValues().filter(Boolean);
  2227. return parseValues(values);
  2228. }
  2229. return [];
  2230. };
  2231. const getArea = () => {
  2232. const values = getValues();
  2233. const area = {
  2234. code: "",
  2235. country: "",
  2236. province: "",
  2237. city: "",
  2238. county: ""
  2239. };
  2240. if (!values.length) {
  2241. return area;
  2242. }
  2243. const names = values.map((item) => item.name);
  2244. const validValues = values.filter((value) => value.code);
  2245. area.code = validValues.length ? validValues[validValues.length - 1].code : "";
  2246. if (props.isOverseaCode(area.code)) {
  2247. area.country = names[1] || "";
  2248. area.province = names[2] || "";
  2249. } else {
  2250. area.province = names[0] || "";
  2251. area.city = names[1] || "";
  2252. area.county = names[2] || "";
  2253. }
  2254. return area;
  2255. };
  2256. const reset = (newCode = "") => {
  2257. state.code = newCode;
  2258. setValues();
  2259. };
  2260. const onChange = (values, index) => {
  2261. state.code = values[index].code;
  2262. setValues();
  2263. if (pickerRef.value) {
  2264. const parsedValues = parseValues(pickerRef.value.getValues());
  2265. emit("change", parsedValues, index);
  2266. }
  2267. };
  2268. const onConfirm = (values, index) => {
  2269. setValues();
  2270. emit("confirm", parseValues(values), index);
  2271. };
  2272. const onCancel = (...args) => emit("cancel", ...args);
  2273. vue.onMounted(setValues);
  2274. vue.watch(() => props.value, (value) => {
  2275. state.code = value;
  2276. setValues();
  2277. });
  2278. vue.watch(() => props.areaList, setValues, {
  2279. deep: true
  2280. });
  2281. vue.watch(() => props.columnsNum, () => {
  2282. vue.nextTick(setValues);
  2283. });
  2284. useExpose({
  2285. reset,
  2286. getArea,
  2287. getValues
  2288. });
  2289. return () => {
  2290. const columns = state.columns.slice(0, +props.columnsNum);
  2291. return vue.createVNode(Picker, vue.mergeProps({
  2292. "ref": pickerRef,
  2293. "class": bem$1e(),
  2294. "columns": columns,
  2295. "columnsFieldNames": {
  2296. text: "name"
  2297. },
  2298. "onChange": onChange,
  2299. "onCancel": onCancel,
  2300. "onConfirm": onConfirm
  2301. }, pick(props, INHERIT_PROPS)), pick(slots, INHERIT_SLOTS));
  2302. };
  2303. }
  2304. });
  2305. const Area = withInstall(stdin_default$1p);
  2306. const [name$1h, bem$1d] = createNamespace("cell");
  2307. const cellSharedProps = {
  2308. icon: String,
  2309. size: String,
  2310. title: numericProp,
  2311. value: numericProp,
  2312. label: numericProp,
  2313. center: Boolean,
  2314. isLink: Boolean,
  2315. border: truthProp,
  2316. required: Boolean,
  2317. iconPrefix: String,
  2318. valueClass: unknownProp,
  2319. labelClass: unknownProp,
  2320. titleClass: unknownProp,
  2321. titleStyle: null,
  2322. arrowDirection: String,
  2323. clickable: {
  2324. type: Boolean,
  2325. default: null
  2326. }
  2327. };
  2328. const cellProps = extend({}, cellSharedProps, routeProps);
  2329. var stdin_default$1o = vue.defineComponent({
  2330. name: name$1h,
  2331. props: cellProps,
  2332. setup(props, {
  2333. slots
  2334. }) {
  2335. const route2 = useRoute();
  2336. const renderLabel = () => {
  2337. const showLabel = slots.label || isDef(props.label);
  2338. if (showLabel) {
  2339. return vue.createVNode("div", {
  2340. "class": [bem$1d("label"), props.labelClass]
  2341. }, [slots.label ? slots.label() : props.label]);
  2342. }
  2343. };
  2344. const renderTitle = () => {
  2345. if (slots.title || isDef(props.title)) {
  2346. return vue.createVNode("div", {
  2347. "class": [bem$1d("title"), props.titleClass],
  2348. "style": props.titleStyle
  2349. }, [slots.title ? slots.title() : vue.createVNode("span", null, [props.title]), renderLabel()]);
  2350. }
  2351. };
  2352. const renderValue = () => {
  2353. const slot = slots.value || slots.default;
  2354. const hasValue = slot || isDef(props.value);
  2355. if (hasValue) {
  2356. const hasTitle = slots.title || isDef(props.title);
  2357. return vue.createVNode("div", {
  2358. "class": [bem$1d("value", {
  2359. alone: !hasTitle
  2360. }), props.valueClass]
  2361. }, [slot ? slot() : vue.createVNode("span", null, [props.value])]);
  2362. }
  2363. };
  2364. const renderLeftIcon = () => {
  2365. if (slots.icon) {
  2366. return slots.icon();
  2367. }
  2368. if (props.icon) {
  2369. return vue.createVNode(Icon, {
  2370. "name": props.icon,
  2371. "class": bem$1d("left-icon"),
  2372. "classPrefix": props.iconPrefix
  2373. }, null);
  2374. }
  2375. };
  2376. const renderRightIcon = () => {
  2377. if (slots["right-icon"]) {
  2378. return slots["right-icon"]();
  2379. }
  2380. if (props.isLink) {
  2381. const name2 = props.arrowDirection && props.arrowDirection !== "right" ? `arrow-${props.arrowDirection}` : "arrow";
  2382. return vue.createVNode(Icon, {
  2383. "name": name2,
  2384. "class": bem$1d("right-icon")
  2385. }, null);
  2386. }
  2387. };
  2388. return () => {
  2389. var _a, _b;
  2390. const {
  2391. size,
  2392. center,
  2393. border,
  2394. isLink,
  2395. required
  2396. } = props;
  2397. const clickable = (_a = props.clickable) != null ? _a : isLink;
  2398. const classes = {
  2399. center,
  2400. required,
  2401. clickable,
  2402. borderless: !border
  2403. };
  2404. if (size) {
  2405. classes[size] = !!size;
  2406. }
  2407. return vue.createVNode("div", {
  2408. "class": bem$1d(classes),
  2409. "role": clickable ? "button" : void 0,
  2410. "tabindex": clickable ? 0 : void 0,
  2411. "onClick": route2
  2412. }, [renderLeftIcon(), renderTitle(), renderValue(), renderRightIcon(), (_b = slots.extra) == null ? void 0 : _b.call(slots)]);
  2413. };
  2414. }
  2415. });
  2416. const Cell = withInstall(stdin_default$1o);
  2417. const [name$1g, bem$1c] = createNamespace("form");
  2418. const formProps = {
  2419. colon: Boolean,
  2420. disabled: Boolean,
  2421. readonly: Boolean,
  2422. showError: Boolean,
  2423. labelWidth: numericProp,
  2424. labelAlign: String,
  2425. inputAlign: String,
  2426. scrollToError: Boolean,
  2427. validateFirst: Boolean,
  2428. submitOnEnter: truthProp,
  2429. showErrorMessage: truthProp,
  2430. errorMessageAlign: String,
  2431. validateTrigger: {
  2432. type: [String, Array],
  2433. default: "onBlur"
  2434. }
  2435. };
  2436. var stdin_default$1n = vue.defineComponent({
  2437. name: name$1g,
  2438. props: formProps,
  2439. emits: ["submit", "failed"],
  2440. setup(props, {
  2441. emit,
  2442. slots
  2443. }) {
  2444. const {
  2445. children,
  2446. linkChildren
  2447. } = use.useChildren(FORM_KEY);
  2448. const getFieldsByNames = (names) => {
  2449. if (names) {
  2450. return children.filter((field) => names.includes(field.name));
  2451. }
  2452. return children;
  2453. };
  2454. const validateSeq = (names) => new Promise((resolve, reject) => {
  2455. const errors = [];
  2456. const fields = getFieldsByNames(names);
  2457. fields.reduce((promise, field) => promise.then(() => {
  2458. if (!errors.length) {
  2459. return field.validate().then((error) => {
  2460. if (error) {
  2461. errors.push(error);
  2462. }
  2463. });
  2464. }
  2465. }), Promise.resolve()).then(() => {
  2466. if (errors.length) {
  2467. reject(errors);
  2468. } else {
  2469. resolve();
  2470. }
  2471. });
  2472. });
  2473. const validateAll = (names) => new Promise((resolve, reject) => {
  2474. const fields = getFieldsByNames(names);
  2475. Promise.all(fields.map((item) => item.validate())).then((errors) => {
  2476. errors = errors.filter(Boolean);
  2477. if (errors.length) {
  2478. reject(errors);
  2479. } else {
  2480. resolve();
  2481. }
  2482. });
  2483. });
  2484. const validateField = (name2) => {
  2485. const matched = children.find((item) => item.name === name2);
  2486. if (matched) {
  2487. return new Promise((resolve, reject) => {
  2488. matched.validate().then((error) => {
  2489. if (error) {
  2490. reject(error);
  2491. } else {
  2492. resolve();
  2493. }
  2494. });
  2495. });
  2496. }
  2497. return Promise.reject();
  2498. };
  2499. const validate = (name2) => {
  2500. if (typeof name2 === "string") {
  2501. return validateField(name2);
  2502. }
  2503. return props.validateFirst ? validateSeq(name2) : validateAll(name2);
  2504. };
  2505. const resetValidation = (name2) => {
  2506. if (typeof name2 === "string") {
  2507. name2 = [name2];
  2508. }
  2509. const fields = getFieldsByNames(name2);
  2510. fields.forEach((item) => {
  2511. item.resetValidation();
  2512. });
  2513. };
  2514. const getValidationStatus = () => children.reduce((form, field) => {
  2515. form[field.name] = field.getValidationStatus();
  2516. return form;
  2517. }, {});
  2518. const scrollToField = (name2, options) => {
  2519. children.some((item) => {
  2520. if (item.name === name2) {
  2521. item.$el.scrollIntoView(options);
  2522. return true;
  2523. }
  2524. return false;
  2525. });
  2526. };
  2527. const getValues = () => children.reduce((form, field) => {
  2528. form[field.name] = field.formValue.value;
  2529. return form;
  2530. }, {});
  2531. const submit = () => {
  2532. const values = getValues();
  2533. validate().then(() => emit("submit", values)).catch((errors) => {
  2534. emit("failed", {
  2535. values,
  2536. errors
  2537. });
  2538. if (props.scrollToError && errors[0].name) {
  2539. scrollToField(errors[0].name);
  2540. }
  2541. });
  2542. };
  2543. const onSubmit = (event) => {
  2544. preventDefault(event);
  2545. submit();
  2546. };
  2547. linkChildren({
  2548. props
  2549. });
  2550. useExpose({
  2551. submit,
  2552. validate,
  2553. getValues,
  2554. scrollToField,
  2555. resetValidation,
  2556. getValidationStatus
  2557. });
  2558. return () => {
  2559. var _a;
  2560. return vue.createVNode("form", {
  2561. "class": bem$1c(),
  2562. "onSubmit": onSubmit
  2563. }, [(_a = slots.default) == null ? void 0 : _a.call(slots)]);
  2564. };
  2565. }
  2566. });
  2567. const Form = withInstall(stdin_default$1n);
  2568. function isEmptyValue(value) {
  2569. if (Array.isArray(value)) {
  2570. return !value.length;
  2571. }
  2572. if (value === 0) {
  2573. return false;
  2574. }
  2575. return !value;
  2576. }
  2577. function runSyncRule(value, rule) {
  2578. if (isEmptyValue(value)) {
  2579. if (rule.required) {
  2580. return false;
  2581. }
  2582. if (rule.validateEmpty === false) {
  2583. return true;
  2584. }
  2585. }
  2586. if (rule.pattern && !rule.pattern.test(String(value))) {
  2587. return false;
  2588. }
  2589. return true;
  2590. }
  2591. function runRuleValidator(value, rule) {
  2592. return new Promise((resolve) => {
  2593. const returnVal = rule.validator(value, rule);
  2594. if (isPromise(returnVal)) {
  2595. returnVal.then(resolve);
  2596. return;
  2597. }
  2598. resolve(returnVal);
  2599. });
  2600. }
  2601. function getRuleMessage(value, rule) {
  2602. const { message } = rule;
  2603. if (isFunction(message)) {
  2604. return message(value, rule);
  2605. }
  2606. return message || "";
  2607. }
  2608. function startComposing({ target }) {
  2609. target.composing = true;
  2610. }
  2611. function endComposing({ target }) {
  2612. if (target.composing) {
  2613. target.composing = false;
  2614. target.dispatchEvent(new Event("input"));
  2615. }
  2616. }
  2617. function resizeTextarea(input, autosize) {
  2618. const scrollTop = getRootScrollTop();
  2619. input.style.height = "auto";
  2620. let height = input.scrollHeight;
  2621. if (isObject(autosize)) {
  2622. const { maxHeight, minHeight } = autosize;
  2623. if (maxHeight !== void 0) {
  2624. height = Math.min(height, maxHeight);
  2625. }
  2626. if (minHeight !== void 0) {
  2627. height = Math.max(height, minHeight);
  2628. }
  2629. }
  2630. if (height) {
  2631. input.style.height = `${height}px`;
  2632. setRootScrollTop(scrollTop);
  2633. }
  2634. }
  2635. function mapInputType(type) {
  2636. if (type === "number") {
  2637. return {
  2638. type: "text",
  2639. inputmode: "decimal"
  2640. };
  2641. }
  2642. if (type === "digit") {
  2643. return {
  2644. type: "tel",
  2645. inputmode: "numeric"
  2646. };
  2647. }
  2648. return { type };
  2649. }
  2650. function getStringLength(str) {
  2651. return [...str].length;
  2652. }
  2653. function cutString(str, maxlength) {
  2654. return [...str].slice(0, maxlength).join("");
  2655. }
  2656. let current = 0;
  2657. function useId() {
  2658. const vm = vue.getCurrentInstance();
  2659. const { name: name2 = "unknown" } = (vm == null ? void 0 : vm.type) || {};
  2660. if (process.env.NODE_ENV === "test") {
  2661. return name2;
  2662. }
  2663. return `${name2}-${++current}`;
  2664. }
  2665. const [name$1f, bem$1b] = createNamespace("field");
  2666. const fieldSharedProps = {
  2667. id: String,
  2668. name: String,
  2669. leftIcon: String,
  2670. rightIcon: String,
  2671. autofocus: Boolean,
  2672. clearable: Boolean,
  2673. maxlength: numericProp,
  2674. formatter: Function,
  2675. clearIcon: makeStringProp("clear"),
  2676. modelValue: makeNumericProp(""),
  2677. inputAlign: String,
  2678. placeholder: String,
  2679. autocomplete: String,
  2680. errorMessage: String,
  2681. enterkeyhint: String,
  2682. clearTrigger: makeStringProp("focus"),
  2683. formatTrigger: makeStringProp("onChange"),
  2684. error: {
  2685. type: Boolean,
  2686. default: null
  2687. },
  2688. disabled: {
  2689. type: Boolean,
  2690. default: null
  2691. },
  2692. readonly: {
  2693. type: Boolean,
  2694. default: null
  2695. }
  2696. };
  2697. const fieldProps = extend({}, cellSharedProps, fieldSharedProps, {
  2698. rows: numericProp,
  2699. type: makeStringProp("text"),
  2700. rules: Array,
  2701. autosize: [Boolean, Object],
  2702. labelWidth: numericProp,
  2703. labelClass: unknownProp,
  2704. labelAlign: String,
  2705. showWordLimit: Boolean,
  2706. errorMessageAlign: String,
  2707. colon: {
  2708. type: Boolean,
  2709. default: null
  2710. }
  2711. });
  2712. var stdin_default$1m = vue.defineComponent({
  2713. name: name$1f,
  2714. props: fieldProps,
  2715. emits: ["blur", "focus", "clear", "keypress", "click-input", "end-validate", "start-validate", "click-left-icon", "click-right-icon", "update:modelValue"],
  2716. setup(props, {
  2717. emit,
  2718. slots
  2719. }) {
  2720. const id = useId();
  2721. const state = vue.reactive({
  2722. status: "unvalidated",
  2723. focused: false,
  2724. validateMessage: ""
  2725. });
  2726. const inputRef = vue.ref();
  2727. const clearIconRef = vue.ref();
  2728. const customValue = vue.ref();
  2729. const {
  2730. parent: form
  2731. } = use.useParent(FORM_KEY);
  2732. const getModelValue = () => {
  2733. var _a;
  2734. return String((_a = props.modelValue) != null ? _a : "");
  2735. };
  2736. const getProp = (key) => {
  2737. if (isDef(props[key])) {
  2738. return props[key];
  2739. }
  2740. if (form && isDef(form.props[key])) {
  2741. return form.props[key];
  2742. }
  2743. };
  2744. const showClear = vue.computed(() => {
  2745. const readonly = getProp("readonly");
  2746. if (props.clearable && !readonly) {
  2747. const hasValue = getModelValue() !== "";
  2748. const trigger = props.clearTrigger === "always" || props.clearTrigger === "focus" && state.focused;
  2749. return hasValue && trigger;
  2750. }
  2751. return false;
  2752. });
  2753. const formValue = vue.computed(() => {
  2754. if (customValue.value && slots.input) {
  2755. return customValue.value();
  2756. }
  2757. return props.modelValue;
  2758. });
  2759. const runRules = (rules) => rules.reduce((promise, rule) => promise.then(() => {
  2760. if (state.status === "failed") {
  2761. return;
  2762. }
  2763. let {
  2764. value
  2765. } = formValue;
  2766. if (rule.formatter) {
  2767. value = rule.formatter(value, rule);
  2768. }
  2769. if (!runSyncRule(value, rule)) {
  2770. state.status = "failed";
  2771. state.validateMessage = getRuleMessage(value, rule);
  2772. return;
  2773. }
  2774. if (rule.validator) {
  2775. if (isEmptyValue(value) && rule.validateEmpty === false) {
  2776. return;
  2777. }
  2778. return runRuleValidator(value, rule).then((result) => {
  2779. if (result && typeof result === "string") {
  2780. state.status = "failed";
  2781. state.validateMessage = result;
  2782. } else if (result === false) {
  2783. state.status = "failed";
  2784. state.validateMessage = getRuleMessage(value, rule);
  2785. }
  2786. });
  2787. }
  2788. }), Promise.resolve());
  2789. const resetValidation = () => {
  2790. state.status = "unvalidated";
  2791. state.validateMessage = "";
  2792. };
  2793. const endValidate = () => emit("end-validate", {
  2794. status: state.status
  2795. });
  2796. const validate = (rules = props.rules) => new Promise((resolve) => {
  2797. resetValidation();
  2798. if (rules) {
  2799. emit("start-validate");
  2800. runRules(rules).then(() => {
  2801. if (state.status === "failed") {
  2802. resolve({
  2803. name: props.name,
  2804. message: state.validateMessage
  2805. });
  2806. endValidate();
  2807. } else {
  2808. state.status = "passed";
  2809. resolve();
  2810. endValidate();
  2811. }
  2812. });
  2813. } else {
  2814. resolve();
  2815. }
  2816. });
  2817. const validateWithTrigger = (trigger) => {
  2818. if (form && props.rules) {
  2819. const {
  2820. validateTrigger
  2821. } = form.props;
  2822. const defaultTrigger = toArray(validateTrigger).includes(trigger);
  2823. const rules = props.rules.filter((rule) => {
  2824. if (rule.trigger) {
  2825. return toArray(rule.trigger).includes(trigger);
  2826. }
  2827. return defaultTrigger;
  2828. });
  2829. if (rules.length) {
  2830. validate(rules);
  2831. }
  2832. }
  2833. };
  2834. const limitValueLength = (value) => {
  2835. const {
  2836. maxlength
  2837. } = props;
  2838. if (isDef(maxlength) && getStringLength(value) > maxlength) {
  2839. const modelValue = getModelValue();
  2840. if (modelValue && getStringLength(modelValue) === +maxlength) {
  2841. return modelValue;
  2842. }
  2843. return cutString(value, +maxlength);
  2844. }
  2845. return value;
  2846. };
  2847. const updateValue = (value, trigger = "onChange") => {
  2848. const originalValue = value;
  2849. value = limitValueLength(value);
  2850. const isExceedLimit = value !== originalValue;
  2851. if (props.type === "number" || props.type === "digit") {
  2852. const isNumber = props.type === "number";
  2853. value = formatNumber(value, isNumber, isNumber);
  2854. }
  2855. if (props.formatter && trigger === props.formatTrigger) {
  2856. value = props.formatter(value);
  2857. }
  2858. if (inputRef.value && inputRef.value.value !== value) {
  2859. if (state.focused && isExceedLimit) {
  2860. const {
  2861. selectionStart,
  2862. selectionEnd
  2863. } = inputRef.value;
  2864. inputRef.value.value = value;
  2865. inputRef.value.setSelectionRange(selectionStart - 1, selectionEnd - 1);
  2866. } else {
  2867. inputRef.value.value = value;
  2868. }
  2869. }
  2870. if (value !== props.modelValue) {
  2871. emit("update:modelValue", value);
  2872. }
  2873. };
  2874. const onInput = (event) => {
  2875. if (!event.target.composing) {
  2876. updateValue(event.target.value);
  2877. }
  2878. };
  2879. const blur = () => {
  2880. var _a;
  2881. return (_a = inputRef.value) == null ? void 0 : _a.blur();
  2882. };
  2883. const focus = () => {
  2884. var _a;
  2885. return (_a = inputRef.value) == null ? void 0 : _a.focus();
  2886. };
  2887. const adjustTextareaSize = () => {
  2888. const input = inputRef.value;
  2889. if (props.type === "textarea" && props.autosize && input) {
  2890. resizeTextarea(input, props.autosize);
  2891. }
  2892. };
  2893. const onFocus = (event) => {
  2894. state.focused = true;
  2895. emit("focus", event);
  2896. vue.nextTick(adjustTextareaSize);
  2897. if (getProp("readonly")) {
  2898. blur();
  2899. }
  2900. };
  2901. const onBlur = (event) => {
  2902. if (getProp("readonly")) {
  2903. return;
  2904. }
  2905. state.focused = false;
  2906. updateValue(getModelValue(), "onBlur");
  2907. emit("blur", event);
  2908. validateWithTrigger("onBlur");
  2909. vue.nextTick(adjustTextareaSize);
  2910. resetScroll();
  2911. };
  2912. const onClickInput = (event) => emit("click-input", event);
  2913. const onClickLeftIcon = (event) => emit("click-left-icon", event);
  2914. const onClickRightIcon = (event) => emit("click-right-icon", event);
  2915. const onClear = (event) => {
  2916. preventDefault(event);
  2917. emit("update:modelValue", "");
  2918. emit("clear", event);
  2919. };
  2920. const showError = vue.computed(() => {
  2921. if (typeof props.error === "boolean") {
  2922. return props.error;
  2923. }
  2924. if (form && form.props.showError && state.status === "failed") {
  2925. return true;
  2926. }
  2927. });
  2928. const labelStyle = vue.computed(() => {
  2929. const labelWidth = getProp("labelWidth");
  2930. if (labelWidth) {
  2931. return {
  2932. width: addUnit(labelWidth)
  2933. };
  2934. }
  2935. });
  2936. const onKeypress = (event) => {
  2937. const ENTER_CODE = 13;
  2938. if (event.keyCode === ENTER_CODE) {
  2939. const submitOnEnter = form && form.props.submitOnEnter;
  2940. if (!submitOnEnter && props.type !== "textarea") {
  2941. preventDefault(event);
  2942. }
  2943. if (props.type === "search") {
  2944. blur();
  2945. }
  2946. }
  2947. emit("keypress", event);
  2948. };
  2949. const getInputId = () => props.id || `${id}-input`;
  2950. const getValidationStatus = () => state.status;
  2951. const renderInput = () => {
  2952. const controlClass = bem$1b("control", [getProp("inputAlign"), {
  2953. error: showError.value,
  2954. custom: !!slots.input,
  2955. "min-height": props.type === "textarea" && !props.autosize
  2956. }]);
  2957. if (slots.input) {
  2958. return vue.createVNode("div", {
  2959. "class": controlClass,
  2960. "onClick": onClickInput
  2961. }, [slots.input()]);
  2962. }
  2963. const inputAttrs = {
  2964. id: getInputId(),
  2965. ref: inputRef,
  2966. name: props.name,
  2967. rows: props.rows !== void 0 ? +props.rows : void 0,
  2968. class: controlClass,
  2969. disabled: getProp("disabled"),
  2970. readonly: getProp("readonly"),
  2971. autofocus: props.autofocus,
  2972. placeholder: props.placeholder,
  2973. autocomplete: props.autocomplete,
  2974. enterkeyhint: props.enterkeyhint,
  2975. "aria-labelledby": props.label ? `${id}-label` : void 0,
  2976. onBlur,
  2977. onFocus,
  2978. onInput,
  2979. onClick: onClickInput,
  2980. onChange: endComposing,
  2981. onKeypress,
  2982. onCompositionend: endComposing,
  2983. onCompositionstart: startComposing
  2984. };
  2985. if (props.type === "textarea") {
  2986. return vue.createVNode("textarea", inputAttrs, null);
  2987. }
  2988. return vue.createVNode("input", vue.mergeProps(mapInputType(props.type), inputAttrs), null);
  2989. };
  2990. const renderLeftIcon = () => {
  2991. const leftIconSlot = slots["left-icon"];
  2992. if (props.leftIcon || leftIconSlot) {
  2993. return vue.createVNode("div", {
  2994. "class": bem$1b("left-icon"),
  2995. "onClick": onClickLeftIcon
  2996. }, [leftIconSlot ? leftIconSlot() : vue.createVNode(Icon, {
  2997. "name": props.leftIcon,
  2998. "classPrefix": props.iconPrefix
  2999. }, null)]);
  3000. }
  3001. };
  3002. const renderRightIcon = () => {
  3003. const rightIconSlot = slots["right-icon"];
  3004. if (props.rightIcon || rightIconSlot) {
  3005. return vue.createVNode("div", {
  3006. "class": bem$1b("right-icon"),
  3007. "onClick": onClickRightIcon
  3008. }, [rightIconSlot ? rightIconSlot() : vue.createVNode(Icon, {
  3009. "name": props.rightIcon,
  3010. "classPrefix": props.iconPrefix
  3011. }, null)]);
  3012. }
  3013. };
  3014. const renderWordLimit = () => {
  3015. if (props.showWordLimit && props.maxlength) {
  3016. const count = getStringLength(getModelValue());
  3017. return vue.createVNode("div", {
  3018. "class": bem$1b("word-limit")
  3019. }, [vue.createVNode("span", {
  3020. "class": bem$1b("word-num")
  3021. }, [count]), vue.createTextVNode("/"), props.maxlength]);
  3022. }
  3023. };
  3024. const renderMessage = () => {
  3025. if (form && form.props.showErrorMessage === false) {
  3026. return;
  3027. }
  3028. const message = props.errorMessage || state.validateMessage;
  3029. if (message) {
  3030. const slot = slots["error-message"];
  3031. const errorMessageAlign = getProp("errorMessageAlign");
  3032. return vue.createVNode("div", {
  3033. "class": bem$1b("error-message", errorMessageAlign)
  3034. }, [slot ? slot({
  3035. message
  3036. }) : message]);
  3037. }
  3038. };
  3039. const renderLabel = () => {
  3040. const colon = getProp("colon") ? ":" : "";
  3041. if (slots.label) {
  3042. return [slots.label(), colon];
  3043. }
  3044. if (props.label) {
  3045. return vue.createVNode("label", {
  3046. "id": `${id}-label`,
  3047. "for": getInputId()
  3048. }, [props.label + colon]);
  3049. }
  3050. };
  3051. const renderFieldBody = () => [vue.createVNode("div", {
  3052. "class": bem$1b("body")
  3053. }, [renderInput(), showClear.value && vue.createVNode(Icon, {
  3054. "ref": clearIconRef,
  3055. "name": props.clearIcon,
  3056. "class": bem$1b("clear")
  3057. }, null), renderRightIcon(), slots.button && vue.createVNode("div", {
  3058. "class": bem$1b("button")
  3059. }, [slots.button()])]), renderWordLimit(), renderMessage()];
  3060. useExpose({
  3061. blur,
  3062. focus,
  3063. validate,
  3064. formValue,
  3065. resetValidation,
  3066. getValidationStatus
  3067. });
  3068. vue.provide(use.CUSTOM_FIELD_INJECTION_KEY, {
  3069. customValue,
  3070. resetValidation,
  3071. validateWithTrigger
  3072. });
  3073. vue.watch(() => props.modelValue, () => {
  3074. updateValue(getModelValue());
  3075. resetValidation();
  3076. validateWithTrigger("onChange");
  3077. vue.nextTick(adjustTextareaSize);
  3078. });
  3079. vue.onMounted(() => {
  3080. updateValue(getModelValue(), props.formatTrigger);
  3081. vue.nextTick(adjustTextareaSize);
  3082. });
  3083. use.useEventListener("touchstart", onClear, {
  3084. target: vue.computed(() => {
  3085. var _a;
  3086. return (_a = clearIconRef.value) == null ? void 0 : _a.$el;
  3087. })
  3088. });
  3089. return () => {
  3090. const disabled = getProp("disabled");
  3091. const labelAlign = getProp("labelAlign");
  3092. const Label = renderLabel();
  3093. const LeftIcon = renderLeftIcon();
  3094. return vue.createVNode(Cell, {
  3095. "size": props.size,
  3096. "icon": props.leftIcon,
  3097. "class": bem$1b({
  3098. error: showError.value,
  3099. disabled,
  3100. [`label-${labelAlign}`]: labelAlign
  3101. }),
  3102. "center": props.center,
  3103. "border": props.border,
  3104. "isLink": props.isLink,
  3105. "clickable": props.clickable,
  3106. "titleStyle": labelStyle.value,
  3107. "valueClass": bem$1b("value"),
  3108. "titleClass": [bem$1b("label", [labelAlign, {
  3109. required: props.required
  3110. }]), props.labelClass],
  3111. "arrowDirection": props.arrowDirection
  3112. }, {
  3113. icon: LeftIcon ? () => LeftIcon : null,
  3114. title: Label ? () => Label : null,
  3115. value: renderFieldBody,
  3116. extra: slots.extra
  3117. });
  3118. };
  3119. }
  3120. });
  3121. const Field = withInstall(stdin_default$1m);
  3122. function usePopupState() {
  3123. const state = vue.reactive({
  3124. show: false
  3125. });
  3126. const toggle = (show) => {
  3127. state.show = show;
  3128. };
  3129. const open = (props) => {
  3130. extend(state, props, { transitionAppear: true });
  3131. toggle(true);
  3132. };
  3133. const close = () => toggle(false);
  3134. useExpose({ open, close, toggle });
  3135. return {
  3136. open,
  3137. close,
  3138. state,
  3139. toggle
  3140. };
  3141. }
  3142. function mountComponent(RootComponent) {
  3143. const app = vue.createApp(RootComponent);
  3144. const root = document.createElement("div");
  3145. document.body.appendChild(root);
  3146. return {
  3147. instance: app.mount(root),
  3148. unmount() {
  3149. app.unmount();
  3150. document.body.removeChild(root);
  3151. }
  3152. };
  3153. }
  3154. let lockCount = 0;
  3155. function lockClick(lock) {
  3156. if (lock) {
  3157. if (!lockCount) {
  3158. document.body.classList.add("van-toast--unclickable");
  3159. }
  3160. lockCount++;
  3161. } else if (lockCount) {
  3162. lockCount--;
  3163. if (!lockCount) {
  3164. document.body.classList.remove("van-toast--unclickable");
  3165. }
  3166. }
  3167. }
  3168. const [name$1e, bem$1a] = createNamespace("toast");
  3169. const popupInheritProps = ["show", "overlay", "teleport", "transition", "overlayClass", "overlayStyle", "closeOnClickOverlay"];
  3170. const toastProps = {
  3171. icon: String,
  3172. show: Boolean,
  3173. type: makeStringProp("text"),
  3174. overlay: Boolean,
  3175. message: numericProp,
  3176. iconSize: numericProp,
  3177. duration: makeNumberProp(2e3),
  3178. position: makeStringProp("middle"),
  3179. teleport: [String, Object],
  3180. className: unknownProp,
  3181. iconPrefix: String,
  3182. transition: makeStringProp("van-fade"),
  3183. loadingType: String,
  3184. forbidClick: Boolean,
  3185. overlayClass: unknownProp,
  3186. overlayStyle: Object,
  3187. closeOnClick: Boolean,
  3188. closeOnClickOverlay: Boolean
  3189. };
  3190. var stdin_default$1l = vue.defineComponent({
  3191. name: name$1e,
  3192. props: toastProps,
  3193. emits: ["update:show"],
  3194. setup(props, {
  3195. emit
  3196. }) {
  3197. let timer2;
  3198. let clickable = false;
  3199. const toggleClickable = () => {
  3200. const newValue = props.show && props.forbidClick;
  3201. if (clickable !== newValue) {
  3202. clickable = newValue;
  3203. lockClick(clickable);
  3204. }
  3205. };
  3206. const updateShow = (show) => emit("update:show", show);
  3207. const onClick = () => {
  3208. if (props.closeOnClick) {
  3209. updateShow(false);
  3210. }
  3211. };
  3212. const clearTimer = () => clearTimeout(timer2);
  3213. const renderIcon = () => {
  3214. const {
  3215. icon,
  3216. type,
  3217. iconSize,
  3218. iconPrefix,
  3219. loadingType
  3220. } = props;
  3221. const hasIcon = icon || type === "success" || type === "fail";
  3222. if (hasIcon) {
  3223. return vue.createVNode(Icon, {
  3224. "name": icon || type,
  3225. "size": iconSize,
  3226. "class": bem$1a("icon"),
  3227. "classPrefix": iconPrefix
  3228. }, null);
  3229. }
  3230. if (type === "loading") {
  3231. return vue.createVNode(Loading, {
  3232. "class": bem$1a("loading"),
  3233. "size": iconSize,
  3234. "type": loadingType
  3235. }, null);
  3236. }
  3237. };
  3238. const renderMessage = () => {
  3239. const {
  3240. type,
  3241. message
  3242. } = props;
  3243. if (isDef(message) && message !== "") {
  3244. return type === "html" ? vue.createVNode("div", {
  3245. "key": 0,
  3246. "class": bem$1a("text"),
  3247. "innerHTML": String(message)
  3248. }, null) : vue.createVNode("div", {
  3249. "class": bem$1a("text")
  3250. }, [message]);
  3251. }
  3252. };
  3253. vue.watch(() => [props.show, props.forbidClick], toggleClickable);
  3254. vue.watch(() => [props.show, props.type, props.message, props.duration], () => {
  3255. clearTimer();
  3256. if (props.show && props.duration > 0) {
  3257. timer2 = setTimeout(() => {
  3258. updateShow(false);
  3259. }, props.duration);
  3260. }
  3261. });
  3262. vue.onMounted(toggleClickable);
  3263. vue.onUnmounted(toggleClickable);
  3264. return () => vue.createVNode(Popup, vue.mergeProps({
  3265. "class": [bem$1a([props.position, {
  3266. [props.type]: !props.icon
  3267. }]), props.className],
  3268. "lockScroll": false,
  3269. "onClick": onClick,
  3270. "onClosed": clearTimer,
  3271. "onUpdate:show": updateShow
  3272. }, pick(props, popupInheritProps)), {
  3273. default: () => [renderIcon(), renderMessage()]
  3274. });
  3275. }
  3276. });
  3277. const defaultOptions$1 = {
  3278. icon: "",
  3279. type: "text",
  3280. message: "",
  3281. className: "",
  3282. overlay: false,
  3283. onClose: void 0,
  3284. onOpened: void 0,
  3285. duration: 2e3,
  3286. teleport: "body",
  3287. iconSize: void 0,
  3288. iconPrefix: void 0,
  3289. position: "middle",
  3290. transition: "van-fade",
  3291. forbidClick: false,
  3292. loadingType: void 0,
  3293. overlayClass: "",
  3294. overlayStyle: void 0,
  3295. closeOnClick: false,
  3296. closeOnClickOverlay: false
  3297. };
  3298. let queue = [];
  3299. let allowMultiple = false;
  3300. let currentOptions = extend({}, defaultOptions$1);
  3301. const defaultOptionsMap = /* @__PURE__ */ new Map();
  3302. function parseOptions$1(message) {
  3303. if (isObject(message)) {
  3304. return message;
  3305. }
  3306. return {
  3307. message
  3308. };
  3309. }
  3310. function createInstance() {
  3311. const {
  3312. instance: instance2,
  3313. unmount
  3314. } = mountComponent({
  3315. setup() {
  3316. const message = vue.ref("");
  3317. const {
  3318. open,
  3319. state,
  3320. close,
  3321. toggle
  3322. } = usePopupState();
  3323. const onClosed = () => {
  3324. if (allowMultiple) {
  3325. queue = queue.filter((item) => item !== instance2);
  3326. unmount();
  3327. }
  3328. };
  3329. const render = () => {
  3330. const attrs = {
  3331. onClosed,
  3332. "onUpdate:show": toggle
  3333. };
  3334. return vue.createVNode(stdin_default$1l, vue.mergeProps(state, attrs), null);
  3335. };
  3336. vue.watch(message, (val) => {
  3337. state.message = val;
  3338. });
  3339. vue.getCurrentInstance().render = render;
  3340. return {
  3341. open,
  3342. clear: close,
  3343. message
  3344. };
  3345. }
  3346. });
  3347. return instance2;
  3348. }
  3349. function getInstance() {
  3350. if (!queue.length || allowMultiple) {
  3351. const instance2 = createInstance();
  3352. queue.push(instance2);
  3353. }
  3354. return queue[queue.length - 1];
  3355. }
  3356. function Toast(options = {}) {
  3357. if (!inBrowser) {
  3358. return {};
  3359. }
  3360. const toast = getInstance();
  3361. const parsedOptions = parseOptions$1(options);
  3362. toast.open(extend({}, currentOptions, defaultOptionsMap.get(parsedOptions.type || currentOptions.type), parsedOptions));
  3363. return toast;
  3364. }
  3365. const createMethod = (type) => (options) => Toast(extend({
  3366. type
  3367. }, parseOptions$1(options)));
  3368. Toast.loading = createMethod("loading");
  3369. Toast.success = createMethod("success");
  3370. Toast.fail = createMethod("fail");
  3371. Toast.clear = (all) => {
  3372. var _a;
  3373. if (queue.length) {
  3374. if (all) {
  3375. queue.forEach((toast) => {
  3376. toast.clear();
  3377. });
  3378. queue = [];
  3379. } else if (!allowMultiple) {
  3380. queue[0].clear();
  3381. } else {
  3382. (_a = queue.shift()) == null ? void 0 : _a.clear();
  3383. }
  3384. }
  3385. };
  3386. function setDefaultOptions(type, options) {
  3387. if (typeof type === "string") {
  3388. defaultOptionsMap.set(type, options);
  3389. } else {
  3390. extend(currentOptions, type);
  3391. }
  3392. }
  3393. Toast.setDefaultOptions = setDefaultOptions;
  3394. Toast.resetDefaultOptions = (type) => {
  3395. if (typeof type === "string") {
  3396. defaultOptionsMap.delete(type);
  3397. } else {
  3398. currentOptions = extend({}, defaultOptions$1);
  3399. defaultOptionsMap.clear();
  3400. }
  3401. };
  3402. Toast.allowMultiple = (value = true) => {
  3403. allowMultiple = value;
  3404. };
  3405. Toast.install = (app) => {
  3406. app.use(withInstall(stdin_default$1l));
  3407. app.config.globalProperties.$toast = Toast;
  3408. };
  3409. const [name$1d, bem$19] = createNamespace("switch");
  3410. const switchProps = {
  3411. size: numericProp,
  3412. loading: Boolean,
  3413. disabled: Boolean,
  3414. modelValue: unknownProp,
  3415. activeColor: String,
  3416. inactiveColor: String,
  3417. activeValue: {
  3418. type: unknownProp,
  3419. default: true
  3420. },
  3421. inactiveValue: {
  3422. type: unknownProp,
  3423. default: false
  3424. }
  3425. };
  3426. var stdin_default$1k = vue.defineComponent({
  3427. name: name$1d,
  3428. props: switchProps,
  3429. emits: ["change", "update:modelValue"],
  3430. setup(props, {
  3431. emit,
  3432. slots
  3433. }) {
  3434. const isChecked = () => props.modelValue === props.activeValue;
  3435. const onClick = () => {
  3436. if (!props.disabled && !props.loading) {
  3437. const newValue = isChecked() ? props.inactiveValue : props.activeValue;
  3438. emit("update:modelValue", newValue);
  3439. emit("change", newValue);
  3440. }
  3441. };
  3442. const renderLoading = () => {
  3443. if (props.loading) {
  3444. const color = isChecked() ? props.activeColor : props.inactiveColor;
  3445. return vue.createVNode(Loading, {
  3446. "class": bem$19("loading"),
  3447. "color": color
  3448. }, null);
  3449. }
  3450. if (slots.node) {
  3451. return slots.node();
  3452. }
  3453. };
  3454. use.useCustomFieldValue(() => props.modelValue);
  3455. return () => {
  3456. var _a;
  3457. const {
  3458. size,
  3459. loading,
  3460. disabled,
  3461. activeColor,
  3462. inactiveColor
  3463. } = props;
  3464. const checked = isChecked();
  3465. const style = {
  3466. fontSize: addUnit(size),
  3467. backgroundColor: checked ? activeColor : inactiveColor
  3468. };
  3469. return vue.createVNode("div", {
  3470. "role": "switch",
  3471. "class": bem$19({
  3472. on: checked,
  3473. loading,
  3474. disabled
  3475. }),
  3476. "style": style,
  3477. "tabindex": disabled ? void 0 : 0,
  3478. "aria-checked": checked,
  3479. "onClick": onClick
  3480. }, [vue.createVNode("div", {
  3481. "class": bem$19("node")
  3482. }, [renderLoading()]), (_a = slots.background) == null ? void 0 : _a.call(slots)]);
  3483. };
  3484. }
  3485. });
  3486. const Switch = withInstall(stdin_default$1k);
  3487. const [name$1c, bem$18] = createNamespace("address-edit-detail");
  3488. const t$i = createNamespace("address-edit")[2];
  3489. var stdin_default$1j = vue.defineComponent({
  3490. name: name$1c,
  3491. props: {
  3492. show: Boolean,
  3493. rows: numericProp,
  3494. value: String,
  3495. rules: Array,
  3496. focused: Boolean,
  3497. maxlength: numericProp,
  3498. searchResult: Array,
  3499. showSearchResult: Boolean
  3500. },
  3501. emits: ["blur", "focus", "input", "select-search"],
  3502. setup(props, {
  3503. emit
  3504. }) {
  3505. const field = vue.ref();
  3506. const showSearchResult = () => props.focused && props.searchResult && props.showSearchResult;
  3507. const onSelect = (express) => {
  3508. emit("select-search", express);
  3509. emit("input", `${express.address || ""} ${express.name || ""}`.trim());
  3510. };
  3511. const renderSearchTitle = (express) => {
  3512. if (express.name) {
  3513. const text = express.name.replace(props.value, `<span class=${bem$18("keyword")}>${props.value}</span>`);
  3514. return vue.createVNode("div", {
  3515. "innerHTML": text
  3516. }, null);
  3517. }
  3518. };
  3519. const renderSearchResult = () => {
  3520. if (!showSearchResult()) {
  3521. return;
  3522. }
  3523. const {
  3524. searchResult
  3525. } = props;
  3526. return searchResult.map((express) => vue.createVNode(Cell, {
  3527. "clickable": true,
  3528. "key": express.name + express.address,
  3529. "icon": "location-o",
  3530. "label": express.address,
  3531. "class": bem$18("search-item"),
  3532. "border": false,
  3533. "onClick": () => onSelect(express)
  3534. }, {
  3535. title: () => renderSearchTitle(express)
  3536. }));
  3537. };
  3538. const onBlur = (event) => emit("blur", event);
  3539. const onFocus = (event) => emit("focus", event);
  3540. const onInput = (value) => emit("input", value);
  3541. return () => {
  3542. if (props.show) {
  3543. return vue.createVNode(vue.Fragment, null, [vue.createVNode(Field, {
  3544. "autosize": true,
  3545. "clearable": true,
  3546. "ref": field,
  3547. "class": bem$18(),
  3548. "rows": props.rows,
  3549. "type": "textarea",
  3550. "rules": props.rules,
  3551. "label": t$i("addressDetail"),
  3552. "border": !showSearchResult(),
  3553. "maxlength": props.maxlength,
  3554. "modelValue": props.value,
  3555. "placeholder": t$i("addressDetail"),
  3556. "onBlur": onBlur,
  3557. "onFocus": onFocus,
  3558. "onUpdate:modelValue": onInput
  3559. }, null), renderSearchResult()]);
  3560. }
  3561. };
  3562. }
  3563. });
  3564. const [name$1b, bem$17, t$h] = createNamespace("address-edit");
  3565. const DEFAULT_DATA = {
  3566. name: "",
  3567. tel: "",
  3568. city: "",
  3569. county: "",
  3570. country: "",
  3571. province: "",
  3572. areaCode: "",
  3573. isDefault: false,
  3574. postalCode: "",
  3575. addressDetail: ""
  3576. };
  3577. const isPostal = (value) => /^\d{6}$/.test(value);
  3578. const addressEditProps = {
  3579. areaList: Object,
  3580. isSaving: Boolean,
  3581. isDeleting: Boolean,
  3582. validator: Function,
  3583. showArea: truthProp,
  3584. showDetail: truthProp,
  3585. showDelete: Boolean,
  3586. showPostal: Boolean,
  3587. disableArea: Boolean,
  3588. searchResult: Array,
  3589. telMaxlength: numericProp,
  3590. showSetDefault: Boolean,
  3591. saveButtonText: String,
  3592. areaPlaceholder: String,
  3593. deleteButtonText: String,
  3594. showSearchResult: Boolean,
  3595. detailRows: makeNumericProp(1),
  3596. detailMaxlength: makeNumericProp(200),
  3597. areaColumnsPlaceholder: makeArrayProp(),
  3598. addressInfo: {
  3599. type: Object,
  3600. default: () => extend({}, DEFAULT_DATA)
  3601. },
  3602. telValidator: {
  3603. type: Function,
  3604. default: isMobile
  3605. },
  3606. postalValidator: {
  3607. type: Function,
  3608. default: isPostal
  3609. }
  3610. };
  3611. var stdin_default$1i = vue.defineComponent({
  3612. name: name$1b,
  3613. props: addressEditProps,
  3614. emits: ["save", "focus", "delete", "click-area", "change-area", "change-detail", "select-search", "change-default"],
  3615. setup(props, {
  3616. emit,
  3617. slots
  3618. }) {
  3619. const areaRef = vue.ref();
  3620. const data = vue.reactive({});
  3621. const showAreaPopup = vue.ref(false);
  3622. const detailFocused = vue.ref(false);
  3623. const areaListLoaded = vue.computed(() => isObject(props.areaList) && Object.keys(props.areaList).length);
  3624. const areaText = vue.computed(() => {
  3625. const {
  3626. country,
  3627. province,
  3628. city,
  3629. county,
  3630. areaCode
  3631. } = data;
  3632. if (areaCode) {
  3633. const arr = [country, province, city, county];
  3634. if (province && province === city) {
  3635. arr.splice(1, 1);
  3636. }
  3637. return arr.filter(Boolean).join("/");
  3638. }
  3639. return "";
  3640. });
  3641. const hideBottomFields = vue.computed(() => {
  3642. var _a;
  3643. return ((_a = props.searchResult) == null ? void 0 : _a.length) && detailFocused.value;
  3644. });
  3645. const assignAreaValues = () => {
  3646. if (areaRef.value) {
  3647. const detail = areaRef.value.getArea();
  3648. detail.areaCode = detail.code;
  3649. delete detail.code;
  3650. extend(data, detail);
  3651. }
  3652. };
  3653. const onFocus = (key) => {
  3654. detailFocused.value = key === "addressDetail";
  3655. emit("focus", key);
  3656. };
  3657. const rules = vue.computed(() => {
  3658. const {
  3659. validator,
  3660. telValidator,
  3661. postalValidator
  3662. } = props;
  3663. const makeRule = (name2, emptyMessage) => ({
  3664. validator: (value) => {
  3665. if (validator) {
  3666. const message = validator(name2, value);
  3667. if (message) {
  3668. return message;
  3669. }
  3670. }
  3671. if (!value) {
  3672. return emptyMessage;
  3673. }
  3674. return true;
  3675. }
  3676. });
  3677. return {
  3678. name: [makeRule("name", t$h("nameEmpty"))],
  3679. tel: [makeRule("tel", t$h("telInvalid")), {
  3680. validator: telValidator,
  3681. message: t$h("telInvalid")
  3682. }],
  3683. areaCode: [makeRule("areaCode", t$h("areaEmpty"))],
  3684. addressDetail: [makeRule("addressDetail", t$h("addressEmpty"))],
  3685. postalCode: [makeRule("addressDetail", t$h("postalEmpty")), {
  3686. validator: postalValidator,
  3687. message: t$h("postalEmpty")
  3688. }]
  3689. };
  3690. });
  3691. const onSave = () => emit("save", data);
  3692. const onChangeDetail = (val) => {
  3693. data.addressDetail = val;
  3694. emit("change-detail", val);
  3695. };
  3696. const onAreaConfirm = (values) => {
  3697. values = values.filter(Boolean);
  3698. if (values.some((value) => !value.code)) {
  3699. Toast(t$h("areaEmpty"));
  3700. } else {
  3701. showAreaPopup.value = false;
  3702. assignAreaValues();
  3703. emit("change-area", values);
  3704. }
  3705. };
  3706. const onDelete = () => emit("delete", data);
  3707. const getArea = () => {
  3708. var _a;
  3709. return ((_a = areaRef.value) == null ? void 0 : _a.getValues()) || [];
  3710. };
  3711. const setAreaCode = (code) => {
  3712. data.areaCode = code || "";
  3713. if (code) {
  3714. vue.nextTick(assignAreaValues);
  3715. }
  3716. };
  3717. const onDetailBlur = () => {
  3718. setTimeout(() => {
  3719. detailFocused.value = false;
  3720. });
  3721. };
  3722. const setAddressDetail = (value) => {
  3723. data.addressDetail = value;
  3724. };
  3725. const renderSetDefaultCell = () => {
  3726. if (props.showSetDefault) {
  3727. const slots2 = {
  3728. "right-icon": () => vue.createVNode(Switch, {
  3729. "modelValue": data.isDefault,
  3730. "onUpdate:modelValue": ($event) => data.isDefault = $event,
  3731. "size": "24",
  3732. "onChange": (event) => emit("change-default", event)
  3733. }, null)
  3734. };
  3735. return vue.withDirectives(vue.createVNode(Cell, {
  3736. "center": true,
  3737. "title": t$h("defaultAddress"),
  3738. "class": bem$17("default")
  3739. }, slots2), [[vue.vShow, !hideBottomFields.value]]);
  3740. }
  3741. };
  3742. useExpose({
  3743. getArea,
  3744. setAreaCode,
  3745. setAddressDetail
  3746. });
  3747. vue.watch(() => props.areaList, () => setAreaCode(data.areaCode));
  3748. vue.watch(() => props.addressInfo, (value) => {
  3749. extend(data, DEFAULT_DATA, value);
  3750. setAreaCode(value.areaCode);
  3751. }, {
  3752. deep: true,
  3753. immediate: true
  3754. });
  3755. return () => {
  3756. const {
  3757. disableArea
  3758. } = props;
  3759. return vue.createVNode(Form, {
  3760. "class": bem$17(),
  3761. "onSubmit": onSave
  3762. }, {
  3763. default: () => {
  3764. var _a;
  3765. return [vue.createVNode("div", {
  3766. "class": bem$17("fields")
  3767. }, [vue.createVNode(Field, {
  3768. "modelValue": data.name,
  3769. "onUpdate:modelValue": ($event) => data.name = $event,
  3770. "clearable": true,
  3771. "label": t$h("name"),
  3772. "rules": rules.value.name,
  3773. "placeholder": t$h("name"),
  3774. "onFocus": () => onFocus("name")
  3775. }, null), vue.createVNode(Field, {
  3776. "modelValue": data.tel,
  3777. "onUpdate:modelValue": ($event) => data.tel = $event,
  3778. "clearable": true,
  3779. "type": "tel",
  3780. "label": t$h("tel"),
  3781. "rules": rules.value.tel,
  3782. "maxlength": props.telMaxlength,
  3783. "placeholder": t$h("tel"),
  3784. "onFocus": () => onFocus("tel")
  3785. }, null), vue.withDirectives(vue.createVNode(Field, {
  3786. "readonly": true,
  3787. "label": t$h("area"),
  3788. "is-link": !disableArea,
  3789. "modelValue": areaText.value,
  3790. "rules": rules.value.areaCode,
  3791. "placeholder": props.areaPlaceholder || t$h("area"),
  3792. "onFocus": () => onFocus("areaCode"),
  3793. "onClick": () => {
  3794. emit("click-area");
  3795. showAreaPopup.value = !disableArea;
  3796. }
  3797. }, null), [[vue.vShow, props.showArea]]), vue.createVNode(stdin_default$1j, {
  3798. "show": props.showDetail,
  3799. "rows": props.detailRows,
  3800. "rules": rules.value.addressDetail,
  3801. "value": data.addressDetail,
  3802. "focused": detailFocused.value,
  3803. "maxlength": props.detailMaxlength,
  3804. "searchResult": props.searchResult,
  3805. "showSearchResult": props.showSearchResult,
  3806. "onBlur": onDetailBlur,
  3807. "onFocus": () => onFocus("addressDetail"),
  3808. "onInput": onChangeDetail,
  3809. "onSelect-search": (event) => emit("select-search", event)
  3810. }, null), props.showPostal && vue.withDirectives(vue.createVNode(Field, {
  3811. "modelValue": data.postalCode,
  3812. "onUpdate:modelValue": ($event) => data.postalCode = $event,
  3813. "type": "tel",
  3814. "rules": rules.value.postalCode,
  3815. "label": t$h("postal"),
  3816. "maxlength": "6",
  3817. "placeholder": t$h("postal"),
  3818. "onFocus": () => onFocus("postalCode")
  3819. }, null), [[vue.vShow, !hideBottomFields.value]]), (_a = slots.default) == null ? void 0 : _a.call(slots)]), renderSetDefaultCell(), vue.withDirectives(vue.createVNode("div", {
  3820. "class": bem$17("buttons")
  3821. }, [vue.createVNode(Button, {
  3822. "block": true,
  3823. "round": true,
  3824. "type": "danger",
  3825. "text": props.saveButtonText || t$h("save"),
  3826. "class": bem$17("button"),
  3827. "loading": props.isSaving,
  3828. "nativeType": "submit"
  3829. }, null), props.showDelete && vue.createVNode(Button, {
  3830. "block": true,
  3831. "round": true,
  3832. "class": bem$17("button"),
  3833. "loading": props.isDeleting,
  3834. "text": props.deleteButtonText || t$h("delete"),
  3835. "onClick": onDelete
  3836. }, null)]), [[vue.vShow, !hideBottomFields.value]]), vue.createVNode(Popup, {
  3837. "show": showAreaPopup.value,
  3838. "onUpdate:show": ($event) => showAreaPopup.value = $event,
  3839. "round": true,
  3840. "teleport": "body",
  3841. "position": "bottom",
  3842. "lazyRender": false
  3843. }, {
  3844. default: () => [vue.createVNode(Area, {
  3845. "ref": areaRef,
  3846. "value": data.areaCode,
  3847. "loading": !areaListLoaded.value,
  3848. "areaList": props.areaList,
  3849. "columnsPlaceholder": props.areaColumnsPlaceholder,
  3850. "onConfirm": onAreaConfirm,
  3851. "onCancel": () => {
  3852. showAreaPopup.value = false;
  3853. }
  3854. }, null)]
  3855. })];
  3856. }
  3857. });
  3858. };
  3859. }
  3860. });
  3861. const AddressEdit = withInstall(stdin_default$1i);
  3862. const [name$1a, bem$16] = createNamespace("radio-group");
  3863. const radioGroupProps = {
  3864. disabled: Boolean,
  3865. iconSize: numericProp,
  3866. direction: String,
  3867. modelValue: unknownProp,
  3868. checkedColor: String
  3869. };
  3870. const RADIO_KEY = Symbol(name$1a);
  3871. var stdin_default$1h = vue.defineComponent({
  3872. name: name$1a,
  3873. props: radioGroupProps,
  3874. emits: ["change", "update:modelValue"],
  3875. setup(props, {
  3876. emit,
  3877. slots
  3878. }) {
  3879. const {
  3880. linkChildren
  3881. } = use.useChildren(RADIO_KEY);
  3882. const updateValue = (value) => emit("update:modelValue", value);
  3883. vue.watch(() => props.modelValue, (value) => emit("change", value));
  3884. linkChildren({
  3885. props,
  3886. updateValue
  3887. });
  3888. use.useCustomFieldValue(() => props.modelValue);
  3889. return () => {
  3890. var _a;
  3891. return vue.createVNode("div", {
  3892. "class": bem$16([props.direction]),
  3893. "role": "radiogroup"
  3894. }, [(_a = slots.default) == null ? void 0 : _a.call(slots)]);
  3895. };
  3896. }
  3897. });
  3898. const RadioGroup = withInstall(stdin_default$1h);
  3899. const [name$19, bem$15] = createNamespace("tag");
  3900. const tagProps = {
  3901. size: String,
  3902. mark: Boolean,
  3903. show: truthProp,
  3904. type: makeStringProp("default"),
  3905. color: String,
  3906. plain: Boolean,
  3907. round: Boolean,
  3908. textColor: String,
  3909. closeable: Boolean
  3910. };
  3911. var stdin_default$1g = vue.defineComponent({
  3912. name: name$19,
  3913. props: tagProps,
  3914. emits: ["close"],
  3915. setup(props, {
  3916. slots,
  3917. emit
  3918. }) {
  3919. const onClose = (event) => {
  3920. event.stopPropagation();
  3921. emit("close", event);
  3922. };
  3923. const getStyle = () => {
  3924. if (props.plain) {
  3925. return {
  3926. color: props.textColor || props.color,
  3927. borderColor: props.color
  3928. };
  3929. }
  3930. return {
  3931. color: props.textColor,
  3932. background: props.color
  3933. };
  3934. };
  3935. const renderTag = () => {
  3936. var _a;
  3937. const {
  3938. type,
  3939. mark,
  3940. plain,
  3941. round,
  3942. size,
  3943. closeable
  3944. } = props;
  3945. const classes = {
  3946. mark,
  3947. plain,
  3948. round
  3949. };
  3950. if (size) {
  3951. classes[size] = size;
  3952. }
  3953. const CloseIcon = closeable && vue.createVNode(Icon, {
  3954. "name": "cross",
  3955. "class": [bem$15("close"), HAPTICS_FEEDBACK],
  3956. "onClick": onClose
  3957. }, null);
  3958. return vue.createVNode("span", {
  3959. "style": getStyle(),
  3960. "class": bem$15([classes, type])
  3961. }, [(_a = slots.default) == null ? void 0 : _a.call(slots), CloseIcon]);
  3962. };
  3963. return () => vue.createVNode(vue.Transition, {
  3964. "name": props.closeable ? "van-fade" : void 0
  3965. }, {
  3966. default: () => [props.show ? renderTag() : null]
  3967. });
  3968. }
  3969. });
  3970. const Tag = withInstall(stdin_default$1g);
  3971. const checkerProps = {
  3972. name: unknownProp,
  3973. shape: makeStringProp("round"),
  3974. disabled: Boolean,
  3975. iconSize: numericProp,
  3976. modelValue: unknownProp,
  3977. checkedColor: String,
  3978. labelPosition: String,
  3979. labelDisabled: Boolean
  3980. };
  3981. var stdin_default$1f = vue.defineComponent({
  3982. props: extend({}, checkerProps, {
  3983. bem: makeRequiredProp(Function),
  3984. role: String,
  3985. parent: Object,
  3986. checked: Boolean,
  3987. bindGroup: truthProp
  3988. }),
  3989. emits: ["click", "toggle"],
  3990. setup(props, {
  3991. emit,
  3992. slots
  3993. }) {
  3994. const iconRef = vue.ref();
  3995. const getParentProp = (name2) => {
  3996. if (props.parent && props.bindGroup) {
  3997. return props.parent.props[name2];
  3998. }
  3999. };
  4000. const disabled = vue.computed(() => getParentProp("disabled") || props.disabled);
  4001. const direction = vue.computed(() => getParentProp("direction"));
  4002. const iconStyle = vue.computed(() => {
  4003. const checkedColor = props.checkedColor || getParentProp("checkedColor");
  4004. if (checkedColor && props.checked && !disabled.value) {
  4005. return {
  4006. borderColor: checkedColor,
  4007. backgroundColor: checkedColor
  4008. };
  4009. }
  4010. });
  4011. const onClick = (event) => {
  4012. const {
  4013. target
  4014. } = event;
  4015. const icon = iconRef.value;
  4016. const iconClicked = icon === target || (icon == null ? void 0 : icon.contains(target));
  4017. if (!disabled.value && (iconClicked || !props.labelDisabled)) {
  4018. emit("toggle");
  4019. }
  4020. emit("click", event);
  4021. };
  4022. const renderIcon = () => {
  4023. const {
  4024. bem: bem2,
  4025. shape,
  4026. checked
  4027. } = props;
  4028. const iconSize = props.iconSize || getParentProp("iconSize");
  4029. return vue.createVNode("div", {
  4030. "ref": iconRef,
  4031. "class": bem2("icon", [shape, {
  4032. disabled: disabled.value,
  4033. checked
  4034. }]),
  4035. "style": {
  4036. fontSize: addUnit(iconSize)
  4037. }
  4038. }, [slots.icon ? slots.icon({
  4039. checked,
  4040. disabled: disabled.value
  4041. }) : vue.createVNode(Icon, {
  4042. "name": "success",
  4043. "style": iconStyle.value
  4044. }, null)]);
  4045. };
  4046. const renderLabel = () => {
  4047. if (slots.default) {
  4048. return vue.createVNode("span", {
  4049. "class": props.bem("label", [props.labelPosition, {
  4050. disabled: disabled.value
  4051. }])
  4052. }, [slots.default()]);
  4053. }
  4054. };
  4055. return () => {
  4056. const nodes = props.labelPosition === "left" ? [renderLabel(), renderIcon()] : [renderIcon(), renderLabel()];
  4057. return vue.createVNode("div", {
  4058. "role": props.role,
  4059. "class": props.bem([{
  4060. disabled: disabled.value,
  4061. "label-disabled": props.labelDisabled
  4062. }, direction.value]),
  4063. "tabindex": disabled.value ? void 0 : 0,
  4064. "aria-checked": props.checked,
  4065. "onClick": onClick
  4066. }, [nodes]);
  4067. };
  4068. }
  4069. });
  4070. const [name$18, bem$14] = createNamespace("radio");
  4071. var stdin_default$1e = vue.defineComponent({
  4072. name: name$18,
  4073. props: checkerProps,
  4074. emits: ["update:modelValue"],
  4075. setup(props, {
  4076. emit,
  4077. slots
  4078. }) {
  4079. const {
  4080. parent
  4081. } = use.useParent(RADIO_KEY);
  4082. const checked = () => {
  4083. const value = parent ? parent.props.modelValue : props.modelValue;
  4084. return value === props.name;
  4085. };
  4086. const toggle = () => {
  4087. if (parent) {
  4088. parent.updateValue(props.name);
  4089. } else {
  4090. emit("update:modelValue", props.name);
  4091. }
  4092. };
  4093. return () => vue.createVNode(stdin_default$1f, vue.mergeProps({
  4094. "bem": bem$14,
  4095. "role": "radio",
  4096. "parent": parent,
  4097. "checked": checked(),
  4098. "onToggle": toggle
  4099. }, props), pick(slots, ["default", "icon"]));
  4100. }
  4101. });
  4102. const Radio = withInstall(stdin_default$1e);
  4103. const [name$17, bem$13] = createNamespace("address-item");
  4104. var stdin_default$1d = vue.defineComponent({
  4105. name: name$17,
  4106. props: {
  4107. address: makeRequiredProp(Object),
  4108. disabled: Boolean,
  4109. switchable: Boolean,
  4110. defaultTagText: String
  4111. },
  4112. emits: ["edit", "click", "select"],
  4113. setup(props, {
  4114. slots,
  4115. emit
  4116. }) {
  4117. const onClick = () => {
  4118. if (props.switchable) {
  4119. emit("select");
  4120. }
  4121. emit("click");
  4122. };
  4123. const renderRightIcon = () => vue.createVNode(Icon, {
  4124. "name": "edit",
  4125. "class": bem$13("edit"),
  4126. "onClick": (event) => {
  4127. event.stopPropagation();
  4128. emit("edit");
  4129. emit("click");
  4130. }
  4131. }, null);
  4132. const renderTag = () => {
  4133. if (slots.tag) {
  4134. return slots.tag(props.address);
  4135. }
  4136. if (props.address.isDefault && props.defaultTagText) {
  4137. return vue.createVNode(Tag, {
  4138. "type": "danger",
  4139. "round": true,
  4140. "class": bem$13("tag")
  4141. }, {
  4142. default: () => [props.defaultTagText]
  4143. });
  4144. }
  4145. };
  4146. const renderContent = () => {
  4147. const {
  4148. address,
  4149. disabled,
  4150. switchable
  4151. } = props;
  4152. const Info = [vue.createVNode("div", {
  4153. "class": bem$13("name")
  4154. }, [`${address.name} ${address.tel}`, renderTag()]), vue.createVNode("div", {
  4155. "class": bem$13("address")
  4156. }, [address.address])];
  4157. if (switchable && !disabled) {
  4158. return vue.createVNode(Radio, {
  4159. "name": address.id,
  4160. "iconSize": 18
  4161. }, {
  4162. default: () => [Info]
  4163. });
  4164. }
  4165. return Info;
  4166. };
  4167. return () => {
  4168. var _a;
  4169. const {
  4170. disabled
  4171. } = props;
  4172. return vue.createVNode("div", {
  4173. "class": bem$13({
  4174. disabled
  4175. }),
  4176. "onClick": onClick
  4177. }, [vue.createVNode(Cell, {
  4178. "border": false,
  4179. "valueClass": bem$13("value")
  4180. }, {
  4181. value: renderContent,
  4182. "right-icon": renderRightIcon
  4183. }), (_a = slots.bottom) == null ? void 0 : _a.call(slots, extend({}, props.address, {
  4184. disabled
  4185. }))]);
  4186. };
  4187. }
  4188. });
  4189. const [name$16, bem$12, t$g] = createNamespace("address-list");
  4190. const addressListProps = {
  4191. list: makeArrayProp(),
  4192. modelValue: numericProp,
  4193. switchable: truthProp,
  4194. disabledText: String,
  4195. disabledList: makeArrayProp(),
  4196. addButtonText: String,
  4197. defaultTagText: String
  4198. };
  4199. var stdin_default$1c = vue.defineComponent({
  4200. name: name$16,
  4201. props: addressListProps,
  4202. emits: ["add", "edit", "select", "click-item", "edit-disabled", "select-disabled", "update:modelValue"],
  4203. setup(props, {
  4204. slots,
  4205. emit
  4206. }) {
  4207. const renderItem = (item, index, disabled) => {
  4208. const onEdit = () => emit(disabled ? "edit-disabled" : "edit", item, index);
  4209. const onClick = () => emit("click-item", item, index);
  4210. const onSelect = () => {
  4211. emit(disabled ? "select-disabled" : "select", item, index);
  4212. if (!disabled) {
  4213. emit("update:modelValue", item.id);
  4214. }
  4215. };
  4216. return vue.createVNode(stdin_default$1d, {
  4217. "key": item.id,
  4218. "address": item,
  4219. "disabled": disabled,
  4220. "switchable": props.switchable,
  4221. "defaultTagText": props.defaultTagText,
  4222. "onEdit": onEdit,
  4223. "onClick": onClick,
  4224. "onSelect": onSelect
  4225. }, {
  4226. bottom: slots["item-bottom"],
  4227. tag: slots.tag
  4228. });
  4229. };
  4230. const renderList = (list, disabled) => {
  4231. if (list) {
  4232. return list.map((item, index) => renderItem(item, index, disabled));
  4233. }
  4234. };
  4235. const renderBottom = () => vue.createVNode("div", {
  4236. "class": [bem$12("bottom"), "van-safe-area-bottom"]
  4237. }, [vue.createVNode(Button, {
  4238. "round": true,
  4239. "block": true,
  4240. "type": "danger",
  4241. "text": props.addButtonText || t$g("add"),
  4242. "class": bem$12("add"),
  4243. "onClick": () => emit("add")
  4244. }, null)]);
  4245. return () => {
  4246. var _a, _b;
  4247. const List2 = renderList(props.list);
  4248. const DisabledList = renderList(props.disabledList, true);
  4249. const DisabledText = props.disabledText && vue.createVNode("div", {
  4250. "class": bem$12("disabled-text")
  4251. }, [props.disabledText]);
  4252. return vue.createVNode("div", {
  4253. "class": bem$12()
  4254. }, [(_a = slots.top) == null ? void 0 : _a.call(slots), vue.createVNode(RadioGroup, {
  4255. "modelValue": props.modelValue
  4256. }, {
  4257. default: () => [List2]
  4258. }), DisabledText, DisabledList, (_b = slots.default) == null ? void 0 : _b.call(slots), renderBottom()]);
  4259. };
  4260. }
  4261. });
  4262. const AddressList = withInstall(stdin_default$1c);
  4263. const [name$15, bem$11, t$f] = createNamespace("calendar");
  4264. const formatMonthTitle = (date) => t$f("monthTitle", date.getFullYear(), date.getMonth() + 1);
  4265. function compareMonth(date1, date2) {
  4266. const year1 = date1.getFullYear();
  4267. const year2 = date2.getFullYear();
  4268. if (year1 === year2) {
  4269. const month1 = date1.getMonth();
  4270. const month2 = date2.getMonth();
  4271. return month1 === month2 ? 0 : month1 > month2 ? 1 : -1;
  4272. }
  4273. return year1 > year2 ? 1 : -1;
  4274. }
  4275. function compareDay(day1, day2) {
  4276. const compareMonthResult = compareMonth(day1, day2);
  4277. if (compareMonthResult === 0) {
  4278. const date1 = day1.getDate();
  4279. const date2 = day2.getDate();
  4280. return date1 === date2 ? 0 : date1 > date2 ? 1 : -1;
  4281. }
  4282. return compareMonthResult;
  4283. }
  4284. const cloneDate = (date) => new Date(date);
  4285. const cloneDates = (dates) => Array.isArray(dates) ? dates.map(cloneDate) : cloneDate(dates);
  4286. function getDayByOffset(date, offset) {
  4287. const cloned = cloneDate(date);
  4288. cloned.setDate(cloned.getDate() + offset);
  4289. return cloned;
  4290. }
  4291. const getPrevDay = (date) => getDayByOffset(date, -1);
  4292. const getNextDay = (date) => getDayByOffset(date, 1);
  4293. const getToday = () => {
  4294. const today = new Date();
  4295. today.setHours(0, 0, 0, 0);
  4296. return today;
  4297. };
  4298. function calcDateNum(date) {
  4299. const day1 = date[0].getTime();
  4300. const day2 = date[1].getTime();
  4301. return (day2 - day1) / (1e3 * 60 * 60 * 24) + 1;
  4302. }
  4303. function useRefs() {
  4304. const refs = vue.ref([]);
  4305. const cache = [];
  4306. vue.onBeforeUpdate(() => {
  4307. refs.value = [];
  4308. });
  4309. const setRefs = (index) => {
  4310. if (!cache[index]) {
  4311. cache[index] = (el) => {
  4312. refs.value[index] = el;
  4313. };
  4314. }
  4315. return cache[index];
  4316. };
  4317. return [refs, setRefs];
  4318. }
  4319. const sharedProps = extend({}, pickerSharedProps, {
  4320. filter: Function,
  4321. columnsOrder: Array,
  4322. formatter: {
  4323. type: Function,
  4324. default: (type, value) => value
  4325. }
  4326. });
  4327. const pickerInheritKeys = Object.keys(pickerSharedProps);
  4328. function times(n, iteratee) {
  4329. if (n < 0) {
  4330. return [];
  4331. }
  4332. const result = Array(n);
  4333. let index = -1;
  4334. while (++index < n) {
  4335. result[index] = iteratee(index);
  4336. }
  4337. return result;
  4338. }
  4339. function getTrueValue(value) {
  4340. if (!value) {
  4341. return 0;
  4342. }
  4343. while (Number.isNaN(parseInt(value, 10))) {
  4344. if (value.length > 1) {
  4345. value = value.slice(1);
  4346. } else {
  4347. return 0;
  4348. }
  4349. }
  4350. return parseInt(value, 10);
  4351. }
  4352. const getMonthEndDay = (year, month) => 32 - new Date(year, month - 1, 32).getDate();
  4353. const proxyPickerMethods = (picker, callback) => {
  4354. const methods = [
  4355. "setValues",
  4356. "setIndexes",
  4357. "setColumnIndex",
  4358. "setColumnValue"
  4359. ];
  4360. return new Proxy(picker, {
  4361. get: (target, prop) => {
  4362. if (methods.includes(prop)) {
  4363. return (...args) => {
  4364. target[prop](...args);
  4365. callback();
  4366. };
  4367. }
  4368. return target[prop];
  4369. }
  4370. });
  4371. };
  4372. const [name$14] = createNamespace("calendar-day");
  4373. var stdin_default$1b = vue.defineComponent({
  4374. name: name$14,
  4375. props: {
  4376. item: makeRequiredProp(Object),
  4377. color: String,
  4378. index: Number,
  4379. offset: makeNumberProp(0),
  4380. rowHeight: String
  4381. },
  4382. emits: ["click"],
  4383. setup(props, {
  4384. emit,
  4385. slots
  4386. }) {
  4387. const style = vue.computed(() => {
  4388. var _a;
  4389. const {
  4390. item,
  4391. index,
  4392. color,
  4393. offset,
  4394. rowHeight
  4395. } = props;
  4396. const style2 = {
  4397. height: rowHeight
  4398. };
  4399. if (item.type === "placeholder") {
  4400. style2.width = "100%";
  4401. return style2;
  4402. }
  4403. if (index === 0) {
  4404. style2.marginLeft = `${100 * offset / 7}%`;
  4405. }
  4406. if (color) {
  4407. switch (item.type) {
  4408. case "end":
  4409. case "start":
  4410. case "start-end":
  4411. case "multiple-middle":
  4412. case "multiple-selected":
  4413. style2.background = color;
  4414. break;
  4415. case "middle":
  4416. style2.color = color;
  4417. break;
  4418. }
  4419. }
  4420. if (offset + (((_a = item.date) == null ? void 0 : _a.getDate()) || 1) > 28) {
  4421. style2.marginBottom = 0;
  4422. }
  4423. return style2;
  4424. });
  4425. const onClick = () => {
  4426. if (props.item.type !== "disabled") {
  4427. emit("click", props.item);
  4428. }
  4429. };
  4430. const renderTopInfo = () => {
  4431. const {
  4432. topInfo
  4433. } = props.item;
  4434. if (topInfo || slots["top-info"]) {
  4435. return vue.createVNode("div", {
  4436. "class": bem$11("top-info")
  4437. }, [slots["top-info"] ? slots["top-info"](props.item) : topInfo]);
  4438. }
  4439. };
  4440. const renderBottomInfo = () => {
  4441. const {
  4442. bottomInfo
  4443. } = props.item;
  4444. if (bottomInfo || slots["bottom-info"]) {
  4445. return vue.createVNode("div", {
  4446. "class": bem$11("bottom-info")
  4447. }, [slots["bottom-info"] ? slots["bottom-info"](props.item) : bottomInfo]);
  4448. }
  4449. };
  4450. const renderContent = () => {
  4451. const {
  4452. item,
  4453. color,
  4454. rowHeight
  4455. } = props;
  4456. const {
  4457. type,
  4458. text
  4459. } = item;
  4460. const Nodes = [renderTopInfo(), text, renderBottomInfo()];
  4461. if (type === "selected") {
  4462. return vue.createVNode("div", {
  4463. "class": bem$11("selected-day"),
  4464. "style": {
  4465. width: rowHeight,
  4466. height: rowHeight,
  4467. background: color
  4468. }
  4469. }, [Nodes]);
  4470. }
  4471. return Nodes;
  4472. };
  4473. return () => {
  4474. const {
  4475. type,
  4476. className
  4477. } = props.item;
  4478. if (type === "placeholder") {
  4479. return vue.createVNode("div", {
  4480. "class": bem$11("day"),
  4481. "style": style.value
  4482. }, null);
  4483. }
  4484. return vue.createVNode("div", {
  4485. "role": "gridcell",
  4486. "style": style.value,
  4487. "class": [bem$11("day", type), className],
  4488. "tabindex": type === "disabled" ? void 0 : -1,
  4489. "onClick": onClick
  4490. }, [renderContent()]);
  4491. };
  4492. }
  4493. });
  4494. const [name$13] = createNamespace("calendar-month");
  4495. const calendarMonthProps = {
  4496. date: makeRequiredProp(Date),
  4497. type: String,
  4498. color: String,
  4499. minDate: makeRequiredProp(Date),
  4500. maxDate: makeRequiredProp(Date),
  4501. showMark: Boolean,
  4502. rowHeight: numericProp,
  4503. formatter: Function,
  4504. lazyRender: Boolean,
  4505. currentDate: [Date, Array],
  4506. allowSameDay: Boolean,
  4507. showSubtitle: Boolean,
  4508. showMonthTitle: Boolean,
  4509. firstDayOfWeek: Number
  4510. };
  4511. var stdin_default$1a = vue.defineComponent({
  4512. name: name$13,
  4513. props: calendarMonthProps,
  4514. emits: ["click", "update-height"],
  4515. setup(props, {
  4516. emit,
  4517. slots
  4518. }) {
  4519. const [visible, setVisible] = use.useToggle();
  4520. const daysRef = vue.ref();
  4521. const monthRef = vue.ref();
  4522. const height = useHeight(monthRef);
  4523. const title = vue.computed(() => formatMonthTitle(props.date));
  4524. const rowHeight = vue.computed(() => addUnit(props.rowHeight));
  4525. const offset = vue.computed(() => {
  4526. const realDay = props.date.getDay();
  4527. if (props.firstDayOfWeek) {
  4528. return (realDay + 7 - props.firstDayOfWeek) % 7;
  4529. }
  4530. return realDay;
  4531. });
  4532. const totalDay = vue.computed(() => getMonthEndDay(props.date.getFullYear(), props.date.getMonth() + 1));
  4533. const shouldRender = vue.computed(() => visible.value || !props.lazyRender);
  4534. const getTitle = () => title.value;
  4535. const getMultipleDayType = (day) => {
  4536. const isSelected = (date) => props.currentDate.some((item) => compareDay(item, date) === 0);
  4537. if (isSelected(day)) {
  4538. const prevDay = getPrevDay(day);
  4539. const nextDay = getNextDay(day);
  4540. const prevSelected = isSelected(prevDay);
  4541. const nextSelected = isSelected(nextDay);
  4542. if (prevSelected && nextSelected) {
  4543. return "multiple-middle";
  4544. }
  4545. if (prevSelected) {
  4546. return "end";
  4547. }
  4548. if (nextSelected) {
  4549. return "start";
  4550. }
  4551. return "multiple-selected";
  4552. }
  4553. return "";
  4554. };
  4555. const getRangeDayType = (day) => {
  4556. const [startDay, endDay] = props.currentDate;
  4557. if (!startDay) {
  4558. return "";
  4559. }
  4560. const compareToStart = compareDay(day, startDay);
  4561. if (!endDay) {
  4562. return compareToStart === 0 ? "start" : "";
  4563. }
  4564. const compareToEnd = compareDay(day, endDay);
  4565. if (props.allowSameDay && compareToStart === 0 && compareToEnd === 0) {
  4566. return "start-end";
  4567. }
  4568. if (compareToStart === 0) {
  4569. return "start";
  4570. }
  4571. if (compareToEnd === 0) {
  4572. return "end";
  4573. }
  4574. if (compareToStart > 0 && compareToEnd < 0) {
  4575. return "middle";
  4576. }
  4577. return "";
  4578. };
  4579. const getDayType = (day) => {
  4580. const {
  4581. type,
  4582. minDate,
  4583. maxDate,
  4584. currentDate
  4585. } = props;
  4586. if (compareDay(day, minDate) < 0 || compareDay(day, maxDate) > 0) {
  4587. return "disabled";
  4588. }
  4589. if (currentDate === null) {
  4590. return "";
  4591. }
  4592. if (Array.isArray(currentDate)) {
  4593. if (type === "multiple") {
  4594. return getMultipleDayType(day);
  4595. }
  4596. if (type === "range") {
  4597. return getRangeDayType(day);
  4598. }
  4599. } else if (type === "single") {
  4600. return compareDay(day, currentDate) === 0 ? "selected" : "";
  4601. }
  4602. return "";
  4603. };
  4604. const getBottomInfo = (dayType) => {
  4605. if (props.type === "range") {
  4606. if (dayType === "start" || dayType === "end") {
  4607. return t$f(dayType);
  4608. }
  4609. if (dayType === "start-end") {
  4610. return `${t$f("start")}/${t$f("end")}`;
  4611. }
  4612. }
  4613. };
  4614. const renderTitle = () => {
  4615. if (props.showMonthTitle) {
  4616. return vue.createVNode("div", {
  4617. "class": bem$11("month-title")
  4618. }, [title.value]);
  4619. }
  4620. };
  4621. const renderMark = () => {
  4622. if (props.showMark && shouldRender.value) {
  4623. return vue.createVNode("div", {
  4624. "class": bem$11("month-mark")
  4625. }, [props.date.getMonth() + 1]);
  4626. }
  4627. };
  4628. const placeholders = vue.computed(() => {
  4629. const count = Math.ceil((totalDay.value + offset.value) / 7);
  4630. return Array(count).fill({
  4631. type: "placeholder"
  4632. });
  4633. });
  4634. const days = vue.computed(() => {
  4635. const days2 = [];
  4636. const year = props.date.getFullYear();
  4637. const month = props.date.getMonth();
  4638. for (let day = 1; day <= totalDay.value; day++) {
  4639. const date = new Date(year, month, day);
  4640. const type = getDayType(date);
  4641. let config = {
  4642. date,
  4643. type,
  4644. text: day,
  4645. bottomInfo: getBottomInfo(type)
  4646. };
  4647. if (props.formatter) {
  4648. config = props.formatter(config);
  4649. }
  4650. days2.push(config);
  4651. }
  4652. return days2;
  4653. });
  4654. const disabledDays = vue.computed(() => days.value.filter((day) => day.type === "disabled"));
  4655. const scrollToDate = (body, targetDate) => {
  4656. if (daysRef.value) {
  4657. const daysRect = use.useRect(daysRef.value);
  4658. const totalRows = placeholders.value.length;
  4659. const currentRow = Math.ceil((targetDate.getDate() + offset.value) / 7);
  4660. const rowOffset = (currentRow - 1) * daysRect.height / totalRows;
  4661. setScrollTop(body, daysRect.top + rowOffset + body.scrollTop - use.useRect(body).top);
  4662. }
  4663. };
  4664. const renderDay = (item, index) => vue.createVNode(stdin_default$1b, {
  4665. "item": item,
  4666. "index": index,
  4667. "color": props.color,
  4668. "offset": offset.value,
  4669. "rowHeight": rowHeight.value,
  4670. "onClick": (item2) => emit("click", item2)
  4671. }, pick(slots, ["top-info", "bottom-info"]));
  4672. const renderDays = () => vue.createVNode("div", {
  4673. "ref": daysRef,
  4674. "role": "grid",
  4675. "class": bem$11("days")
  4676. }, [renderMark(), (shouldRender.value ? days : placeholders).value.map(renderDay)]);
  4677. useExpose({
  4678. getTitle,
  4679. getHeight: () => height.value,
  4680. setVisible,
  4681. scrollToDate,
  4682. disabledDays
  4683. });
  4684. return () => vue.createVNode("div", {
  4685. "class": bem$11("month"),
  4686. "ref": monthRef
  4687. }, [renderTitle(), renderDays()]);
  4688. }
  4689. });
  4690. const [name$12] = createNamespace("calendar-header");
  4691. var stdin_default$19 = vue.defineComponent({
  4692. name: name$12,
  4693. props: {
  4694. title: String,
  4695. subtitle: String,
  4696. showTitle: Boolean,
  4697. showSubtitle: Boolean,
  4698. firstDayOfWeek: Number
  4699. },
  4700. emits: ["click-subtitle"],
  4701. setup(props, {
  4702. slots,
  4703. emit
  4704. }) {
  4705. const renderTitle = () => {
  4706. if (props.showTitle) {
  4707. const text = props.title || t$f("title");
  4708. const title = slots.title ? slots.title() : text;
  4709. return vue.createVNode("div", {
  4710. "class": bem$11("header-title")
  4711. }, [title]);
  4712. }
  4713. };
  4714. const onClickSubtitle = (event) => emit("click-subtitle", event);
  4715. const renderSubtitle = () => {
  4716. if (props.showSubtitle) {
  4717. const title = slots.subtitle ? slots.subtitle() : props.subtitle;
  4718. return vue.createVNode("div", {
  4719. "class": bem$11("header-subtitle"),
  4720. "onClick": onClickSubtitle
  4721. }, [title]);
  4722. }
  4723. };
  4724. const renderWeekDays = () => {
  4725. const {
  4726. firstDayOfWeek
  4727. } = props;
  4728. const weekdays = t$f("weekdays");
  4729. const renderWeekDays2 = [...weekdays.slice(firstDayOfWeek, 7), ...weekdays.slice(0, firstDayOfWeek)];
  4730. return vue.createVNode("div", {
  4731. "class": bem$11("weekdays")
  4732. }, [renderWeekDays2.map((text) => vue.createVNode("span", {
  4733. "class": bem$11("weekday")
  4734. }, [text]))]);
  4735. };
  4736. return () => vue.createVNode("div", {
  4737. "class": bem$11("header")
  4738. }, [renderTitle(), renderSubtitle(), renderWeekDays()]);
  4739. }
  4740. });
  4741. const calendarProps = {
  4742. show: Boolean,
  4743. type: makeStringProp("single"),
  4744. title: String,
  4745. color: String,
  4746. round: truthProp,
  4747. readonly: Boolean,
  4748. poppable: truthProp,
  4749. maxRange: makeNumericProp(null),
  4750. position: makeStringProp("bottom"),
  4751. teleport: [String, Object],
  4752. showMark: truthProp,
  4753. showTitle: truthProp,
  4754. formatter: Function,
  4755. rowHeight: numericProp,
  4756. confirmText: String,
  4757. rangePrompt: String,
  4758. lazyRender: truthProp,
  4759. showConfirm: truthProp,
  4760. defaultDate: [Date, Array],
  4761. allowSameDay: Boolean,
  4762. showSubtitle: truthProp,
  4763. closeOnPopstate: truthProp,
  4764. showRangePrompt: truthProp,
  4765. confirmDisabledText: String,
  4766. closeOnClickOverlay: truthProp,
  4767. safeAreaInsetTop: Boolean,
  4768. safeAreaInsetBottom: truthProp,
  4769. minDate: {
  4770. type: Date,
  4771. validator: isDate,
  4772. default: getToday
  4773. },
  4774. maxDate: {
  4775. type: Date,
  4776. validator: isDate,
  4777. default: () => {
  4778. const now = getToday();
  4779. return new Date(now.getFullYear(), now.getMonth() + 6, now.getDate());
  4780. }
  4781. },
  4782. firstDayOfWeek: {
  4783. type: numericProp,
  4784. default: 0,
  4785. validator: (val) => val >= 0 && val <= 6
  4786. }
  4787. };
  4788. var stdin_default$18 = vue.defineComponent({
  4789. name: name$15,
  4790. props: calendarProps,
  4791. emits: ["select", "confirm", "unselect", "month-show", "over-range", "update:show", "click-subtitle"],
  4792. setup(props, {
  4793. emit,
  4794. slots
  4795. }) {
  4796. const limitDateRange = (date, minDate = props.minDate, maxDate = props.maxDate) => {
  4797. if (compareDay(date, minDate) === -1) {
  4798. return minDate;
  4799. }
  4800. if (compareDay(date, maxDate) === 1) {
  4801. return maxDate;
  4802. }
  4803. return date;
  4804. };
  4805. const getInitialDate = (defaultDate = props.defaultDate) => {
  4806. const {
  4807. type,
  4808. minDate,
  4809. maxDate,
  4810. allowSameDay
  4811. } = props;
  4812. if (defaultDate === null) {
  4813. return defaultDate;
  4814. }
  4815. const now = getToday();
  4816. if (type === "range") {
  4817. if (!Array.isArray(defaultDate)) {
  4818. defaultDate = [];
  4819. }
  4820. const start = limitDateRange(defaultDate[0] || now, minDate, allowSameDay ? maxDate : getPrevDay(maxDate));
  4821. const end = limitDateRange(defaultDate[1] || now, allowSameDay ? minDate : getNextDay(minDate));
  4822. return [start, end];
  4823. }
  4824. if (type === "multiple") {
  4825. if (Array.isArray(defaultDate)) {
  4826. return defaultDate.map((date) => limitDateRange(date));
  4827. }
  4828. return [limitDateRange(now)];
  4829. }
  4830. if (!defaultDate || Array.isArray(defaultDate)) {
  4831. defaultDate = now;
  4832. }
  4833. return limitDateRange(defaultDate);
  4834. };
  4835. let bodyHeight;
  4836. const bodyRef = vue.ref();
  4837. const subtitle = vue.ref("");
  4838. const currentDate = vue.ref(getInitialDate());
  4839. const [monthRefs, setMonthRefs] = useRefs();
  4840. const dayOffset = vue.computed(() => props.firstDayOfWeek ? +props.firstDayOfWeek % 7 : 0);
  4841. const months = vue.computed(() => {
  4842. const months2 = [];
  4843. const cursor = new Date(props.minDate);
  4844. cursor.setDate(1);
  4845. do {
  4846. months2.push(new Date(cursor));
  4847. cursor.setMonth(cursor.getMonth() + 1);
  4848. } while (compareMonth(cursor, props.maxDate) !== 1);
  4849. return months2;
  4850. });
  4851. const buttonDisabled = vue.computed(() => {
  4852. if (currentDate.value) {
  4853. if (props.type === "range") {
  4854. return !currentDate.value[0] || !currentDate.value[1];
  4855. }
  4856. if (props.type === "multiple") {
  4857. return !currentDate.value.length;
  4858. }
  4859. }
  4860. return !currentDate.value;
  4861. });
  4862. const getSelectedDate = () => currentDate.value;
  4863. const onScroll = () => {
  4864. const top = getScrollTop(bodyRef.value);
  4865. const bottom = top + bodyHeight;
  4866. const heights = months.value.map((item, index) => monthRefs.value[index].getHeight());
  4867. const heightSum = heights.reduce((a, b) => a + b, 0);
  4868. if (bottom > heightSum && top > 0) {
  4869. return;
  4870. }
  4871. let height = 0;
  4872. let currentMonth;
  4873. const visibleRange = [-1, -1];
  4874. for (let i = 0; i < months.value.length; i++) {
  4875. const month = monthRefs.value[i];
  4876. const visible = height <= bottom && height + heights[i] >= top;
  4877. if (visible) {
  4878. visibleRange[1] = i;
  4879. if (!currentMonth) {
  4880. currentMonth = month;
  4881. visibleRange[0] = i;
  4882. }
  4883. if (!monthRefs.value[i].showed) {
  4884. monthRefs.value[i].showed = true;
  4885. emit("month-show", {
  4886. date: month.date,
  4887. title: month.getTitle()
  4888. });
  4889. }
  4890. }
  4891. height += heights[i];
  4892. }
  4893. months.value.forEach((month, index) => {
  4894. const visible = index >= visibleRange[0] - 1 && index <= visibleRange[1] + 1;
  4895. monthRefs.value[index].setVisible(visible);
  4896. });
  4897. if (currentMonth) {
  4898. subtitle.value = currentMonth.getTitle();
  4899. }
  4900. };
  4901. const scrollToDate = (targetDate) => {
  4902. use.raf(() => {
  4903. months.value.some((month, index) => {
  4904. if (compareMonth(month, targetDate) === 0) {
  4905. if (bodyRef.value) {
  4906. monthRefs.value[index].scrollToDate(bodyRef.value, targetDate);
  4907. }
  4908. return true;
  4909. }
  4910. return false;
  4911. });
  4912. onScroll();
  4913. });
  4914. };
  4915. const scrollToCurrentDate = () => {
  4916. if (props.poppable && !props.show) {
  4917. return;
  4918. }
  4919. if (currentDate.value) {
  4920. const targetDate = props.type === "single" ? currentDate.value : currentDate.value[0];
  4921. if (isDate(targetDate)) {
  4922. scrollToDate(targetDate);
  4923. }
  4924. } else {
  4925. use.raf(onScroll);
  4926. }
  4927. };
  4928. const init = () => {
  4929. if (props.poppable && !props.show) {
  4930. return;
  4931. }
  4932. use.raf(() => {
  4933. bodyHeight = Math.floor(use.useRect(bodyRef).height);
  4934. });
  4935. scrollToCurrentDate();
  4936. };
  4937. const reset = (date = getInitialDate()) => {
  4938. currentDate.value = date;
  4939. scrollToCurrentDate();
  4940. };
  4941. const checkRange = (date) => {
  4942. const {
  4943. maxRange,
  4944. rangePrompt,
  4945. showRangePrompt
  4946. } = props;
  4947. if (maxRange && calcDateNum(date) > maxRange) {
  4948. if (showRangePrompt) {
  4949. Toast(rangePrompt || t$f("rangePrompt", maxRange));
  4950. }
  4951. emit("over-range");
  4952. return false;
  4953. }
  4954. return true;
  4955. };
  4956. const onConfirm = () => {
  4957. var _a;
  4958. return emit("confirm", (_a = currentDate.value) != null ? _a : cloneDates(currentDate.value));
  4959. };
  4960. const select = (date, complete) => {
  4961. const setCurrentDate = (date2) => {
  4962. currentDate.value = date2;
  4963. emit("select", cloneDates(date2));
  4964. };
  4965. if (complete && props.type === "range") {
  4966. const valid = checkRange(date);
  4967. if (!valid) {
  4968. setCurrentDate([date[0], getDayByOffset(date[0], +props.maxRange - 1)]);
  4969. return;
  4970. }
  4971. }
  4972. setCurrentDate(date);
  4973. if (complete && !props.showConfirm) {
  4974. onConfirm();
  4975. }
  4976. };
  4977. const getDisabledDate = (disabledDays2, startDay, date) => {
  4978. var _a;
  4979. return (_a = disabledDays2.find((day) => compareDay(startDay, day.date) === -1 && compareDay(day.date, date) === -1)) == null ? void 0 : _a.date;
  4980. };
  4981. const disabledDays = vue.computed(() => monthRefs.value.reduce((arr, ref2) => {
  4982. var _a, _b;
  4983. arr.push(...(_b = (_a = ref2.disabledDays) == null ? void 0 : _a.value) != null ? _b : []);
  4984. return arr;
  4985. }, []));
  4986. const onClickDay = (item) => {
  4987. if (props.readonly || !item.date) {
  4988. return;
  4989. }
  4990. const {
  4991. date
  4992. } = item;
  4993. const {
  4994. type
  4995. } = props;
  4996. if (type === "range") {
  4997. if (!currentDate.value) {
  4998. select([date]);
  4999. return;
  5000. }
  5001. const [startDay, endDay] = currentDate.value;
  5002. if (startDay && !endDay) {
  5003. const compareToStart = compareDay(date, startDay);
  5004. if (compareToStart === 1) {
  5005. const disabledDay = getDisabledDate(disabledDays.value, startDay, date);
  5006. if (disabledDay) {
  5007. const endDay2 = getPrevDay(disabledDay);
  5008. if (compareDay(startDay, endDay2) === -1) {
  5009. select([startDay, endDay2]);
  5010. } else {
  5011. select([date]);
  5012. }
  5013. } else {
  5014. select([startDay, date], true);
  5015. }
  5016. } else if (compareToStart === -1) {
  5017. select([date]);
  5018. } else if (props.allowSameDay) {
  5019. select([date, date], true);
  5020. }
  5021. } else {
  5022. select([date]);
  5023. }
  5024. } else if (type === "multiple") {
  5025. if (!currentDate.value) {
  5026. select([date]);
  5027. return;
  5028. }
  5029. const dates = currentDate.value;
  5030. const selectedIndex = dates.findIndex((dateItem) => compareDay(dateItem, date) === 0);
  5031. if (selectedIndex !== -1) {
  5032. const [unselectedDate] = dates.splice(selectedIndex, 1);
  5033. emit("unselect", cloneDate(unselectedDate));
  5034. } else if (props.maxRange && dates.length >= props.maxRange) {
  5035. Toast(props.rangePrompt || t$f("rangePrompt", props.maxRange));
  5036. } else {
  5037. select([...dates, date]);
  5038. }
  5039. } else {
  5040. select(date, true);
  5041. }
  5042. };
  5043. const updateShow = (value) => emit("update:show", value);
  5044. const renderMonth = (date, index) => {
  5045. const showMonthTitle = index !== 0 || !props.showSubtitle;
  5046. return vue.createVNode(stdin_default$1a, vue.mergeProps({
  5047. "ref": setMonthRefs(index),
  5048. "date": date,
  5049. "currentDate": currentDate.value,
  5050. "showMonthTitle": showMonthTitle,
  5051. "firstDayOfWeek": dayOffset.value
  5052. }, pick(props, ["type", "color", "minDate", "maxDate", "showMark", "formatter", "rowHeight", "lazyRender", "showSubtitle", "allowSameDay"]), {
  5053. "onClick": onClickDay
  5054. }), pick(slots, ["top-info", "bottom-info"]));
  5055. };
  5056. const renderFooterButton = () => {
  5057. if (slots.footer) {
  5058. return slots.footer();
  5059. }
  5060. if (props.showConfirm) {
  5061. const slot = slots["confirm-text"];
  5062. const disabled = buttonDisabled.value;
  5063. const text = disabled ? props.confirmDisabledText : props.confirmText;
  5064. return vue.createVNode(Button, {
  5065. "round": true,
  5066. "block": true,
  5067. "type": "danger",
  5068. "color": props.color,
  5069. "class": bem$11("confirm"),
  5070. "disabled": disabled,
  5071. "nativeType": "button",
  5072. "onClick": onConfirm
  5073. }, {
  5074. default: () => [slot ? slot({
  5075. disabled
  5076. }) : text || t$f("confirm")]
  5077. });
  5078. }
  5079. };
  5080. const renderFooter = () => vue.createVNode("div", {
  5081. "class": [bem$11("footer"), {
  5082. "van-safe-area-bottom": props.safeAreaInsetBottom
  5083. }]
  5084. }, [renderFooterButton()]);
  5085. const renderCalendar = () => vue.createVNode("div", {
  5086. "class": bem$11()
  5087. }, [vue.createVNode(stdin_default$19, {
  5088. "title": props.title,
  5089. "subtitle": subtitle.value,
  5090. "showTitle": props.showTitle,
  5091. "showSubtitle": props.showSubtitle,
  5092. "firstDayOfWeek": dayOffset.value,
  5093. "onClick-subtitle": (event) => emit("click-subtitle", event)
  5094. }, pick(slots, ["title", "subtitle"])), vue.createVNode("div", {
  5095. "ref": bodyRef,
  5096. "class": bem$11("body"),
  5097. "onScroll": onScroll
  5098. }, [months.value.map(renderMonth)]), renderFooter()]);
  5099. vue.watch(() => props.show, init);
  5100. vue.watch(() => [props.type, props.minDate, props.maxDate], () => reset(getInitialDate(currentDate.value)));
  5101. vue.watch(() => props.defaultDate, (value = null) => {
  5102. currentDate.value = value;
  5103. scrollToCurrentDate();
  5104. });
  5105. useExpose({
  5106. reset,
  5107. scrollToDate,
  5108. getSelectedDate
  5109. });
  5110. use.onMountedOrActivated(init);
  5111. return () => {
  5112. if (props.poppable) {
  5113. return vue.createVNode(Popup, {
  5114. "show": props.show,
  5115. "class": bem$11("popup"),
  5116. "round": props.round,
  5117. "position": props.position,
  5118. "closeable": props.showTitle || props.showSubtitle,
  5119. "teleport": props.teleport,
  5120. "closeOnPopstate": props.closeOnPopstate,
  5121. "safeAreaInsetTop": props.safeAreaInsetTop,
  5122. "closeOnClickOverlay": props.closeOnClickOverlay,
  5123. "onUpdate:show": updateShow
  5124. }, {
  5125. default: renderCalendar
  5126. });
  5127. }
  5128. return renderCalendar();
  5129. };
  5130. }
  5131. });
  5132. const Calendar = withInstall(stdin_default$18);
  5133. const [name$11, bem$10] = createNamespace("image");
  5134. const imageProps = {
  5135. src: String,
  5136. alt: String,
  5137. fit: String,
  5138. position: String,
  5139. round: Boolean,
  5140. block: Boolean,
  5141. width: numericProp,
  5142. height: numericProp,
  5143. radius: numericProp,
  5144. lazyLoad: Boolean,
  5145. iconSize: numericProp,
  5146. showError: truthProp,
  5147. errorIcon: makeStringProp("photo-fail"),
  5148. iconPrefix: String,
  5149. showLoading: truthProp,
  5150. loadingIcon: makeStringProp("photo")
  5151. };
  5152. var stdin_default$17 = vue.defineComponent({
  5153. name: name$11,
  5154. props: imageProps,
  5155. emits: ["load", "error"],
  5156. setup(props, {
  5157. emit,
  5158. slots
  5159. }) {
  5160. const error = vue.ref(false);
  5161. const loading = vue.ref(true);
  5162. const imageRef = vue.ref();
  5163. const {
  5164. $Lazyload
  5165. } = vue.getCurrentInstance().proxy;
  5166. const style = vue.computed(() => {
  5167. const style2 = {
  5168. width: addUnit(props.width),
  5169. height: addUnit(props.height)
  5170. };
  5171. if (isDef(props.radius)) {
  5172. style2.overflow = "hidden";
  5173. style2.borderRadius = addUnit(props.radius);
  5174. }
  5175. return style2;
  5176. });
  5177. vue.watch(() => props.src, () => {
  5178. error.value = false;
  5179. loading.value = true;
  5180. });
  5181. const onLoad = (event) => {
  5182. loading.value = false;
  5183. emit("load", event);
  5184. };
  5185. const onError = (event) => {
  5186. error.value = true;
  5187. loading.value = false;
  5188. emit("error", event);
  5189. };
  5190. const renderIcon = (name2, className, slot) => {
  5191. if (slot) {
  5192. return slot();
  5193. }
  5194. return vue.createVNode(Icon, {
  5195. "name": name2,
  5196. "size": props.iconSize,
  5197. "class": className,
  5198. "classPrefix": props.iconPrefix
  5199. }, null);
  5200. };
  5201. const renderPlaceholder = () => {
  5202. if (loading.value && props.showLoading) {
  5203. return vue.createVNode("div", {
  5204. "class": bem$10("loading")
  5205. }, [renderIcon(props.loadingIcon, bem$10("loading-icon"), slots.loading)]);
  5206. }
  5207. if (error.value && props.showError) {
  5208. return vue.createVNode("div", {
  5209. "class": bem$10("error")
  5210. }, [renderIcon(props.errorIcon, bem$10("error-icon"), slots.error)]);
  5211. }
  5212. };
  5213. const renderImage = () => {
  5214. if (error.value || !props.src) {
  5215. return;
  5216. }
  5217. const attrs = {
  5218. alt: props.alt,
  5219. class: bem$10("img"),
  5220. style: {
  5221. objectFit: props.fit,
  5222. objectPosition: props.position
  5223. }
  5224. };
  5225. if (props.lazyLoad) {
  5226. return vue.withDirectives(vue.createVNode("img", vue.mergeProps({
  5227. "ref": imageRef
  5228. }, attrs), null), [[vue.resolveDirective("lazy"), props.src]]);
  5229. }
  5230. return vue.createVNode("img", vue.mergeProps({
  5231. "src": props.src,
  5232. "onLoad": onLoad,
  5233. "onError": onError
  5234. }, attrs), null);
  5235. };
  5236. const onLazyLoaded = ({
  5237. el
  5238. }) => {
  5239. const check = () => {
  5240. if (el === imageRef.value && loading.value) {
  5241. onLoad();
  5242. }
  5243. };
  5244. if (imageRef.value) {
  5245. check();
  5246. } else {
  5247. vue.nextTick(check);
  5248. }
  5249. };
  5250. const onLazyLoadError = ({
  5251. el
  5252. }) => {
  5253. if (el === imageRef.value && !error.value) {
  5254. onError();
  5255. }
  5256. };
  5257. if ($Lazyload && inBrowser) {
  5258. $Lazyload.$on("loaded", onLazyLoaded);
  5259. $Lazyload.$on("error", onLazyLoadError);
  5260. vue.onBeforeUnmount(() => {
  5261. $Lazyload.$off("loaded", onLazyLoaded);
  5262. $Lazyload.$off("error", onLazyLoadError);
  5263. });
  5264. }
  5265. return () => {
  5266. var _a;
  5267. return vue.createVNode("div", {
  5268. "class": bem$10({
  5269. round: props.round,
  5270. block: props.block
  5271. }),
  5272. "style": style.value
  5273. }, [renderImage(), renderPlaceholder(), (_a = slots.default) == null ? void 0 : _a.call(slots)]);
  5274. };
  5275. }
  5276. });
  5277. const Image$1 = withInstall(stdin_default$17);
  5278. const [name$10, bem$$] = createNamespace("card");
  5279. const cardProps = {
  5280. tag: String,
  5281. num: numericProp,
  5282. desc: String,
  5283. thumb: String,
  5284. title: String,
  5285. price: numericProp,
  5286. centered: Boolean,
  5287. lazyLoad: Boolean,
  5288. currency: makeStringProp("\xA5"),
  5289. thumbLink: String,
  5290. originPrice: numericProp
  5291. };
  5292. var stdin_default$16 = vue.defineComponent({
  5293. name: name$10,
  5294. props: cardProps,
  5295. emits: ["click-thumb"],
  5296. setup(props, {
  5297. slots,
  5298. emit
  5299. }) {
  5300. const renderTitle = () => {
  5301. if (slots.title) {
  5302. return slots.title();
  5303. }
  5304. if (props.title) {
  5305. return vue.createVNode("div", {
  5306. "class": [bem$$("title"), "van-multi-ellipsis--l2"]
  5307. }, [props.title]);
  5308. }
  5309. };
  5310. const renderThumbTag = () => {
  5311. if (slots.tag || props.tag) {
  5312. return vue.createVNode("div", {
  5313. "class": bem$$("tag")
  5314. }, [slots.tag ? slots.tag() : vue.createVNode(Tag, {
  5315. "mark": true,
  5316. "type": "danger"
  5317. }, {
  5318. default: () => [props.tag]
  5319. })]);
  5320. }
  5321. };
  5322. const renderThumbImage = () => {
  5323. if (slots.thumb) {
  5324. return slots.thumb();
  5325. }
  5326. return vue.createVNode(Image$1, {
  5327. "src": props.thumb,
  5328. "fit": "cover",
  5329. "width": "100%",
  5330. "height": "100%",
  5331. "lazyLoad": props.lazyLoad
  5332. }, null);
  5333. };
  5334. const renderThumb = () => {
  5335. if (slots.thumb || props.thumb) {
  5336. return vue.createVNode("a", {
  5337. "href": props.thumbLink,
  5338. "class": bem$$("thumb"),
  5339. "onClick": (event) => emit("click-thumb", event)
  5340. }, [renderThumbImage(), renderThumbTag()]);
  5341. }
  5342. };
  5343. const renderDesc = () => {
  5344. if (slots.desc) {
  5345. return slots.desc();
  5346. }
  5347. if (props.desc) {
  5348. return vue.createVNode("div", {
  5349. "class": [bem$$("desc"), "van-ellipsis"]
  5350. }, [props.desc]);
  5351. }
  5352. };
  5353. const renderPriceText = () => {
  5354. const priceArr = props.price.toString().split(".");
  5355. return vue.createVNode("div", null, [vue.createVNode("span", {
  5356. "class": bem$$("price-currency")
  5357. }, [props.currency]), vue.createVNode("span", {
  5358. "class": bem$$("price-integer")
  5359. }, [priceArr[0]]), vue.createTextVNode("."), vue.createVNode("span", {
  5360. "class": bem$$("price-decimal")
  5361. }, [priceArr[1]])]);
  5362. };
  5363. return () => {
  5364. var _a, _b, _c;
  5365. const showNum = slots.num || isDef(props.num);
  5366. const showPrice = slots.price || isDef(props.price);
  5367. const showOriginPrice = slots["origin-price"] || isDef(props.originPrice);
  5368. const showBottom = showNum || showPrice || showOriginPrice || slots.bottom;
  5369. const Price = showPrice && vue.createVNode("div", {
  5370. "class": bem$$("price")
  5371. }, [slots.price ? slots.price() : renderPriceText()]);
  5372. const OriginPrice = showOriginPrice && vue.createVNode("div", {
  5373. "class": bem$$("origin-price")
  5374. }, [slots["origin-price"] ? slots["origin-price"]() : `${props.currency} ${props.originPrice}`]);
  5375. const Num = showNum && vue.createVNode("div", {
  5376. "class": bem$$("num")
  5377. }, [slots.num ? slots.num() : `x${props.num}`]);
  5378. const Footer = slots.footer && vue.createVNode("div", {
  5379. "class": bem$$("footer")
  5380. }, [slots.footer()]);
  5381. const Bottom = showBottom && vue.createVNode("div", {
  5382. "class": bem$$("bottom")
  5383. }, [(_a = slots["price-top"]) == null ? void 0 : _a.call(slots), Price, OriginPrice, Num, (_b = slots.bottom) == null ? void 0 : _b.call(slots)]);
  5384. return vue.createVNode("div", {
  5385. "class": bem$$()
  5386. }, [vue.createVNode("div", {
  5387. "class": bem$$("header")
  5388. }, [renderThumb(), vue.createVNode("div", {
  5389. "class": bem$$("content", {
  5390. centered: props.centered
  5391. })
  5392. }, [vue.createVNode("div", null, [renderTitle(), renderDesc(), (_c = slots.tags) == null ? void 0 : _c.call(slots)]), Bottom])]), Footer]);
  5393. };
  5394. }
  5395. });
  5396. const Card = withInstall(stdin_default$16);
  5397. function scrollLeftTo(scroller, to, duration) {
  5398. let count = 0;
  5399. const from = scroller.scrollLeft;
  5400. const frames = duration === 0 ? 1 : Math.round(duration * 1e3 / 16);
  5401. function animate() {
  5402. scroller.scrollLeft += (to - from) / frames;
  5403. if (++count < frames) {
  5404. use.raf(animate);
  5405. }
  5406. }
  5407. animate();
  5408. }
  5409. function scrollTopTo(scroller, to, duration, callback) {
  5410. let current2 = getScrollTop(scroller);
  5411. const isDown = current2 < to;
  5412. const frames = duration === 0 ? 1 : Math.round(duration * 1e3 / 16);
  5413. const step = (to - current2) / frames;
  5414. function animate() {
  5415. current2 += step;
  5416. if (isDown && current2 > to || !isDown && current2 < to) {
  5417. current2 = to;
  5418. }
  5419. setScrollTop(scroller, current2);
  5420. if (isDown && current2 < to || !isDown && current2 > to) {
  5421. use.raf(animate);
  5422. } else if (callback) {
  5423. use.raf(callback);
  5424. }
  5425. }
  5426. animate();
  5427. }
  5428. function useVisibilityChange(target, onChange) {
  5429. if (!inBrowser || !window.IntersectionObserver) {
  5430. return;
  5431. }
  5432. const observer = new IntersectionObserver(
  5433. (entries) => {
  5434. onChange(entries[0].intersectionRatio > 0);
  5435. },
  5436. { root: document.body }
  5437. );
  5438. const observe = () => {
  5439. if (target.value) {
  5440. observer.observe(target.value);
  5441. }
  5442. };
  5443. const unobserve = () => {
  5444. if (target.value) {
  5445. observer.unobserve(target.value);
  5446. }
  5447. };
  5448. vue.onDeactivated(unobserve);
  5449. vue.onBeforeUnmount(unobserve);
  5450. use.onMountedOrActivated(observe);
  5451. }
  5452. const [name$$, bem$_] = createNamespace("sticky");
  5453. const stickyProps = {
  5454. zIndex: numericProp,
  5455. position: makeStringProp("top"),
  5456. container: Object,
  5457. offsetTop: makeNumericProp(0),
  5458. offsetBottom: makeNumericProp(0)
  5459. };
  5460. var stdin_default$15 = vue.defineComponent({
  5461. name: name$$,
  5462. props: stickyProps,
  5463. emits: ["scroll", "change"],
  5464. setup(props, {
  5465. emit,
  5466. slots
  5467. }) {
  5468. const root = vue.ref();
  5469. const scrollParent = use.useScrollParent(root);
  5470. const state = vue.reactive({
  5471. fixed: false,
  5472. width: 0,
  5473. height: 0,
  5474. transform: 0
  5475. });
  5476. const offset = vue.computed(() => unitToPx(props.position === "top" ? props.offsetTop : props.offsetBottom));
  5477. const rootStyle = vue.computed(() => {
  5478. const {
  5479. fixed,
  5480. height,
  5481. width
  5482. } = state;
  5483. if (fixed) {
  5484. return {
  5485. width: `${width}px`,
  5486. height: `${height}px`
  5487. };
  5488. }
  5489. });
  5490. const stickyStyle = vue.computed(() => {
  5491. if (!state.fixed) {
  5492. return;
  5493. }
  5494. const style = extend(getZIndexStyle(props.zIndex), {
  5495. width: `${state.width}px`,
  5496. height: `${state.height}px`,
  5497. [props.position]: `${offset.value}px`
  5498. });
  5499. if (state.transform) {
  5500. style.transform = `translate3d(0, ${state.transform}px, 0)`;
  5501. }
  5502. return style;
  5503. });
  5504. const emitScroll = (scrollTop) => emit("scroll", {
  5505. scrollTop,
  5506. isFixed: state.fixed
  5507. });
  5508. const onScroll = () => {
  5509. if (!root.value || isHidden(root)) {
  5510. return;
  5511. }
  5512. const {
  5513. container,
  5514. position
  5515. } = props;
  5516. const rootRect = use.useRect(root);
  5517. const scrollTop = getScrollTop(window);
  5518. state.width = rootRect.width;
  5519. state.height = rootRect.height;
  5520. if (position === "top") {
  5521. if (container) {
  5522. const containerRect = use.useRect(container);
  5523. const difference = containerRect.bottom - offset.value - state.height;
  5524. state.fixed = offset.value > rootRect.top && containerRect.bottom > 0;
  5525. state.transform = difference < 0 ? difference : 0;
  5526. } else {
  5527. state.fixed = offset.value > rootRect.top;
  5528. }
  5529. } else {
  5530. const {
  5531. clientHeight
  5532. } = document.documentElement;
  5533. if (container) {
  5534. const containerRect = use.useRect(container);
  5535. const difference = clientHeight - containerRect.top - offset.value - state.height;
  5536. state.fixed = clientHeight - offset.value < rootRect.bottom && clientHeight > containerRect.top;
  5537. state.transform = difference < 0 ? -difference : 0;
  5538. } else {
  5539. state.fixed = clientHeight - offset.value < rootRect.bottom;
  5540. }
  5541. }
  5542. emitScroll(scrollTop);
  5543. };
  5544. vue.watch(() => state.fixed, (value) => emit("change", value));
  5545. use.useEventListener("scroll", onScroll, {
  5546. target: scrollParent,
  5547. passive: true
  5548. });
  5549. useVisibilityChange(root, onScroll);
  5550. return () => {
  5551. var _a;
  5552. return vue.createVNode("div", {
  5553. "ref": root,
  5554. "style": rootStyle.value
  5555. }, [vue.createVNode("div", {
  5556. "class": bem$_({
  5557. fixed: state.fixed
  5558. }),
  5559. "style": stickyStyle.value
  5560. }, [(_a = slots.default) == null ? void 0 : _a.call(slots)])]);
  5561. };
  5562. }
  5563. });
  5564. const Sticky = withInstall(stdin_default$15);
  5565. const [name$_, bem$Z] = createNamespace("tab");
  5566. var stdin_default$14 = vue.defineComponent({
  5567. name: name$_,
  5568. props: {
  5569. id: String,
  5570. dot: Boolean,
  5571. type: String,
  5572. color: String,
  5573. title: String,
  5574. badge: numericProp,
  5575. shrink: Boolean,
  5576. isActive: Boolean,
  5577. disabled: Boolean,
  5578. controls: String,
  5579. scrollable: Boolean,
  5580. activeColor: String,
  5581. inactiveColor: String,
  5582. showZeroBadge: truthProp
  5583. },
  5584. setup(props, {
  5585. slots
  5586. }) {
  5587. const style = vue.computed(() => {
  5588. const style2 = {};
  5589. const {
  5590. type,
  5591. color,
  5592. disabled,
  5593. isActive,
  5594. activeColor,
  5595. inactiveColor
  5596. } = props;
  5597. const isCard = type === "card";
  5598. if (color && isCard) {
  5599. style2.borderColor = color;
  5600. if (!disabled) {
  5601. if (isActive) {
  5602. style2.backgroundColor = color;
  5603. } else {
  5604. style2.color = color;
  5605. }
  5606. }
  5607. }
  5608. const titleColor = isActive ? activeColor : inactiveColor;
  5609. if (titleColor) {
  5610. style2.color = titleColor;
  5611. }
  5612. return style2;
  5613. });
  5614. const renderText = () => {
  5615. const Text2 = vue.createVNode("span", {
  5616. "class": bem$Z("text", {
  5617. ellipsis: !props.scrollable
  5618. })
  5619. }, [slots.title ? slots.title() : props.title]);
  5620. if (props.dot || isDef(props.badge) && props.badge !== "") {
  5621. return vue.createVNode(Badge, {
  5622. "dot": props.dot,
  5623. "content": props.badge,
  5624. "showZero": props.showZeroBadge
  5625. }, {
  5626. default: () => [Text2]
  5627. });
  5628. }
  5629. return Text2;
  5630. };
  5631. return () => vue.createVNode("div", {
  5632. "id": props.id,
  5633. "role": "tab",
  5634. "class": [bem$Z([props.type, {
  5635. grow: props.scrollable && !props.shrink,
  5636. shrink: props.shrink,
  5637. active: props.isActive,
  5638. disabled: props.disabled
  5639. }])],
  5640. "style": style.value,
  5641. "tabindex": props.disabled ? void 0 : props.isActive ? 0 : -1,
  5642. "aria-selected": props.isActive,
  5643. "aria-disabled": props.disabled || void 0,
  5644. "aria-controls": props.controls
  5645. }, [renderText()]);
  5646. }
  5647. });
  5648. const [name$Z, bem$Y] = createNamespace("swipe");
  5649. const swipeProps = {
  5650. loop: truthProp,
  5651. width: numericProp,
  5652. height: numericProp,
  5653. vertical: Boolean,
  5654. autoplay: makeNumericProp(0),
  5655. duration: makeNumericProp(500),
  5656. touchable: truthProp,
  5657. lazyRender: Boolean,
  5658. initialSwipe: makeNumericProp(0),
  5659. indicatorColor: String,
  5660. showIndicators: truthProp,
  5661. stopPropagation: truthProp
  5662. };
  5663. const SWIPE_KEY = Symbol(name$Z);
  5664. var stdin_default$13 = vue.defineComponent({
  5665. name: name$Z,
  5666. props: swipeProps,
  5667. emits: ["change"],
  5668. setup(props, {
  5669. emit,
  5670. slots
  5671. }) {
  5672. const root = vue.ref();
  5673. const track = vue.ref();
  5674. const state = vue.reactive({
  5675. rect: null,
  5676. width: 0,
  5677. height: 0,
  5678. offset: 0,
  5679. active: 0,
  5680. swiping: false
  5681. });
  5682. const touch = useTouch();
  5683. const {
  5684. children,
  5685. linkChildren
  5686. } = use.useChildren(SWIPE_KEY);
  5687. const count = vue.computed(() => children.length);
  5688. const size = vue.computed(() => state[props.vertical ? "height" : "width"]);
  5689. const delta = vue.computed(() => props.vertical ? touch.deltaY.value : touch.deltaX.value);
  5690. const minOffset = vue.computed(() => {
  5691. if (state.rect) {
  5692. const base = props.vertical ? state.rect.height : state.rect.width;
  5693. return base - size.value * count.value;
  5694. }
  5695. return 0;
  5696. });
  5697. const maxCount = vue.computed(() => Math.ceil(Math.abs(minOffset.value) / size.value));
  5698. const trackSize = vue.computed(() => count.value * size.value);
  5699. const activeIndicator = vue.computed(() => (state.active + count.value) % count.value);
  5700. const isCorrectDirection = vue.computed(() => {
  5701. const expect = props.vertical ? "vertical" : "horizontal";
  5702. return touch.direction.value === expect;
  5703. });
  5704. const trackStyle = vue.computed(() => {
  5705. const style = {
  5706. transitionDuration: `${state.swiping ? 0 : props.duration}ms`,
  5707. transform: `translate${props.vertical ? "Y" : "X"}(${state.offset}px)`
  5708. };
  5709. if (size.value) {
  5710. const mainAxis = props.vertical ? "height" : "width";
  5711. const crossAxis = props.vertical ? "width" : "height";
  5712. style[mainAxis] = `${trackSize.value}px`;
  5713. style[crossAxis] = props[crossAxis] ? `${props[crossAxis]}px` : "";
  5714. }
  5715. return style;
  5716. });
  5717. const getTargetActive = (pace) => {
  5718. const {
  5719. active
  5720. } = state;
  5721. if (pace) {
  5722. if (props.loop) {
  5723. return clamp(active + pace, -1, count.value);
  5724. }
  5725. return clamp(active + pace, 0, maxCount.value);
  5726. }
  5727. return active;
  5728. };
  5729. const getTargetOffset = (targetActive, offset = 0) => {
  5730. let currentPosition = targetActive * size.value;
  5731. if (!props.loop) {
  5732. currentPosition = Math.min(currentPosition, -minOffset.value);
  5733. }
  5734. let targetOffset = offset - currentPosition;
  5735. if (!props.loop) {
  5736. targetOffset = clamp(targetOffset, minOffset.value, 0);
  5737. }
  5738. return targetOffset;
  5739. };
  5740. const move = ({
  5741. pace = 0,
  5742. offset = 0,
  5743. emitChange
  5744. }) => {
  5745. if (count.value <= 1) {
  5746. return;
  5747. }
  5748. const {
  5749. active
  5750. } = state;
  5751. const targetActive = getTargetActive(pace);
  5752. const targetOffset = getTargetOffset(targetActive, offset);
  5753. if (props.loop) {
  5754. if (children[0] && targetOffset !== minOffset.value) {
  5755. const outRightBound = targetOffset < minOffset.value;
  5756. children[0].setOffset(outRightBound ? trackSize.value : 0);
  5757. }
  5758. if (children[count.value - 1] && targetOffset !== 0) {
  5759. const outLeftBound = targetOffset > 0;
  5760. children[count.value - 1].setOffset(outLeftBound ? -trackSize.value : 0);
  5761. }
  5762. }
  5763. state.active = targetActive;
  5764. state.offset = targetOffset;
  5765. if (emitChange && targetActive !== active) {
  5766. emit("change", activeIndicator.value);
  5767. }
  5768. };
  5769. const correctPosition = () => {
  5770. state.swiping = true;
  5771. if (state.active <= -1) {
  5772. move({
  5773. pace: count.value
  5774. });
  5775. } else if (state.active >= count.value) {
  5776. move({
  5777. pace: -count.value
  5778. });
  5779. }
  5780. };
  5781. const prev = () => {
  5782. correctPosition();
  5783. touch.reset();
  5784. use.doubleRaf(() => {
  5785. state.swiping = false;
  5786. move({
  5787. pace: -1,
  5788. emitChange: true
  5789. });
  5790. });
  5791. };
  5792. const next = () => {
  5793. correctPosition();
  5794. touch.reset();
  5795. use.doubleRaf(() => {
  5796. state.swiping = false;
  5797. move({
  5798. pace: 1,
  5799. emitChange: true
  5800. });
  5801. });
  5802. };
  5803. let autoplayTimer;
  5804. const stopAutoplay = () => clearTimeout(autoplayTimer);
  5805. const autoplay = () => {
  5806. stopAutoplay();
  5807. if (props.autoplay > 0 && count.value > 1) {
  5808. autoplayTimer = setTimeout(() => {
  5809. next();
  5810. autoplay();
  5811. }, +props.autoplay);
  5812. }
  5813. };
  5814. const initialize = (active = +props.initialSwipe) => {
  5815. if (!root.value) {
  5816. return;
  5817. }
  5818. const cb = () => {
  5819. var _a, _b;
  5820. if (!isHidden(root)) {
  5821. const rect = {
  5822. width: root.value.offsetWidth,
  5823. height: root.value.offsetHeight
  5824. };
  5825. state.rect = rect;
  5826. state.width = +((_a = props.width) != null ? _a : rect.width);
  5827. state.height = +((_b = props.height) != null ? _b : rect.height);
  5828. }
  5829. if (count.value) {
  5830. active = Math.min(count.value - 1, active);
  5831. }
  5832. state.active = active;
  5833. state.swiping = true;
  5834. state.offset = getTargetOffset(active);
  5835. children.forEach((swipe) => {
  5836. swipe.setOffset(0);
  5837. });
  5838. autoplay();
  5839. };
  5840. if (isHidden(root)) {
  5841. vue.nextTick().then(cb);
  5842. } else {
  5843. cb();
  5844. }
  5845. };
  5846. const resize = () => initialize(state.active);
  5847. let touchStartTime;
  5848. const onTouchStart = (event) => {
  5849. if (!props.touchable)
  5850. return;
  5851. touch.start(event);
  5852. touchStartTime = Date.now();
  5853. stopAutoplay();
  5854. correctPosition();
  5855. };
  5856. const onTouchMove = (event) => {
  5857. if (props.touchable && state.swiping) {
  5858. touch.move(event);
  5859. if (isCorrectDirection.value) {
  5860. const isEdgeTouch = !props.loop && (state.active === 0 && delta.value > 0 || state.active === count.value - 1 && delta.value < 0);
  5861. if (!isEdgeTouch) {
  5862. preventDefault(event, props.stopPropagation);
  5863. move({
  5864. offset: delta.value
  5865. });
  5866. }
  5867. }
  5868. }
  5869. };
  5870. const onTouchEnd = () => {
  5871. if (!props.touchable || !state.swiping) {
  5872. return;
  5873. }
  5874. const duration = Date.now() - touchStartTime;
  5875. const speed = delta.value / duration;
  5876. const shouldSwipe = Math.abs(speed) > 0.25 || Math.abs(delta.value) > size.value / 2;
  5877. if (shouldSwipe && isCorrectDirection.value) {
  5878. const offset = props.vertical ? touch.offsetY.value : touch.offsetX.value;
  5879. let pace = 0;
  5880. if (props.loop) {
  5881. pace = offset > 0 ? delta.value > 0 ? -1 : 1 : 0;
  5882. } else {
  5883. pace = -Math[delta.value > 0 ? "ceil" : "floor"](delta.value / size.value);
  5884. }
  5885. move({
  5886. pace,
  5887. emitChange: true
  5888. });
  5889. } else if (delta.value) {
  5890. move({
  5891. pace: 0
  5892. });
  5893. }
  5894. state.swiping = false;
  5895. autoplay();
  5896. };
  5897. const swipeTo = (index, options = {}) => {
  5898. correctPosition();
  5899. touch.reset();
  5900. use.doubleRaf(() => {
  5901. let targetIndex;
  5902. if (props.loop && index === count.value) {
  5903. targetIndex = state.active === 0 ? 0 : index;
  5904. } else {
  5905. targetIndex = index % count.value;
  5906. }
  5907. if (options.immediate) {
  5908. use.doubleRaf(() => {
  5909. state.swiping = false;
  5910. });
  5911. } else {
  5912. state.swiping = false;
  5913. }
  5914. move({
  5915. pace: targetIndex - state.active,
  5916. emitChange: true
  5917. });
  5918. });
  5919. };
  5920. const renderDot = (_, index) => {
  5921. const active = index === activeIndicator.value;
  5922. const style = active ? {
  5923. backgroundColor: props.indicatorColor
  5924. } : void 0;
  5925. return vue.createVNode("i", {
  5926. "style": style,
  5927. "class": bem$Y("indicator", {
  5928. active
  5929. })
  5930. }, null);
  5931. };
  5932. const renderIndicator = () => {
  5933. if (slots.indicator) {
  5934. return slots.indicator({
  5935. active: activeIndicator.value,
  5936. total: count.value
  5937. });
  5938. }
  5939. if (props.showIndicators && count.value > 1) {
  5940. return vue.createVNode("div", {
  5941. "class": bem$Y("indicators", {
  5942. vertical: props.vertical
  5943. })
  5944. }, [Array(count.value).fill("").map(renderDot)]);
  5945. }
  5946. };
  5947. useExpose({
  5948. prev,
  5949. next,
  5950. state,
  5951. resize,
  5952. swipeTo
  5953. });
  5954. linkChildren({
  5955. size,
  5956. props,
  5957. count,
  5958. activeIndicator
  5959. });
  5960. vue.watch(() => props.initialSwipe, (value) => initialize(+value));
  5961. vue.watch(count, () => initialize(state.active));
  5962. vue.watch(() => props.autoplay, autoplay);
  5963. vue.watch([windowWidth, windowHeight], resize);
  5964. vue.watch(use.usePageVisibility(), (visible) => {
  5965. if (visible === "visible") {
  5966. autoplay();
  5967. } else {
  5968. stopAutoplay();
  5969. }
  5970. });
  5971. vue.onMounted(initialize);
  5972. vue.onActivated(() => initialize(state.active));
  5973. onPopupReopen(() => initialize(state.active));
  5974. vue.onDeactivated(stopAutoplay);
  5975. vue.onBeforeUnmount(stopAutoplay);
  5976. use.useEventListener("touchmove", onTouchMove, {
  5977. target: track
  5978. });
  5979. return () => {
  5980. var _a;
  5981. return vue.createVNode("div", {
  5982. "ref": root,
  5983. "class": bem$Y()
  5984. }, [vue.createVNode("div", {
  5985. "ref": track,
  5986. "style": trackStyle.value,
  5987. "class": bem$Y("track", {
  5988. vertical: props.vertical
  5989. }),
  5990. "onTouchstartPassive": onTouchStart,
  5991. "onTouchend": onTouchEnd,
  5992. "onTouchcancel": onTouchEnd
  5993. }, [(_a = slots.default) == null ? void 0 : _a.call(slots)]), renderIndicator()]);
  5994. };
  5995. }
  5996. });
  5997. const Swipe = withInstall(stdin_default$13);
  5998. const [name$Y, bem$X] = createNamespace("tabs");
  5999. var stdin_default$12 = vue.defineComponent({
  6000. name: name$Y,
  6001. props: {
  6002. count: makeRequiredProp(Number),
  6003. inited: Boolean,
  6004. animated: Boolean,
  6005. duration: makeRequiredProp(numericProp),
  6006. swipeable: Boolean,
  6007. lazyRender: Boolean,
  6008. currentIndex: makeRequiredProp(Number)
  6009. },
  6010. emits: ["change"],
  6011. setup(props, {
  6012. emit,
  6013. slots
  6014. }) {
  6015. const swipeRef = vue.ref();
  6016. const onChange = (index) => emit("change", index);
  6017. const renderChildren = () => {
  6018. var _a;
  6019. const Content = (_a = slots.default) == null ? void 0 : _a.call(slots);
  6020. if (props.animated || props.swipeable) {
  6021. return vue.createVNode(Swipe, {
  6022. "ref": swipeRef,
  6023. "loop": false,
  6024. "class": bem$X("track"),
  6025. "duration": +props.duration * 1e3,
  6026. "touchable": props.swipeable,
  6027. "lazyRender": props.lazyRender,
  6028. "showIndicators": false,
  6029. "onChange": onChange
  6030. }, {
  6031. default: () => [Content]
  6032. });
  6033. }
  6034. return Content;
  6035. };
  6036. const swipeToCurrentTab = (index) => {
  6037. const swipe = swipeRef.value;
  6038. if (swipe && swipe.state.active !== index) {
  6039. swipe.swipeTo(index, {
  6040. immediate: !props.inited
  6041. });
  6042. }
  6043. };
  6044. vue.watch(() => props.currentIndex, swipeToCurrentTab);
  6045. vue.onMounted(() => {
  6046. swipeToCurrentTab(props.currentIndex);
  6047. });
  6048. useExpose({
  6049. swipeRef
  6050. });
  6051. return () => vue.createVNode("div", {
  6052. "class": bem$X("content", {
  6053. animated: props.animated || props.swipeable
  6054. })
  6055. }, [renderChildren()]);
  6056. }
  6057. });
  6058. const [name$X, bem$W] = createNamespace("tabs");
  6059. const tabsProps = {
  6060. type: makeStringProp("line"),
  6061. color: String,
  6062. border: Boolean,
  6063. sticky: Boolean,
  6064. shrink: Boolean,
  6065. active: makeNumericProp(0),
  6066. duration: makeNumericProp(0.3),
  6067. animated: Boolean,
  6068. ellipsis: truthProp,
  6069. swipeable: Boolean,
  6070. scrollspy: Boolean,
  6071. offsetTop: makeNumericProp(0),
  6072. background: String,
  6073. lazyRender: truthProp,
  6074. lineWidth: numericProp,
  6075. lineHeight: numericProp,
  6076. beforeChange: Function,
  6077. swipeThreshold: makeNumericProp(5),
  6078. titleActiveColor: String,
  6079. titleInactiveColor: String
  6080. };
  6081. const TABS_KEY = Symbol(name$X);
  6082. var stdin_default$11 = vue.defineComponent({
  6083. name: name$X,
  6084. props: tabsProps,
  6085. emits: ["click", "change", "scroll", "disabled", "rendered", "click-tab", "update:active"],
  6086. setup(props, {
  6087. emit,
  6088. slots
  6089. }) {
  6090. var _a, _b;
  6091. if (process.env.NODE_ENV !== "production") {
  6092. const props2 = (_b = (_a = vue.getCurrentInstance()) == null ? void 0 : _a.vnode) == null ? void 0 : _b.props;
  6093. if (props2 && "onClick" in props2) {
  6094. console.warn('[Vant] Tabs: "click" event is deprecated, using "click-tab" instead.');
  6095. }
  6096. if (props2 && "onDisabled" in props2) {
  6097. console.warn('[Vant] Tabs: "disabled" event is deprecated, using "click-tab" instead.');
  6098. }
  6099. }
  6100. let tabHeight;
  6101. let lockScroll;
  6102. let stickyFixed;
  6103. const root = vue.ref();
  6104. const navRef = vue.ref();
  6105. const wrapRef = vue.ref();
  6106. const contentRef = vue.ref();
  6107. const id = useId();
  6108. const scroller = use.useScrollParent(root);
  6109. const [titleRefs, setTitleRefs] = useRefs();
  6110. const {
  6111. children,
  6112. linkChildren
  6113. } = use.useChildren(TABS_KEY);
  6114. const state = vue.reactive({
  6115. inited: false,
  6116. position: "",
  6117. lineStyle: {},
  6118. currentIndex: -1
  6119. });
  6120. const scrollable = vue.computed(() => children.length > props.swipeThreshold || !props.ellipsis || props.shrink);
  6121. const navStyle = vue.computed(() => ({
  6122. borderColor: props.color,
  6123. background: props.background
  6124. }));
  6125. const getTabName = (tab, index) => {
  6126. var _a2;
  6127. return (_a2 = tab.name) != null ? _a2 : index;
  6128. };
  6129. const currentName = vue.computed(() => {
  6130. const activeTab = children[state.currentIndex];
  6131. if (activeTab) {
  6132. return getTabName(activeTab, state.currentIndex);
  6133. }
  6134. });
  6135. const offsetTopPx = vue.computed(() => unitToPx(props.offsetTop));
  6136. const scrollOffset = vue.computed(() => {
  6137. if (props.sticky) {
  6138. return offsetTopPx.value + tabHeight;
  6139. }
  6140. return 0;
  6141. });
  6142. const scrollIntoView = (immediate) => {
  6143. const nav = navRef.value;
  6144. const titles = titleRefs.value;
  6145. if (!scrollable.value || !nav || !titles || !titles[state.currentIndex]) {
  6146. return;
  6147. }
  6148. const title = titles[state.currentIndex].$el;
  6149. const to = title.offsetLeft - (nav.offsetWidth - title.offsetWidth) / 2;
  6150. scrollLeftTo(nav, to, immediate ? 0 : +props.duration);
  6151. };
  6152. const setLine = () => {
  6153. const shouldAnimate = state.inited;
  6154. vue.nextTick(() => {
  6155. const titles = titleRefs.value;
  6156. if (!titles || !titles[state.currentIndex] || props.type !== "line" || isHidden(root.value)) {
  6157. return;
  6158. }
  6159. const title = titles[state.currentIndex].$el;
  6160. const {
  6161. lineWidth,
  6162. lineHeight
  6163. } = props;
  6164. const left = title.offsetLeft + title.offsetWidth / 2;
  6165. const lineStyle = {
  6166. width: addUnit(lineWidth),
  6167. backgroundColor: props.color,
  6168. transform: `translateX(${left}px) translateX(-50%)`
  6169. };
  6170. if (shouldAnimate) {
  6171. lineStyle.transitionDuration = `${props.duration}s`;
  6172. }
  6173. if (isDef(lineHeight)) {
  6174. const height = addUnit(lineHeight);
  6175. lineStyle.height = height;
  6176. lineStyle.borderRadius = height;
  6177. }
  6178. state.lineStyle = lineStyle;
  6179. });
  6180. };
  6181. const findAvailableTab = (index) => {
  6182. const diff = index < state.currentIndex ? -1 : 1;
  6183. while (index >= 0 && index < children.length) {
  6184. if (!children[index].disabled) {
  6185. return index;
  6186. }
  6187. index += diff;
  6188. }
  6189. };
  6190. const setCurrentIndex = (currentIndex, skipScrollIntoView) => {
  6191. const newIndex = findAvailableTab(currentIndex);
  6192. if (!isDef(newIndex)) {
  6193. return;
  6194. }
  6195. const newTab = children[newIndex];
  6196. const newName = getTabName(newTab, newIndex);
  6197. const shouldEmitChange = state.currentIndex !== null;
  6198. if (state.currentIndex !== newIndex) {
  6199. state.currentIndex = newIndex;
  6200. if (!skipScrollIntoView) {
  6201. scrollIntoView();
  6202. }
  6203. setLine();
  6204. }
  6205. if (newName !== props.active) {
  6206. emit("update:active", newName);
  6207. if (shouldEmitChange) {
  6208. emit("change", newName, newTab.title);
  6209. }
  6210. }
  6211. if (stickyFixed && !props.scrollspy) {
  6212. setRootScrollTop(Math.ceil(getElementTop(root.value) - offsetTopPx.value));
  6213. }
  6214. };
  6215. const setCurrentIndexByName = (name2, skipScrollIntoView) => {
  6216. const matched = children.find((tab, index2) => getTabName(tab, index2) === name2);
  6217. const index = matched ? children.indexOf(matched) : 0;
  6218. setCurrentIndex(index, skipScrollIntoView);
  6219. };
  6220. const scrollToCurrentContent = (immediate = false) => {
  6221. if (props.scrollspy) {
  6222. const target = children[state.currentIndex].$el;
  6223. if (target && scroller.value) {
  6224. const to = getElementTop(target, scroller.value) - scrollOffset.value;
  6225. lockScroll = true;
  6226. scrollTopTo(scroller.value, to, immediate ? 0 : +props.duration, () => {
  6227. lockScroll = false;
  6228. });
  6229. }
  6230. }
  6231. };
  6232. const onClickTab = (item, index, event) => {
  6233. const {
  6234. title,
  6235. disabled
  6236. } = children[index];
  6237. const name2 = getTabName(children[index], index);
  6238. if (disabled) {
  6239. emit("disabled", name2, title);
  6240. } else {
  6241. callInterceptor(props.beforeChange, {
  6242. args: [name2],
  6243. done: () => {
  6244. setCurrentIndex(index);
  6245. scrollToCurrentContent();
  6246. }
  6247. });
  6248. emit("click", name2, title);
  6249. route(item);
  6250. }
  6251. emit("click-tab", {
  6252. name: name2,
  6253. title,
  6254. event,
  6255. disabled
  6256. });
  6257. };
  6258. const onStickyScroll = (params) => {
  6259. stickyFixed = params.isFixed;
  6260. emit("scroll", params);
  6261. };
  6262. const scrollTo = (name2) => {
  6263. vue.nextTick(() => {
  6264. setCurrentIndexByName(name2);
  6265. scrollToCurrentContent(true);
  6266. });
  6267. };
  6268. const getCurrentIndexOnScroll = () => {
  6269. for (let index = 0; index < children.length; index++) {
  6270. const {
  6271. top
  6272. } = use.useRect(children[index].$el);
  6273. if (top > scrollOffset.value) {
  6274. return index === 0 ? 0 : index - 1;
  6275. }
  6276. }
  6277. return children.length - 1;
  6278. };
  6279. const onScroll = () => {
  6280. if (props.scrollspy && !lockScroll) {
  6281. const index = getCurrentIndexOnScroll();
  6282. setCurrentIndex(index);
  6283. }
  6284. };
  6285. const renderNav = () => children.map((item, index) => vue.createVNode(stdin_default$14, vue.mergeProps({
  6286. "key": item.id,
  6287. "id": `${id}-${index}`,
  6288. "ref": setTitleRefs(index),
  6289. "type": props.type,
  6290. "color": props.color,
  6291. "style": item.titleStyle,
  6292. "class": item.titleClass,
  6293. "shrink": props.shrink,
  6294. "isActive": index === state.currentIndex,
  6295. "controls": item.id,
  6296. "scrollable": scrollable.value,
  6297. "activeColor": props.titleActiveColor,
  6298. "inactiveColor": props.titleInactiveColor,
  6299. "onClick": (event) => onClickTab(item, index, event)
  6300. }, pick(item, ["dot", "badge", "title", "disabled", "showZeroBadge"])), {
  6301. title: item.$slots.title
  6302. }));
  6303. const renderLine = () => {
  6304. if (props.type === "line" && children.length) {
  6305. return vue.createVNode("div", {
  6306. "class": bem$W("line"),
  6307. "style": state.lineStyle
  6308. }, null);
  6309. }
  6310. };
  6311. const renderHeader = () => {
  6312. var _a2, _b2, _c;
  6313. const {
  6314. type,
  6315. border,
  6316. sticky
  6317. } = props;
  6318. const Header = [vue.createVNode("div", {
  6319. "ref": sticky ? void 0 : wrapRef,
  6320. "class": [bem$W("wrap"), {
  6321. [BORDER_TOP_BOTTOM]: type === "line" && border
  6322. }]
  6323. }, [vue.createVNode("div", {
  6324. "ref": navRef,
  6325. "role": "tablist",
  6326. "class": bem$W("nav", [type, {
  6327. shrink: props.shrink,
  6328. complete: scrollable.value
  6329. }]),
  6330. "style": navStyle.value,
  6331. "aria-orientation": "horizontal"
  6332. }, [(_a2 = slots["nav-left"]) == null ? void 0 : _a2.call(slots), renderNav(), renderLine(), (_b2 = slots["nav-right"]) == null ? void 0 : _b2.call(slots)])]), (_c = slots["nav-bottom"]) == null ? void 0 : _c.call(slots)];
  6333. if (sticky) {
  6334. return vue.createVNode("div", {
  6335. "ref": wrapRef
  6336. }, [Header]);
  6337. }
  6338. return Header;
  6339. };
  6340. vue.watch([() => props.color, windowWidth], setLine);
  6341. vue.watch(() => props.active, (value) => {
  6342. if (value !== currentName.value) {
  6343. setCurrentIndexByName(value);
  6344. }
  6345. });
  6346. vue.watch(() => children.length, () => {
  6347. if (state.inited) {
  6348. setCurrentIndexByName(props.active);
  6349. setLine();
  6350. vue.nextTick(() => {
  6351. scrollIntoView(true);
  6352. });
  6353. }
  6354. });
  6355. const init = () => {
  6356. setCurrentIndexByName(props.active, true);
  6357. vue.nextTick(() => {
  6358. state.inited = true;
  6359. if (wrapRef.value) {
  6360. tabHeight = use.useRect(wrapRef.value).height;
  6361. }
  6362. scrollIntoView(true);
  6363. });
  6364. };
  6365. const onRendered = (name2, title) => emit("rendered", name2, title);
  6366. const resize = () => {
  6367. setLine();
  6368. vue.nextTick(() => {
  6369. var _a2, _b2;
  6370. return (_b2 = (_a2 = contentRef.value) == null ? void 0 : _a2.swipeRef.value) == null ? void 0 : _b2.resize();
  6371. });
  6372. };
  6373. useExpose({
  6374. resize,
  6375. scrollTo
  6376. });
  6377. vue.onActivated(setLine);
  6378. onPopupReopen(setLine);
  6379. use.onMountedOrActivated(init);
  6380. use.useEventListener("scroll", onScroll, {
  6381. target: scroller,
  6382. passive: true
  6383. });
  6384. linkChildren({
  6385. id,
  6386. props,
  6387. setLine,
  6388. onRendered,
  6389. currentName,
  6390. scrollIntoView
  6391. });
  6392. return () => vue.createVNode("div", {
  6393. "ref": root,
  6394. "class": bem$W([props.type])
  6395. }, [props.sticky ? vue.createVNode(Sticky, {
  6396. "container": root.value,
  6397. "offsetTop": offsetTopPx.value,
  6398. "onScroll": onStickyScroll
  6399. }, {
  6400. default: () => [renderHeader()]
  6401. }) : renderHeader(), vue.createVNode(stdin_default$12, {
  6402. "ref": contentRef,
  6403. "count": children.length,
  6404. "inited": state.inited,
  6405. "animated": props.animated,
  6406. "duration": props.duration,
  6407. "swipeable": props.swipeable,
  6408. "lazyRender": props.lazyRender,
  6409. "currentIndex": state.currentIndex,
  6410. "onChange": setCurrentIndex
  6411. }, {
  6412. default: () => {
  6413. var _a2;
  6414. return [(_a2 = slots.default) == null ? void 0 : _a2.call(slots)];
  6415. }
  6416. })]);
  6417. }
  6418. });
  6419. const TAB_STATUS_KEY = Symbol();
  6420. const useTabStatus = () => vue.inject(TAB_STATUS_KEY, null);
  6421. const [name$W, bem$V] = createNamespace("swipe-item");
  6422. var stdin_default$10 = vue.defineComponent({
  6423. name: name$W,
  6424. setup(props, {
  6425. slots
  6426. }) {
  6427. let rendered;
  6428. const state = vue.reactive({
  6429. offset: 0,
  6430. inited: false,
  6431. mounted: false
  6432. });
  6433. const {
  6434. parent,
  6435. index
  6436. } = use.useParent(SWIPE_KEY);
  6437. if (!parent) {
  6438. if (process.env.NODE_ENV !== "production") {
  6439. console.error("[Vant] <SwipeItem> must be a child component of <Swipe>.");
  6440. }
  6441. return;
  6442. }
  6443. const style = vue.computed(() => {
  6444. const style2 = {};
  6445. const {
  6446. vertical
  6447. } = parent.props;
  6448. if (parent.size.value) {
  6449. style2[vertical ? "height" : "width"] = `${parent.size.value}px`;
  6450. }
  6451. if (state.offset) {
  6452. style2.transform = `translate${vertical ? "Y" : "X"}(${state.offset}px)`;
  6453. }
  6454. return style2;
  6455. });
  6456. const shouldRender = vue.computed(() => {
  6457. const {
  6458. loop,
  6459. lazyRender
  6460. } = parent.props;
  6461. if (!lazyRender || rendered) {
  6462. return true;
  6463. }
  6464. if (!state.mounted) {
  6465. return false;
  6466. }
  6467. const active = parent.activeIndicator.value;
  6468. const maxActive = parent.count.value - 1;
  6469. const prevActive = active === 0 && loop ? maxActive : active - 1;
  6470. const nextActive = active === maxActive && loop ? 0 : active + 1;
  6471. rendered = index.value === active || index.value === prevActive || index.value === nextActive;
  6472. return rendered;
  6473. });
  6474. const setOffset = (offset) => {
  6475. state.offset = offset;
  6476. };
  6477. vue.onMounted(() => {
  6478. vue.nextTick(() => {
  6479. state.mounted = true;
  6480. });
  6481. });
  6482. useExpose({
  6483. setOffset
  6484. });
  6485. return () => {
  6486. var _a;
  6487. return vue.createVNode("div", {
  6488. "class": bem$V(),
  6489. "style": style.value
  6490. }, [shouldRender.value ? (_a = slots.default) == null ? void 0 : _a.call(slots) : null]);
  6491. };
  6492. }
  6493. });
  6494. const SwipeItem = withInstall(stdin_default$10);
  6495. const [name$V, bem$U] = createNamespace("tab");
  6496. const tabProps = extend({}, routeProps, {
  6497. dot: Boolean,
  6498. name: numericProp,
  6499. badge: numericProp,
  6500. title: String,
  6501. disabled: Boolean,
  6502. titleClass: unknownProp,
  6503. titleStyle: [String, Object],
  6504. showZeroBadge: truthProp
  6505. });
  6506. var stdin_default$$ = vue.defineComponent({
  6507. name: name$V,
  6508. props: tabProps,
  6509. setup(props, {
  6510. slots
  6511. }) {
  6512. const id = useId();
  6513. const inited = vue.ref(false);
  6514. const {
  6515. parent,
  6516. index
  6517. } = use.useParent(TABS_KEY);
  6518. if (!parent) {
  6519. if (process.env.NODE_ENV !== "production") {
  6520. console.error("[Vant] <Tab> must be a child component of <Tabs>.");
  6521. }
  6522. return;
  6523. }
  6524. const getName = () => {
  6525. var _a;
  6526. return (_a = props.name) != null ? _a : index.value;
  6527. };
  6528. const init = () => {
  6529. inited.value = true;
  6530. if (parent.props.lazyRender) {
  6531. vue.nextTick(() => {
  6532. parent.onRendered(getName(), props.title);
  6533. });
  6534. }
  6535. };
  6536. const active = vue.computed(() => {
  6537. const isActive = getName() === parent.currentName.value;
  6538. if (isActive && !inited.value) {
  6539. init();
  6540. }
  6541. return isActive;
  6542. });
  6543. const hasInactiveClass = vue.ref(!active.value);
  6544. vue.watch(active, (val) => {
  6545. if (val) {
  6546. hasInactiveClass.value = false;
  6547. } else {
  6548. use.doubleRaf(() => {
  6549. hasInactiveClass.value = true;
  6550. });
  6551. }
  6552. });
  6553. vue.watch(() => props.title, () => {
  6554. parent.setLine();
  6555. parent.scrollIntoView();
  6556. });
  6557. vue.provide(TAB_STATUS_KEY, active);
  6558. return () => {
  6559. var _a;
  6560. const label = `${parent.id}-${index.value}`;
  6561. const {
  6562. animated,
  6563. swipeable,
  6564. scrollspy,
  6565. lazyRender
  6566. } = parent.props;
  6567. if (!slots.default && !animated) {
  6568. return;
  6569. }
  6570. const show = scrollspy || active.value;
  6571. if (animated || swipeable) {
  6572. return vue.createVNode(SwipeItem, {
  6573. "id": id,
  6574. "role": "tabpanel",
  6575. "class": bem$U("panel-wrapper", {
  6576. inactive: hasInactiveClass.value
  6577. }),
  6578. "tabindex": active.value ? 0 : -1,
  6579. "aria-hidden": !active.value,
  6580. "aria-labelledby": label
  6581. }, {
  6582. default: () => {
  6583. var _a2;
  6584. return [vue.createVNode("div", {
  6585. "class": bem$U("panel")
  6586. }, [(_a2 = slots.default) == null ? void 0 : _a2.call(slots)])];
  6587. }
  6588. });
  6589. }
  6590. const shouldRender = inited.value || scrollspy || !lazyRender;
  6591. const Content = shouldRender ? (_a = slots.default) == null ? void 0 : _a.call(slots) : null;
  6592. useExpose({
  6593. id
  6594. });
  6595. return vue.withDirectives(vue.createVNode("div", {
  6596. "id": id,
  6597. "role": "tabpanel",
  6598. "class": bem$U("panel"),
  6599. "tabindex": show ? 0 : -1,
  6600. "aria-labelledby": label
  6601. }, [Content]), [[vue.vShow, show]]);
  6602. };
  6603. }
  6604. });
  6605. const Tab = withInstall(stdin_default$$);
  6606. const Tabs = withInstall(stdin_default$11);
  6607. const [name$U, bem$T, t$e] = createNamespace("cascader");
  6608. const cascaderProps = {
  6609. title: String,
  6610. options: makeArrayProp(),
  6611. closeable: truthProp,
  6612. swipeable: truthProp,
  6613. closeIcon: makeStringProp("cross"),
  6614. showHeader: truthProp,
  6615. modelValue: numericProp,
  6616. fieldNames: Object,
  6617. placeholder: String,
  6618. activeColor: String
  6619. };
  6620. var stdin_default$_ = vue.defineComponent({
  6621. name: name$U,
  6622. props: cascaderProps,
  6623. emits: ["close", "change", "finish", "click-tab", "update:modelValue"],
  6624. setup(props, {
  6625. slots,
  6626. emit
  6627. }) {
  6628. const tabs = vue.ref([]);
  6629. const activeTab = vue.ref(0);
  6630. const {
  6631. text: textKey,
  6632. value: valueKey,
  6633. children: childrenKey
  6634. } = extend({
  6635. text: "text",
  6636. value: "value",
  6637. children: "children"
  6638. }, props.fieldNames);
  6639. const getSelectedOptionsByValue = (options, value) => {
  6640. for (const option of options) {
  6641. if (option[valueKey] === value) {
  6642. return [option];
  6643. }
  6644. if (option[childrenKey]) {
  6645. const selectedOptions = getSelectedOptionsByValue(option[childrenKey], value);
  6646. if (selectedOptions) {
  6647. return [option, ...selectedOptions];
  6648. }
  6649. }
  6650. }
  6651. };
  6652. const updateTabs = () => {
  6653. const {
  6654. options,
  6655. modelValue
  6656. } = props;
  6657. if (modelValue !== void 0) {
  6658. const selectedOptions = getSelectedOptionsByValue(options, modelValue);
  6659. if (selectedOptions) {
  6660. let optionsCursor = options;
  6661. tabs.value = selectedOptions.map((option) => {
  6662. const tab = {
  6663. options: optionsCursor,
  6664. selected: option
  6665. };
  6666. const next = optionsCursor.find((item) => item[valueKey] === option[valueKey]);
  6667. if (next) {
  6668. optionsCursor = next[childrenKey];
  6669. }
  6670. return tab;
  6671. });
  6672. if (optionsCursor) {
  6673. tabs.value.push({
  6674. options: optionsCursor,
  6675. selected: null
  6676. });
  6677. }
  6678. vue.nextTick(() => {
  6679. activeTab.value = tabs.value.length - 1;
  6680. });
  6681. return;
  6682. }
  6683. }
  6684. tabs.value = [{
  6685. options,
  6686. selected: null
  6687. }];
  6688. };
  6689. const onSelect = (option, tabIndex) => {
  6690. if (option.disabled) {
  6691. return;
  6692. }
  6693. tabs.value[tabIndex].selected = option;
  6694. if (tabs.value.length > tabIndex + 1) {
  6695. tabs.value = tabs.value.slice(0, tabIndex + 1);
  6696. }
  6697. if (option[childrenKey]) {
  6698. const nextTab = {
  6699. options: option[childrenKey],
  6700. selected: null
  6701. };
  6702. if (tabs.value[tabIndex + 1]) {
  6703. tabs.value[tabIndex + 1] = nextTab;
  6704. } else {
  6705. tabs.value.push(nextTab);
  6706. }
  6707. vue.nextTick(() => {
  6708. activeTab.value++;
  6709. });
  6710. }
  6711. const selectedOptions = tabs.value.map((tab) => tab.selected).filter(Boolean);
  6712. emit("update:modelValue", option[valueKey]);
  6713. const params = {
  6714. value: option[valueKey],
  6715. tabIndex,
  6716. selectedOptions
  6717. };
  6718. emit("change", params);
  6719. if (!option[childrenKey]) {
  6720. emit("finish", params);
  6721. }
  6722. };
  6723. const onClose = () => emit("close");
  6724. const onClickTab = ({
  6725. name: name2,
  6726. title
  6727. }) => emit("click-tab", name2, title);
  6728. const renderHeader = () => props.showHeader ? vue.createVNode("div", {
  6729. "class": bem$T("header")
  6730. }, [vue.createVNode("h2", {
  6731. "class": bem$T("title")
  6732. }, [slots.title ? slots.title() : props.title]), props.closeable ? vue.createVNode(Icon, {
  6733. "name": props.closeIcon,
  6734. "class": [bem$T("close-icon"), HAPTICS_FEEDBACK],
  6735. "onClick": onClose
  6736. }, null) : null]) : null;
  6737. const renderOption = (option, selectedOption, tabIndex) => {
  6738. const {
  6739. disabled
  6740. } = option;
  6741. const selected = !!(selectedOption && option[valueKey] === selectedOption[valueKey]);
  6742. const color = option.color || (selected ? props.activeColor : void 0);
  6743. const Text2 = slots.option ? slots.option({
  6744. option,
  6745. selected
  6746. }) : vue.createVNode("span", null, [option[textKey]]);
  6747. return vue.createVNode("li", {
  6748. "role": "menuitemradio",
  6749. "class": [bem$T("option", {
  6750. selected,
  6751. disabled
  6752. }), option.className],
  6753. "style": {
  6754. color
  6755. },
  6756. "tabindex": disabled ? void 0 : selected ? 0 : -1,
  6757. "aria-checked": selected,
  6758. "aria-disabled": disabled || void 0,
  6759. "onClick": () => onSelect(option, tabIndex)
  6760. }, [Text2, selected ? vue.createVNode(Icon, {
  6761. "name": "success",
  6762. "class": bem$T("selected-icon")
  6763. }, null) : null]);
  6764. };
  6765. const renderOptions = (options, selectedOption, tabIndex) => vue.createVNode("ul", {
  6766. "role": "menu",
  6767. "class": bem$T("options")
  6768. }, [options.map((option) => renderOption(option, selectedOption, tabIndex))]);
  6769. const renderTab = (tab, tabIndex) => {
  6770. const {
  6771. options,
  6772. selected
  6773. } = tab;
  6774. const placeholder = props.placeholder || t$e("select");
  6775. const title = selected ? selected[textKey] : placeholder;
  6776. return vue.createVNode(Tab, {
  6777. "title": title,
  6778. "titleClass": bem$T("tab", {
  6779. unselected: !selected
  6780. })
  6781. }, {
  6782. default: () => {
  6783. var _a, _b;
  6784. return [(_a = slots["options-top"]) == null ? void 0 : _a.call(slots, {
  6785. tabIndex
  6786. }), renderOptions(options, selected, tabIndex), (_b = slots["options-bottom"]) == null ? void 0 : _b.call(slots, {
  6787. tabIndex
  6788. })];
  6789. }
  6790. });
  6791. };
  6792. const renderTabs = () => vue.createVNode(Tabs, {
  6793. "active": activeTab.value,
  6794. "onUpdate:active": ($event) => activeTab.value = $event,
  6795. "shrink": true,
  6796. "animated": true,
  6797. "class": bem$T("tabs"),
  6798. "color": props.activeColor,
  6799. "swipeable": props.swipeable,
  6800. "onClick-tab": onClickTab
  6801. }, {
  6802. default: () => [tabs.value.map(renderTab)]
  6803. });
  6804. updateTabs();
  6805. vue.watch(() => props.options, updateTabs, {
  6806. deep: true
  6807. });
  6808. vue.watch(() => props.modelValue, (value) => {
  6809. if (value !== void 0) {
  6810. const values = tabs.value.map((tab) => {
  6811. var _a;
  6812. return (_a = tab.selected) == null ? void 0 : _a[valueKey];
  6813. });
  6814. if (values.includes(value)) {
  6815. return;
  6816. }
  6817. }
  6818. updateTabs();
  6819. });
  6820. return () => vue.createVNode("div", {
  6821. "class": bem$T()
  6822. }, [renderHeader(), renderTabs()]);
  6823. }
  6824. });
  6825. const Cascader = withInstall(stdin_default$_);
  6826. const [name$T, bem$S] = createNamespace("cell-group");
  6827. const cellGroupProps = {
  6828. title: String,
  6829. inset: Boolean,
  6830. border: truthProp
  6831. };
  6832. var stdin_default$Z = vue.defineComponent({
  6833. name: name$T,
  6834. inheritAttrs: false,
  6835. props: cellGroupProps,
  6836. setup(props, {
  6837. slots,
  6838. attrs
  6839. }) {
  6840. const renderGroup = () => {
  6841. var _a;
  6842. return vue.createVNode("div", vue.mergeProps({
  6843. "class": [bem$S({
  6844. inset: props.inset
  6845. }), {
  6846. [BORDER_TOP_BOTTOM]: props.border && !props.inset
  6847. }]
  6848. }, attrs), [(_a = slots.default) == null ? void 0 : _a.call(slots)]);
  6849. };
  6850. const renderTitle = () => vue.createVNode("div", {
  6851. "class": bem$S("title", {
  6852. inset: props.inset
  6853. })
  6854. }, [slots.title ? slots.title() : props.title]);
  6855. return () => {
  6856. if (props.title || slots.title) {
  6857. return vue.createVNode(vue.Fragment, null, [renderTitle(), renderGroup()]);
  6858. }
  6859. return renderGroup();
  6860. };
  6861. }
  6862. });
  6863. const CellGroup = withInstall(stdin_default$Z);
  6864. const [name$S, bem$R] = createNamespace("checkbox-group");
  6865. const checkboxGroupProps = {
  6866. max: numericProp,
  6867. disabled: Boolean,
  6868. iconSize: numericProp,
  6869. direction: String,
  6870. modelValue: makeArrayProp(),
  6871. checkedColor: String
  6872. };
  6873. const CHECKBOX_GROUP_KEY = Symbol(name$S);
  6874. var stdin_default$Y = vue.defineComponent({
  6875. name: name$S,
  6876. props: checkboxGroupProps,
  6877. emits: ["change", "update:modelValue"],
  6878. setup(props, {
  6879. emit,
  6880. slots
  6881. }) {
  6882. const {
  6883. children,
  6884. linkChildren
  6885. } = use.useChildren(CHECKBOX_GROUP_KEY);
  6886. const updateValue = (value) => emit("update:modelValue", value);
  6887. const toggleAll = (options = {}) => {
  6888. if (typeof options === "boolean") {
  6889. options = {
  6890. checked: options
  6891. };
  6892. }
  6893. const {
  6894. checked,
  6895. skipDisabled
  6896. } = options;
  6897. const checkedChildren = children.filter((item) => {
  6898. if (!item.props.bindGroup) {
  6899. return false;
  6900. }
  6901. if (item.props.disabled && skipDisabled) {
  6902. return item.checked.value;
  6903. }
  6904. return checked != null ? checked : !item.checked.value;
  6905. });
  6906. const names = checkedChildren.map((item) => item.name);
  6907. updateValue(names);
  6908. };
  6909. vue.watch(() => props.modelValue, (value) => emit("change", value));
  6910. useExpose({
  6911. toggleAll
  6912. });
  6913. use.useCustomFieldValue(() => props.modelValue);
  6914. linkChildren({
  6915. props,
  6916. updateValue
  6917. });
  6918. return () => {
  6919. var _a;
  6920. return vue.createVNode("div", {
  6921. "class": bem$R([props.direction])
  6922. }, [(_a = slots.default) == null ? void 0 : _a.call(slots)]);
  6923. };
  6924. }
  6925. });
  6926. const [name$R, bem$Q] = createNamespace("checkbox");
  6927. const checkboxProps = extend({}, checkerProps, {
  6928. bindGroup: truthProp
  6929. });
  6930. var stdin_default$X = vue.defineComponent({
  6931. name: name$R,
  6932. props: checkboxProps,
  6933. emits: ["change", "update:modelValue"],
  6934. setup(props, {
  6935. emit,
  6936. slots
  6937. }) {
  6938. const {
  6939. parent
  6940. } = use.useParent(CHECKBOX_GROUP_KEY);
  6941. const setParentValue = (checked2) => {
  6942. const {
  6943. name: name2
  6944. } = props;
  6945. const {
  6946. max,
  6947. modelValue
  6948. } = parent.props;
  6949. const value = modelValue.slice();
  6950. if (checked2) {
  6951. const overlimit = max && value.length >= max;
  6952. if (!overlimit && !value.includes(name2)) {
  6953. value.push(name2);
  6954. if (props.bindGroup) {
  6955. parent.updateValue(value);
  6956. }
  6957. }
  6958. } else {
  6959. const index = value.indexOf(name2);
  6960. if (index !== -1) {
  6961. value.splice(index, 1);
  6962. if (props.bindGroup) {
  6963. parent.updateValue(value);
  6964. }
  6965. }
  6966. }
  6967. };
  6968. const checked = vue.computed(() => {
  6969. if (parent && props.bindGroup) {
  6970. return parent.props.modelValue.indexOf(props.name) !== -1;
  6971. }
  6972. return !!props.modelValue;
  6973. });
  6974. const toggle = (newValue = !checked.value) => {
  6975. if (parent && props.bindGroup) {
  6976. setParentValue(newValue);
  6977. } else {
  6978. emit("update:modelValue", newValue);
  6979. }
  6980. };
  6981. vue.watch(() => props.modelValue, (value) => emit("change", value));
  6982. useExpose({
  6983. toggle,
  6984. props,
  6985. checked
  6986. });
  6987. use.useCustomFieldValue(() => props.modelValue);
  6988. return () => vue.createVNode(stdin_default$1f, vue.mergeProps({
  6989. "bem": bem$Q,
  6990. "role": "checkbox",
  6991. "parent": parent,
  6992. "checked": checked.value,
  6993. "onToggle": toggle
  6994. }, props), pick(slots, ["default", "icon"]));
  6995. }
  6996. });
  6997. const Checkbox = withInstall(stdin_default$X);
  6998. const CheckboxGroup = withInstall(stdin_default$Y);
  6999. const [name$Q, bem$P] = createNamespace("circle");
  7000. let uid = 0;
  7001. const format = (rate) => Math.min(Math.max(+rate, 0), 100);
  7002. function getPath(clockwise, viewBoxSize) {
  7003. const sweepFlag = clockwise ? 1 : 0;
  7004. 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`;
  7005. }
  7006. const circleProps = {
  7007. text: String,
  7008. size: numericProp,
  7009. fill: makeStringProp("none"),
  7010. rate: makeNumericProp(100),
  7011. speed: makeNumericProp(0),
  7012. color: [String, Object],
  7013. clockwise: truthProp,
  7014. layerColor: String,
  7015. currentRate: makeNumberProp(0),
  7016. strokeWidth: makeNumericProp(40),
  7017. strokeLinecap: String,
  7018. startPosition: makeStringProp("top")
  7019. };
  7020. var stdin_default$W = vue.defineComponent({
  7021. name: name$Q,
  7022. props: circleProps,
  7023. emits: ["update:currentRate"],
  7024. setup(props, {
  7025. emit,
  7026. slots
  7027. }) {
  7028. const id = `van-circle-${uid++}`;
  7029. const viewBoxSize = vue.computed(() => +props.strokeWidth + 1e3);
  7030. const path = vue.computed(() => getPath(props.clockwise, viewBoxSize.value));
  7031. const svgStyle = vue.computed(() => {
  7032. const ROTATE_ANGLE_MAP = {
  7033. top: 0,
  7034. right: 90,
  7035. bottom: 180,
  7036. left: 270
  7037. };
  7038. const angleValue = ROTATE_ANGLE_MAP[props.startPosition];
  7039. if (angleValue) {
  7040. return {
  7041. transform: `rotate(${angleValue}deg)`
  7042. };
  7043. }
  7044. });
  7045. vue.watch(() => props.rate, (rate) => {
  7046. let rafId;
  7047. const startTime = Date.now();
  7048. const startRate = props.currentRate;
  7049. const endRate = format(rate);
  7050. const duration = Math.abs((startRate - endRate) * 1e3 / +props.speed);
  7051. const animate = () => {
  7052. const now = Date.now();
  7053. const progress = Math.min((now - startTime) / duration, 1);
  7054. const rate2 = progress * (endRate - startRate) + startRate;
  7055. emit("update:currentRate", format(parseFloat(rate2.toFixed(1))));
  7056. if (endRate > startRate ? rate2 < endRate : rate2 > endRate) {
  7057. rafId = use.raf(animate);
  7058. }
  7059. };
  7060. if (props.speed) {
  7061. if (rafId) {
  7062. use.cancelRaf(rafId);
  7063. }
  7064. rafId = use.raf(animate);
  7065. } else {
  7066. emit("update:currentRate", endRate);
  7067. }
  7068. }, {
  7069. immediate: true
  7070. });
  7071. const renderHover = () => {
  7072. const PERIMETER = 3140;
  7073. const {
  7074. strokeWidth,
  7075. currentRate,
  7076. strokeLinecap
  7077. } = props;
  7078. const offset = PERIMETER * currentRate / 100;
  7079. const color = isObject(props.color) ? `url(#${id})` : props.color;
  7080. const style = {
  7081. stroke: color,
  7082. strokeWidth: `${+strokeWidth + 1}px`,
  7083. strokeLinecap,
  7084. strokeDasharray: `${offset}px ${PERIMETER}px`
  7085. };
  7086. return vue.createVNode("path", {
  7087. "d": path.value,
  7088. "style": style,
  7089. "class": bem$P("hover"),
  7090. "stroke": color
  7091. }, null);
  7092. };
  7093. const renderLayer = () => {
  7094. const style = {
  7095. fill: props.fill,
  7096. stroke: props.layerColor,
  7097. strokeWidth: `${props.strokeWidth}px`
  7098. };
  7099. return vue.createVNode("path", {
  7100. "class": bem$P("layer"),
  7101. "style": style,
  7102. "d": path.value
  7103. }, null);
  7104. };
  7105. const renderGradient = () => {
  7106. const {
  7107. color
  7108. } = props;
  7109. if (!isObject(color)) {
  7110. return;
  7111. }
  7112. const Stops = Object.keys(color).sort((a, b) => parseFloat(a) - parseFloat(b)).map((key, index) => vue.createVNode("stop", {
  7113. "key": index,
  7114. "offset": key,
  7115. "stop-color": color[key]
  7116. }, null));
  7117. return vue.createVNode("defs", null, [vue.createVNode("linearGradient", {
  7118. "id": id,
  7119. "x1": "100%",
  7120. "y1": "0%",
  7121. "x2": "0%",
  7122. "y2": "0%"
  7123. }, [Stops])]);
  7124. };
  7125. const renderText = () => {
  7126. if (slots.default) {
  7127. return slots.default();
  7128. }
  7129. if (props.text) {
  7130. return vue.createVNode("div", {
  7131. "class": bem$P("text")
  7132. }, [props.text]);
  7133. }
  7134. };
  7135. return () => vue.createVNode("div", {
  7136. "class": bem$P(),
  7137. "style": getSizeStyle(props.size)
  7138. }, [vue.createVNode("svg", {
  7139. "viewBox": `0 0 ${viewBoxSize.value} ${viewBoxSize.value}`,
  7140. "style": svgStyle.value
  7141. }, [renderGradient(), renderLayer(), renderHover()]), renderText()]);
  7142. }
  7143. });
  7144. const Circle = withInstall(stdin_default$W);
  7145. const [name$P, bem$O] = createNamespace("row");
  7146. const ROW_KEY = Symbol(name$P);
  7147. const rowProps = {
  7148. tag: makeStringProp("div"),
  7149. wrap: truthProp,
  7150. align: String,
  7151. gutter: makeNumericProp(0),
  7152. justify: String
  7153. };
  7154. var stdin_default$V = vue.defineComponent({
  7155. name: name$P,
  7156. props: rowProps,
  7157. setup(props, {
  7158. slots
  7159. }) {
  7160. const {
  7161. children,
  7162. linkChildren
  7163. } = use.useChildren(ROW_KEY);
  7164. const groups = vue.computed(() => {
  7165. const groups2 = [[]];
  7166. let totalSpan = 0;
  7167. children.forEach((child, index) => {
  7168. totalSpan += Number(child.span);
  7169. if (totalSpan > 24) {
  7170. groups2.push([index]);
  7171. totalSpan -= 24;
  7172. } else {
  7173. groups2[groups2.length - 1].push(index);
  7174. }
  7175. });
  7176. return groups2;
  7177. });
  7178. const spaces = vue.computed(() => {
  7179. const gutter = Number(props.gutter);
  7180. const spaces2 = [];
  7181. if (!gutter) {
  7182. return spaces2;
  7183. }
  7184. groups.value.forEach((group) => {
  7185. const averagePadding = gutter * (group.length - 1) / group.length;
  7186. group.forEach((item, index) => {
  7187. if (index === 0) {
  7188. spaces2.push({
  7189. right: averagePadding
  7190. });
  7191. } else {
  7192. const left = gutter - spaces2[item - 1].right;
  7193. const right = averagePadding - left;
  7194. spaces2.push({
  7195. left,
  7196. right
  7197. });
  7198. }
  7199. });
  7200. });
  7201. return spaces2;
  7202. });
  7203. linkChildren({
  7204. spaces
  7205. });
  7206. return () => {
  7207. const {
  7208. tag,
  7209. wrap,
  7210. align,
  7211. justify
  7212. } = props;
  7213. return vue.createVNode(tag, {
  7214. "class": bem$O({
  7215. [`align-${align}`]: align,
  7216. [`justify-${justify}`]: justify,
  7217. nowrap: !wrap
  7218. })
  7219. }, {
  7220. default: () => {
  7221. var _a;
  7222. return [(_a = slots.default) == null ? void 0 : _a.call(slots)];
  7223. }
  7224. });
  7225. };
  7226. }
  7227. });
  7228. const [name$O, bem$N] = createNamespace("col");
  7229. const colProps = {
  7230. tag: makeStringProp("div"),
  7231. span: makeNumericProp(0),
  7232. offset: numericProp
  7233. };
  7234. var stdin_default$U = vue.defineComponent({
  7235. name: name$O,
  7236. props: colProps,
  7237. setup(props, {
  7238. slots
  7239. }) {
  7240. const {
  7241. parent,
  7242. index
  7243. } = use.useParent(ROW_KEY);
  7244. const style = vue.computed(() => {
  7245. if (!parent) {
  7246. return;
  7247. }
  7248. const {
  7249. spaces
  7250. } = parent;
  7251. if (spaces && spaces.value && spaces.value[index.value]) {
  7252. const {
  7253. left,
  7254. right
  7255. } = spaces.value[index.value];
  7256. return {
  7257. paddingLeft: left ? `${left}px` : null,
  7258. paddingRight: right ? `${right}px` : null
  7259. };
  7260. }
  7261. });
  7262. return () => {
  7263. const {
  7264. tag,
  7265. span,
  7266. offset
  7267. } = props;
  7268. return vue.createVNode(tag, {
  7269. "style": style.value,
  7270. "class": bem$N({
  7271. [span]: span,
  7272. [`offset-${offset}`]: offset
  7273. })
  7274. }, {
  7275. default: () => {
  7276. var _a;
  7277. return [(_a = slots.default) == null ? void 0 : _a.call(slots)];
  7278. }
  7279. });
  7280. };
  7281. }
  7282. });
  7283. const Col = withInstall(stdin_default$U);
  7284. const [name$N, bem$M] = createNamespace("collapse");
  7285. const COLLAPSE_KEY = Symbol(name$N);
  7286. const collapseProps = {
  7287. border: truthProp,
  7288. accordion: Boolean,
  7289. modelValue: {
  7290. type: [String, Number, Array],
  7291. default: ""
  7292. }
  7293. };
  7294. function validateModelValue(modelValue, accordion) {
  7295. if (accordion && Array.isArray(modelValue)) {
  7296. console.error('[Vant] Collapse: "v-model" should not be Array in accordion mode');
  7297. return false;
  7298. }
  7299. if (!accordion && !Array.isArray(modelValue)) {
  7300. console.error('[Vant] Collapse: "v-model" should be Array in non-accordion mode');
  7301. return false;
  7302. }
  7303. return true;
  7304. }
  7305. var stdin_default$T = vue.defineComponent({
  7306. name: name$N,
  7307. props: collapseProps,
  7308. emits: ["change", "update:modelValue"],
  7309. setup(props, {
  7310. emit,
  7311. slots
  7312. }) {
  7313. const {
  7314. linkChildren,
  7315. children
  7316. } = use.useChildren(COLLAPSE_KEY);
  7317. const updateName = (name2) => {
  7318. emit("change", name2);
  7319. emit("update:modelValue", name2);
  7320. };
  7321. const toggle = (name2, expanded) => {
  7322. const {
  7323. accordion,
  7324. modelValue
  7325. } = props;
  7326. if (accordion) {
  7327. updateName(name2 === modelValue ? "" : name2);
  7328. } else if (expanded) {
  7329. updateName(modelValue.concat(name2));
  7330. } else {
  7331. updateName(modelValue.filter((activeName) => activeName !== name2));
  7332. }
  7333. };
  7334. const toggleAll = (options = {}) => {
  7335. if (props.accordion) {
  7336. return;
  7337. }
  7338. if (typeof options === "boolean") {
  7339. options = {
  7340. expanded: options
  7341. };
  7342. }
  7343. const {
  7344. expanded,
  7345. skipDisabled
  7346. } = options;
  7347. const expandedChildren = children.filter((item) => {
  7348. if (item.disabled && skipDisabled) {
  7349. return item.expanded.value;
  7350. }
  7351. return expanded != null ? expanded : !item.expanded.value;
  7352. });
  7353. const names = expandedChildren.map((item) => item.itemName.value);
  7354. updateName(names);
  7355. };
  7356. const isExpanded = (name2) => {
  7357. const {
  7358. accordion,
  7359. modelValue
  7360. } = props;
  7361. if (process.env.NODE_ENV !== "production" && !validateModelValue(modelValue, accordion)) {
  7362. return false;
  7363. }
  7364. return accordion ? modelValue === name2 : modelValue.includes(name2);
  7365. };
  7366. useExpose({
  7367. toggleAll
  7368. });
  7369. linkChildren({
  7370. toggle,
  7371. isExpanded
  7372. });
  7373. return () => {
  7374. var _a;
  7375. return vue.createVNode("div", {
  7376. "class": [bem$M(), {
  7377. [BORDER_TOP_BOTTOM]: props.border
  7378. }]
  7379. }, [(_a = slots.default) == null ? void 0 : _a.call(slots)]);
  7380. };
  7381. }
  7382. });
  7383. const Collapse = withInstall(stdin_default$T);
  7384. const [name$M, bem$L] = createNamespace("collapse-item");
  7385. const CELL_SLOTS = ["icon", "title", "value", "label", "right-icon"];
  7386. const collapseItemProps = extend({}, cellSharedProps, {
  7387. name: numericProp,
  7388. isLink: truthProp,
  7389. disabled: Boolean,
  7390. readonly: Boolean,
  7391. lazyRender: truthProp
  7392. });
  7393. var stdin_default$S = vue.defineComponent({
  7394. name: name$M,
  7395. props: collapseItemProps,
  7396. setup(props, {
  7397. slots
  7398. }) {
  7399. const wrapperRef = vue.ref();
  7400. const contentRef = vue.ref();
  7401. const {
  7402. parent,
  7403. index
  7404. } = use.useParent(COLLAPSE_KEY);
  7405. if (!parent) {
  7406. if (process.env.NODE_ENV !== "production") {
  7407. console.error("[Vant] <CollapseItem> must be a child component of <Collapse>.");
  7408. }
  7409. return;
  7410. }
  7411. const name2 = vue.computed(() => {
  7412. var _a;
  7413. return (_a = props.name) != null ? _a : index.value;
  7414. });
  7415. const expanded = vue.computed(() => parent.isExpanded(name2.value));
  7416. const show = vue.ref(expanded.value);
  7417. const lazyRender = useLazyRender(() => show.value || !props.lazyRender);
  7418. const onTransitionEnd = () => {
  7419. if (!expanded.value) {
  7420. show.value = false;
  7421. } else if (wrapperRef.value) {
  7422. wrapperRef.value.style.height = "";
  7423. }
  7424. };
  7425. vue.watch(expanded, (value, oldValue) => {
  7426. if (oldValue === null) {
  7427. return;
  7428. }
  7429. if (value) {
  7430. show.value = true;
  7431. }
  7432. const tick = value ? vue.nextTick : use.raf;
  7433. tick(() => {
  7434. if (!contentRef.value || !wrapperRef.value) {
  7435. return;
  7436. }
  7437. const {
  7438. offsetHeight
  7439. } = contentRef.value;
  7440. if (offsetHeight) {
  7441. const contentHeight = `${offsetHeight}px`;
  7442. wrapperRef.value.style.height = value ? "0" : contentHeight;
  7443. use.doubleRaf(() => {
  7444. if (wrapperRef.value) {
  7445. wrapperRef.value.style.height = value ? contentHeight : "0";
  7446. }
  7447. });
  7448. } else {
  7449. onTransitionEnd();
  7450. }
  7451. });
  7452. });
  7453. const toggle = (newValue = !expanded.value) => {
  7454. parent.toggle(name2.value, newValue);
  7455. };
  7456. const onClickTitle = () => {
  7457. if (!props.disabled && !props.readonly) {
  7458. toggle();
  7459. }
  7460. };
  7461. const renderTitle = () => {
  7462. const {
  7463. border,
  7464. disabled,
  7465. readonly
  7466. } = props;
  7467. const attrs = pick(props, Object.keys(cellSharedProps));
  7468. if (readonly) {
  7469. attrs.isLink = false;
  7470. }
  7471. if (disabled || readonly) {
  7472. attrs.clickable = false;
  7473. }
  7474. return vue.createVNode(Cell, vue.mergeProps({
  7475. "role": "button",
  7476. "class": bem$L("title", {
  7477. disabled,
  7478. expanded: expanded.value,
  7479. borderless: !border
  7480. }),
  7481. "aria-expanded": String(expanded.value),
  7482. "onClick": onClickTitle
  7483. }, attrs), pick(slots, CELL_SLOTS));
  7484. };
  7485. const renderContent = lazyRender(() => {
  7486. var _a;
  7487. return vue.withDirectives(vue.createVNode("div", {
  7488. "ref": wrapperRef,
  7489. "class": bem$L("wrapper"),
  7490. "onTransitionend": onTransitionEnd
  7491. }, [vue.createVNode("div", {
  7492. "ref": contentRef,
  7493. "class": bem$L("content")
  7494. }, [(_a = slots.default) == null ? void 0 : _a.call(slots)])]), [[vue.vShow, show.value]]);
  7495. });
  7496. useExpose({
  7497. toggle,
  7498. expanded,
  7499. itemName: name2
  7500. });
  7501. return () => vue.createVNode("div", {
  7502. "class": [bem$L({
  7503. border: index.value && props.border
  7504. })]
  7505. }, [renderTitle(), renderContent()]);
  7506. }
  7507. });
  7508. const CollapseItem = withInstall(stdin_default$S);
  7509. const ConfigProvider = withInstall(stdin_default$1A);
  7510. const [name$L, bem$K, t$d] = createNamespace("contact-card");
  7511. const contactCardProps = {
  7512. tel: String,
  7513. name: String,
  7514. type: makeStringProp("add"),
  7515. addText: String,
  7516. editable: truthProp
  7517. };
  7518. var stdin_default$R = vue.defineComponent({
  7519. name: name$L,
  7520. props: contactCardProps,
  7521. emits: ["click"],
  7522. setup(props, {
  7523. emit
  7524. }) {
  7525. const onClick = (event) => {
  7526. if (props.editable) {
  7527. emit("click", event);
  7528. }
  7529. };
  7530. const renderContent = () => {
  7531. if (props.type === "add") {
  7532. return props.addText || t$d("addContact");
  7533. }
  7534. return [vue.createVNode("div", null, [`${t$d("name")}\uFF1A${props.name}`]), vue.createVNode("div", null, [`${t$d("tel")}\uFF1A${props.tel}`])];
  7535. };
  7536. return () => vue.createVNode(Cell, {
  7537. "center": true,
  7538. "icon": props.type === "edit" ? "contact" : "add-square",
  7539. "class": bem$K([props.type]),
  7540. "border": false,
  7541. "isLink": props.editable,
  7542. "valueClass": bem$K("value"),
  7543. "onClick": onClick
  7544. }, {
  7545. value: renderContent
  7546. });
  7547. }
  7548. });
  7549. const ContactCard = withInstall(stdin_default$R);
  7550. const [name$K, bem$J, t$c] = createNamespace("contact-edit");
  7551. const DEFAULT_CONTACT = {
  7552. tel: "",
  7553. name: ""
  7554. };
  7555. const contactEditProps = {
  7556. isEdit: Boolean,
  7557. isSaving: Boolean,
  7558. isDeleting: Boolean,
  7559. showSetDefault: Boolean,
  7560. setDefaultLabel: String,
  7561. contactInfo: {
  7562. type: Object,
  7563. default: () => extend({}, DEFAULT_CONTACT)
  7564. },
  7565. telValidator: {
  7566. type: Function,
  7567. default: isMobile
  7568. }
  7569. };
  7570. var stdin_default$Q = vue.defineComponent({
  7571. name: name$K,
  7572. props: contactEditProps,
  7573. emits: ["save", "delete", "change-default"],
  7574. setup(props, {
  7575. emit
  7576. }) {
  7577. const contact = vue.reactive(extend({}, DEFAULT_CONTACT, props.contactInfo));
  7578. const onSave = () => {
  7579. if (!props.isSaving) {
  7580. emit("save", contact);
  7581. }
  7582. };
  7583. const onDelete = () => emit("delete", contact);
  7584. const renderButtons = () => vue.createVNode("div", {
  7585. "class": bem$J("buttons")
  7586. }, [vue.createVNode(Button, {
  7587. "block": true,
  7588. "round": true,
  7589. "type": "danger",
  7590. "text": t$c("save"),
  7591. "class": bem$J("button"),
  7592. "loading": props.isSaving,
  7593. "nativeType": "submit"
  7594. }, null), props.isEdit && vue.createVNode(Button, {
  7595. "block": true,
  7596. "round": true,
  7597. "text": t$c("delete"),
  7598. "class": bem$J("button"),
  7599. "loading": props.isDeleting,
  7600. "onClick": onDelete
  7601. }, null)]);
  7602. const renderSwitch = () => vue.createVNode(Switch, {
  7603. "modelValue": contact.isDefault,
  7604. "onUpdate:modelValue": ($event) => contact.isDefault = $event,
  7605. "size": 24,
  7606. "onChange": (checked) => emit("change-default", checked)
  7607. }, null);
  7608. const renderSetDefault = () => {
  7609. if (props.showSetDefault) {
  7610. return vue.createVNode(Cell, {
  7611. "title": props.setDefaultLabel,
  7612. "class": bem$J("switch-cell"),
  7613. "border": false
  7614. }, {
  7615. "right-icon": renderSwitch
  7616. });
  7617. }
  7618. };
  7619. vue.watch(() => props.contactInfo, (value) => extend(contact, DEFAULT_CONTACT, value));
  7620. return () => vue.createVNode(Form, {
  7621. "class": bem$J(),
  7622. "onSubmit": onSave
  7623. }, {
  7624. default: () => [vue.createVNode("div", {
  7625. "class": bem$J("fields")
  7626. }, [vue.createVNode(Field, {
  7627. "modelValue": contact.name,
  7628. "onUpdate:modelValue": ($event) => contact.name = $event,
  7629. "clearable": true,
  7630. "label": t$c("name"),
  7631. "rules": [{
  7632. required: true,
  7633. message: t$c("nameEmpty")
  7634. }],
  7635. "maxlength": "30",
  7636. "placeholder": t$c("name")
  7637. }, null), vue.createVNode(Field, {
  7638. "modelValue": contact.tel,
  7639. "onUpdate:modelValue": ($event) => contact.tel = $event,
  7640. "clearable": true,
  7641. "type": "tel",
  7642. "label": t$c("tel"),
  7643. "rules": [{
  7644. validator: props.telValidator,
  7645. message: t$c("telInvalid")
  7646. }],
  7647. "placeholder": t$c("tel")
  7648. }, null)]), renderSetDefault(), renderButtons()]
  7649. });
  7650. }
  7651. });
  7652. const ContactEdit = withInstall(stdin_default$Q);
  7653. const [name$J, bem$I, t$b] = createNamespace("contact-list");
  7654. const contactListProps = {
  7655. list: Array,
  7656. addText: String,
  7657. modelValue: unknownProp,
  7658. defaultTagText: String
  7659. };
  7660. var stdin_default$P = vue.defineComponent({
  7661. name: name$J,
  7662. props: contactListProps,
  7663. emits: ["add", "edit", "select", "update:modelValue"],
  7664. setup(props, {
  7665. emit
  7666. }) {
  7667. const renderItem = (item, index) => {
  7668. const onClick = () => {
  7669. emit("update:modelValue", item.id);
  7670. emit("select", item, index);
  7671. };
  7672. const renderRightIcon = () => vue.createVNode(Radio, {
  7673. "class": bem$I("radio"),
  7674. "name": item.id,
  7675. "iconSize": 16
  7676. }, null);
  7677. const renderEditIcon = () => vue.createVNode(Icon, {
  7678. "name": "edit",
  7679. "class": bem$I("edit"),
  7680. "onClick": (event) => {
  7681. event.stopPropagation();
  7682. emit("edit", item, index);
  7683. }
  7684. }, null);
  7685. const renderContent = () => {
  7686. const nodes = [`${item.name}\uFF0C${item.tel}`];
  7687. if (item.isDefault && props.defaultTagText) {
  7688. nodes.push(vue.createVNode(Tag, {
  7689. "type": "danger",
  7690. "round": true,
  7691. "class": bem$I("item-tag")
  7692. }, {
  7693. default: () => [props.defaultTagText]
  7694. }));
  7695. }
  7696. return nodes;
  7697. };
  7698. return vue.createVNode(Cell, {
  7699. "key": item.id,
  7700. "isLink": true,
  7701. "center": true,
  7702. "class": bem$I("item"),
  7703. "valueClass": bem$I("item-value"),
  7704. "onClick": onClick
  7705. }, {
  7706. icon: renderEditIcon,
  7707. value: renderContent,
  7708. "right-icon": renderRightIcon
  7709. });
  7710. };
  7711. return () => vue.createVNode("div", {
  7712. "class": bem$I()
  7713. }, [vue.createVNode(RadioGroup, {
  7714. "modelValue": props.modelValue,
  7715. "class": bem$I("group")
  7716. }, {
  7717. default: () => [props.list && props.list.map(renderItem)]
  7718. }), vue.createVNode("div", {
  7719. "class": [bem$I("bottom"), "van-safe-area-bottom"]
  7720. }, [vue.createVNode(Button, {
  7721. "round": true,
  7722. "block": true,
  7723. "type": "danger",
  7724. "class": bem$I("add"),
  7725. "text": props.addText || t$b("addContact"),
  7726. "onClick": () => emit("add")
  7727. }, null)])]);
  7728. }
  7729. });
  7730. const ContactList = withInstall(stdin_default$P);
  7731. function parseFormat(format2, currentTime) {
  7732. const { days } = currentTime;
  7733. let { hours, minutes, seconds, milliseconds } = currentTime;
  7734. if (format2.includes("DD")) {
  7735. format2 = format2.replace("DD", padZero(days));
  7736. } else {
  7737. hours += days * 24;
  7738. }
  7739. if (format2.includes("HH")) {
  7740. format2 = format2.replace("HH", padZero(hours));
  7741. } else {
  7742. minutes += hours * 60;
  7743. }
  7744. if (format2.includes("mm")) {
  7745. format2 = format2.replace("mm", padZero(minutes));
  7746. } else {
  7747. seconds += minutes * 60;
  7748. }
  7749. if (format2.includes("ss")) {
  7750. format2 = format2.replace("ss", padZero(seconds));
  7751. } else {
  7752. milliseconds += seconds * 1e3;
  7753. }
  7754. if (format2.includes("S")) {
  7755. const ms = padZero(milliseconds, 3);
  7756. if (format2.includes("SSS")) {
  7757. format2 = format2.replace("SSS", ms);
  7758. } else if (format2.includes("SS")) {
  7759. format2 = format2.replace("SS", ms.slice(0, 2));
  7760. } else {
  7761. format2 = format2.replace("S", ms.charAt(0));
  7762. }
  7763. }
  7764. return format2;
  7765. }
  7766. const [name$I, bem$H] = createNamespace("count-down");
  7767. const countDownProps = {
  7768. time: makeNumericProp(0),
  7769. format: makeStringProp("HH:mm:ss"),
  7770. autoStart: truthProp,
  7771. millisecond: Boolean
  7772. };
  7773. var stdin_default$O = vue.defineComponent({
  7774. name: name$I,
  7775. props: countDownProps,
  7776. emits: ["change", "finish"],
  7777. setup(props, {
  7778. emit,
  7779. slots
  7780. }) {
  7781. const {
  7782. start,
  7783. pause,
  7784. reset,
  7785. current: current2
  7786. } = use.useCountDown({
  7787. time: +props.time,
  7788. millisecond: props.millisecond,
  7789. onChange: (current22) => emit("change", current22),
  7790. onFinish: () => emit("finish")
  7791. });
  7792. const timeText = vue.computed(() => parseFormat(props.format, current2.value));
  7793. const resetTime = () => {
  7794. reset(+props.time);
  7795. if (props.autoStart) {
  7796. start();
  7797. }
  7798. };
  7799. vue.watch(() => props.time, resetTime, {
  7800. immediate: true
  7801. });
  7802. useExpose({
  7803. start,
  7804. pause,
  7805. reset: resetTime
  7806. });
  7807. return () => vue.createVNode("div", {
  7808. "role": "timer",
  7809. "class": bem$H()
  7810. }, [slots.default ? slots.default(current2.value) : timeText.value]);
  7811. }
  7812. });
  7813. const CountDown = withInstall(stdin_default$O);
  7814. function getDate(timeStamp) {
  7815. const date = new Date(timeStamp * 1e3);
  7816. return `${date.getFullYear()}.${padZero(date.getMonth() + 1)}.${padZero(
  7817. date.getDate()
  7818. )}`;
  7819. }
  7820. const formatDiscount = (discount) => (discount / 10).toFixed(discount % 10 === 0 ? 0 : 1);
  7821. const formatAmount = (amount) => (amount / 100).toFixed(amount % 100 === 0 ? 0 : amount % 10 === 0 ? 1 : 2);
  7822. const [name$H, bem$G, t$a] = createNamespace("coupon");
  7823. var stdin_default$N = vue.defineComponent({
  7824. name: name$H,
  7825. props: {
  7826. chosen: Boolean,
  7827. coupon: makeRequiredProp(Object),
  7828. disabled: Boolean,
  7829. currency: makeStringProp("\xA5")
  7830. },
  7831. setup(props) {
  7832. const validPeriod = vue.computed(() => {
  7833. const {
  7834. startAt,
  7835. endAt
  7836. } = props.coupon;
  7837. return `${getDate(startAt)} - ${getDate(endAt)}`;
  7838. });
  7839. const faceAmount = vue.computed(() => {
  7840. const {
  7841. coupon,
  7842. currency
  7843. } = props;
  7844. if (coupon.valueDesc) {
  7845. return [coupon.valueDesc, vue.createVNode("span", null, [coupon.unitDesc || ""])];
  7846. }
  7847. if (coupon.denominations) {
  7848. const denominations = formatAmount(coupon.denominations);
  7849. return [vue.createVNode("span", null, [currency]), ` ${denominations}`];
  7850. }
  7851. if (coupon.discount) {
  7852. return t$a("discount", formatDiscount(coupon.discount));
  7853. }
  7854. return "";
  7855. });
  7856. const conditionMessage = vue.computed(() => {
  7857. const condition = formatAmount(props.coupon.originCondition || 0);
  7858. return condition === "0" ? t$a("unlimited") : t$a("condition", condition);
  7859. });
  7860. return () => {
  7861. const {
  7862. chosen,
  7863. coupon,
  7864. disabled
  7865. } = props;
  7866. const description = disabled && coupon.reason || coupon.description;
  7867. return vue.createVNode("div", {
  7868. "class": bem$G({
  7869. disabled
  7870. })
  7871. }, [vue.createVNode("div", {
  7872. "class": bem$G("content")
  7873. }, [vue.createVNode("div", {
  7874. "class": bem$G("head")
  7875. }, [vue.createVNode("h2", {
  7876. "class": bem$G("amount")
  7877. }, [faceAmount.value]), vue.createVNode("p", {
  7878. "class": bem$G("condition")
  7879. }, [coupon.condition || conditionMessage.value])]), vue.createVNode("div", {
  7880. "class": bem$G("body")
  7881. }, [vue.createVNode("p", {
  7882. "class": bem$G("name")
  7883. }, [coupon.name]), vue.createVNode("p", {
  7884. "class": bem$G("valid")
  7885. }, [validPeriod.value]), !disabled && vue.createVNode(Checkbox, {
  7886. "class": bem$G("corner"),
  7887. "modelValue": chosen
  7888. }, null)])]), description && vue.createVNode("p", {
  7889. "class": bem$G("description")
  7890. }, [description])]);
  7891. };
  7892. }
  7893. });
  7894. const Coupon = withInstall(stdin_default$N);
  7895. const [name$G, bem$F, t$9] = createNamespace("coupon-cell");
  7896. const couponCellProps = {
  7897. title: String,
  7898. border: truthProp,
  7899. editable: truthProp,
  7900. coupons: makeArrayProp(),
  7901. currency: makeStringProp("\xA5"),
  7902. chosenCoupon: makeNumericProp(-1)
  7903. };
  7904. function formatValue({
  7905. coupons,
  7906. chosenCoupon,
  7907. currency
  7908. }) {
  7909. const coupon = coupons[+chosenCoupon];
  7910. if (coupon) {
  7911. let value = 0;
  7912. if (isDef(coupon.value)) {
  7913. ({
  7914. value
  7915. } = coupon);
  7916. } else if (isDef(coupon.denominations)) {
  7917. value = coupon.denominations;
  7918. }
  7919. return `-${currency} ${(value / 100).toFixed(2)}`;
  7920. }
  7921. return coupons.length === 0 ? t$9("noCoupon") : t$9("count", coupons.length);
  7922. }
  7923. var stdin_default$M = vue.defineComponent({
  7924. name: name$G,
  7925. props: couponCellProps,
  7926. setup(props) {
  7927. return () => {
  7928. const selected = props.coupons[+props.chosenCoupon];
  7929. return vue.createVNode(Cell, {
  7930. "class": bem$F(),
  7931. "value": formatValue(props),
  7932. "title": props.title || t$9("title"),
  7933. "border": props.border,
  7934. "isLink": props.editable,
  7935. "valueClass": bem$F("value", {
  7936. selected
  7937. })
  7938. }, null);
  7939. };
  7940. }
  7941. });
  7942. const CouponCell = withInstall(stdin_default$M);
  7943. const [name$F, bem$E] = createNamespace("empty");
  7944. const emptyProps = {
  7945. image: makeStringProp("default"),
  7946. imageSize: [Number, String, Array],
  7947. description: String
  7948. };
  7949. var stdin_default$L = vue.defineComponent({
  7950. name: name$F,
  7951. props: emptyProps,
  7952. setup(props, {
  7953. slots
  7954. }) {
  7955. const renderDescription = () => {
  7956. const description = slots.description ? slots.description() : props.description;
  7957. if (description) {
  7958. return vue.createVNode("p", {
  7959. "class": bem$E("description")
  7960. }, [description]);
  7961. }
  7962. };
  7963. const renderBottom = () => {
  7964. if (slots.default) {
  7965. return vue.createVNode("div", {
  7966. "class": bem$E("bottom")
  7967. }, [slots.default()]);
  7968. }
  7969. };
  7970. const baseId = useId();
  7971. const getId = (num) => `${baseId}-${num}`;
  7972. const getUrlById = (num) => `url(#${getId(num)})`;
  7973. const renderStop = (color, offset, opacity) => vue.createVNode("stop", {
  7974. "stop-color": color,
  7975. "offset": `${offset}%`,
  7976. "stop-opacity": opacity
  7977. }, null);
  7978. const renderStops = (fromColor, toColor) => [renderStop(fromColor, 0), renderStop(toColor, 100)];
  7979. const renderShadow = (id) => [vue.createVNode("defs", null, [vue.createVNode("radialGradient", {
  7980. "id": getId(id),
  7981. "cx": "50%",
  7982. "cy": "54%",
  7983. "fx": "50%",
  7984. "fy": "54%",
  7985. "r": "297%",
  7986. "gradientTransform": "matrix(-.16 0 0 -.33 .58 .72)"
  7987. }, [renderStop("#EBEDF0", 0), renderStop("#F2F3F5", 100, 0.3)])]), vue.createVNode("ellipse", {
  7988. "fill": getUrlById(id),
  7989. "opacity": ".8",
  7990. "cx": "80",
  7991. "cy": "140",
  7992. "rx": "46",
  7993. "ry": "8"
  7994. }, null)];
  7995. const renderBuilding = () => [vue.createVNode("defs", null, [vue.createVNode("linearGradient", {
  7996. "id": getId("a"),
  7997. "x1": "64%",
  7998. "y1": "100%",
  7999. "x2": "64%"
  8000. }, [renderStop("#FFF", 0, 0.5), renderStop("#F2F3F5", 100)])]), vue.createVNode("g", {
  8001. "opacity": ".8"
  8002. }, [vue.createVNode("path", {
  8003. "d": "M36 131V53H16v20H2v58h34z",
  8004. "fill": getUrlById("a")
  8005. }, null), vue.createVNode("path", {
  8006. "d": "M123 15h22v14h9v77h-31V15z",
  8007. "fill": getUrlById("a")
  8008. }, null)])];
  8009. const renderCloud = () => [vue.createVNode("defs", null, [vue.createVNode("linearGradient", {
  8010. "id": getId("b"),
  8011. "x1": "64%",
  8012. "y1": "97%",
  8013. "x2": "64%",
  8014. "y2": "0%"
  8015. }, [renderStop("#F2F3F5", 0, 0.3), renderStop("#F2F3F5", 100)])]), vue.createVNode("g", {
  8016. "opacity": ".8"
  8017. }, [vue.createVNode("path", {
  8018. "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",
  8019. "fill": getUrlById("b")
  8020. }, null), vue.createVNode("path", {
  8021. "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",
  8022. "fill": getUrlById("b")
  8023. }, null)])];
  8024. const renderNetwork = () => vue.createVNode("svg", {
  8025. "viewBox": "0 0 160 160"
  8026. }, [vue.createVNode("defs", null, [vue.createVNode("linearGradient", {
  8027. "id": getId(1),
  8028. "x1": "64%",
  8029. "y1": "100%",
  8030. "x2": "64%"
  8031. }, [renderStop("#FFF", 0, 0.5), renderStop("#F2F3F5", 100)]), vue.createVNode("linearGradient", {
  8032. "id": getId(2),
  8033. "x1": "50%",
  8034. "x2": "50%",
  8035. "y2": "84%"
  8036. }, [renderStop("#EBEDF0", 0), renderStop("#DCDEE0", 100, 0)]), vue.createVNode("linearGradient", {
  8037. "id": getId(3),
  8038. "x1": "100%",
  8039. "x2": "100%",
  8040. "y2": "100%"
  8041. }, [renderStops("#EAEDF0", "#DCDEE0")]), vue.createVNode("radialGradient", {
  8042. "id": getId(4),
  8043. "cx": "50%",
  8044. "cy": "0%",
  8045. "fx": "50%",
  8046. "fy": "0%",
  8047. "r": "100%",
  8048. "gradientTransform": "matrix(0 1 -.54 0 .5 -.5)"
  8049. }, [renderStop("#EBEDF0", 0), renderStop("#FFF", 100, 0)])]), vue.createVNode("g", {
  8050. "fill": "none"
  8051. }, [renderBuilding(), vue.createVNode("path", {
  8052. "fill": getUrlById(4),
  8053. "d": "M0 139h160v21H0z"
  8054. }, null), vue.createVNode("path", {
  8055. "d": "M80 54a7 7 0 0 1 3 13v27l-2 2h-2a2 2 0 0 1-2-2V67a7 7 0 0 1 3-13z",
  8056. "fill": getUrlById(2)
  8057. }, null), vue.createVNode("g", {
  8058. "opacity": ".6",
  8059. "stroke-linecap": "round",
  8060. "stroke-width": "7"
  8061. }, [vue.createVNode("path", {
  8062. "d": "M64 47a19 19 0 0 0-5 13c0 5 2 10 5 13",
  8063. "stroke": getUrlById(3)
  8064. }, null), vue.createVNode("path", {
  8065. "d": "M53 36a34 34 0 0 0 0 48",
  8066. "stroke": getUrlById(3)
  8067. }, null), vue.createVNode("path", {
  8068. "d": "M95 73a19 19 0 0 0 6-13c0-5-2-9-6-13",
  8069. "stroke": getUrlById(3)
  8070. }, null), vue.createVNode("path", {
  8071. "d": "M106 84a34 34 0 0 0 0-48",
  8072. "stroke": getUrlById(3)
  8073. }, null)]), vue.createVNode("g", {
  8074. "transform": "translate(31 105)"
  8075. }, [vue.createVNode("rect", {
  8076. "fill": "#EBEDF0",
  8077. "width": "98",
  8078. "height": "34",
  8079. "rx": "2"
  8080. }, null), vue.createVNode("rect", {
  8081. "fill": "#FFF",
  8082. "x": "9",
  8083. "y": "8",
  8084. "width": "80",
  8085. "height": "18",
  8086. "rx": "1.1"
  8087. }, null), vue.createVNode("rect", {
  8088. "fill": "#EBEDF0",
  8089. "x": "15",
  8090. "y": "12",
  8091. "width": "18",
  8092. "height": "6",
  8093. "rx": "1.1"
  8094. }, null)])])]);
  8095. const renderMaterial = () => vue.createVNode("svg", {
  8096. "viewBox": "0 0 160 160"
  8097. }, [vue.createVNode("defs", null, [vue.createVNode("linearGradient", {
  8098. "x1": "50%",
  8099. "x2": "50%",
  8100. "y2": "100%",
  8101. "id": getId(5)
  8102. }, [renderStops("#F2F3F5", "#DCDEE0")]), vue.createVNode("linearGradient", {
  8103. "x1": "95%",
  8104. "y1": "48%",
  8105. "x2": "5.5%",
  8106. "y2": "51%",
  8107. "id": getId(6)
  8108. }, [renderStops("#EAEDF1", "#DCDEE0")]), vue.createVNode("linearGradient", {
  8109. "y1": "45%",
  8110. "x2": "100%",
  8111. "y2": "54%",
  8112. "id": getId(7)
  8113. }, [renderStops("#EAEDF1", "#DCDEE0")])]), renderBuilding(), renderCloud(), vue.createVNode("g", {
  8114. "transform": "translate(36 50)",
  8115. "fill": "none"
  8116. }, [vue.createVNode("g", {
  8117. "transform": "translate(8)"
  8118. }, [vue.createVNode("rect", {
  8119. "fill": "#EBEDF0",
  8120. "opacity": ".6",
  8121. "x": "38",
  8122. "y": "13",
  8123. "width": "36",
  8124. "height": "53",
  8125. "rx": "2"
  8126. }, null), vue.createVNode("rect", {
  8127. "fill": getUrlById(5),
  8128. "width": "64",
  8129. "height": "66",
  8130. "rx": "2"
  8131. }, null), vue.createVNode("rect", {
  8132. "fill": "#FFF",
  8133. "x": "6",
  8134. "y": "6",
  8135. "width": "52",
  8136. "height": "55",
  8137. "rx": "1"
  8138. }, null), vue.createVNode("g", {
  8139. "transform": "translate(15 17)",
  8140. "fill": getUrlById(6)
  8141. }, [vue.createVNode("rect", {
  8142. "width": "34",
  8143. "height": "6",
  8144. "rx": "1"
  8145. }, null), vue.createVNode("path", {
  8146. "d": "M0 14h34v6H0z"
  8147. }, null), vue.createVNode("rect", {
  8148. "y": "28",
  8149. "width": "34",
  8150. "height": "6",
  8151. "rx": "1"
  8152. }, null)])]), vue.createVNode("rect", {
  8153. "fill": getUrlById(7),
  8154. "y": "61",
  8155. "width": "88",
  8156. "height": "28",
  8157. "rx": "1"
  8158. }, null), vue.createVNode("rect", {
  8159. "fill": "#F7F8FA",
  8160. "x": "29",
  8161. "y": "72",
  8162. "width": "30",
  8163. "height": "6",
  8164. "rx": "1"
  8165. }, null)])]);
  8166. const renderError = () => vue.createVNode("svg", {
  8167. "viewBox": "0 0 160 160"
  8168. }, [vue.createVNode("defs", null, [vue.createVNode("linearGradient", {
  8169. "x1": "50%",
  8170. "x2": "50%",
  8171. "y2": "100%",
  8172. "id": getId(8)
  8173. }, [renderStops("#EAEDF1", "#DCDEE0")])]), renderBuilding(), renderCloud(), renderShadow("c"), vue.createVNode("path", {
  8174. "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",
  8175. "fill": getUrlById(8)
  8176. }, null)]);
  8177. const renderSearch = () => vue.createVNode("svg", {
  8178. "viewBox": "0 0 160 160"
  8179. }, [vue.createVNode("defs", null, [vue.createVNode("linearGradient", {
  8180. "x1": "50%",
  8181. "y1": "100%",
  8182. "x2": "50%",
  8183. "id": getId(9)
  8184. }, [renderStops("#EEE", "#D8D8D8")]), vue.createVNode("linearGradient", {
  8185. "x1": "100%",
  8186. "y1": "50%",
  8187. "y2": "50%",
  8188. "id": getId(10)
  8189. }, [renderStops("#F2F3F5", "#DCDEE0")]), vue.createVNode("linearGradient", {
  8190. "x1": "50%",
  8191. "x2": "50%",
  8192. "y2": "100%",
  8193. "id": getId(11)
  8194. }, [renderStops("#F2F3F5", "#DCDEE0")]), vue.createVNode("linearGradient", {
  8195. "x1": "50%",
  8196. "x2": "50%",
  8197. "y2": "100%",
  8198. "id": getId(12)
  8199. }, [renderStops("#FFF", "#F7F8FA")])]), renderBuilding(), renderCloud(), renderShadow("d"), vue.createVNode("g", {
  8200. "transform": "rotate(-45 113 -4)",
  8201. "fill": "none"
  8202. }, [vue.createVNode("rect", {
  8203. "fill": getUrlById(9),
  8204. "x": "24",
  8205. "y": "52.8",
  8206. "width": "5.8",
  8207. "height": "19",
  8208. "rx": "1"
  8209. }, null), vue.createVNode("rect", {
  8210. "fill": getUrlById(10),
  8211. "x": "22.1",
  8212. "y": "67.3",
  8213. "width": "9.9",
  8214. "height": "28",
  8215. "rx": "1"
  8216. }, null), vue.createVNode("circle", {
  8217. "stroke": getUrlById(11),
  8218. "stroke-width": "8",
  8219. "cx": "27",
  8220. "cy": "27",
  8221. "r": "27"
  8222. }, null), vue.createVNode("circle", {
  8223. "fill": getUrlById(12),
  8224. "cx": "27",
  8225. "cy": "27",
  8226. "r": "16"
  8227. }, null), vue.createVNode("path", {
  8228. "d": "M37 7c-8 0-15 5-16 12",
  8229. "stroke": getUrlById(11),
  8230. "stroke-width": "3",
  8231. "opacity": ".5",
  8232. "stroke-linecap": "round",
  8233. "transform": "rotate(45 29 13)"
  8234. }, null)])]);
  8235. const renderImage = () => {
  8236. var _a;
  8237. if (slots.image) {
  8238. return slots.image();
  8239. }
  8240. const PRESET_IMAGES = {
  8241. error: renderError,
  8242. search: renderSearch,
  8243. network: renderNetwork,
  8244. default: renderMaterial
  8245. };
  8246. return ((_a = PRESET_IMAGES[props.image]) == null ? void 0 : _a.call(PRESET_IMAGES)) || vue.createVNode("img", {
  8247. "src": props.image
  8248. }, null);
  8249. };
  8250. return () => vue.createVNode("div", {
  8251. "class": bem$E()
  8252. }, [vue.createVNode("div", {
  8253. "class": bem$E("image"),
  8254. "style": getSizeStyle(props.imageSize)
  8255. }, [renderImage()]), renderDescription(), renderBottom()]);
  8256. }
  8257. });
  8258. const Empty = withInstall(stdin_default$L);
  8259. const [name$E, bem$D, t$8] = createNamespace("coupon-list");
  8260. const couponListProps = {
  8261. code: makeStringProp(""),
  8262. coupons: makeArrayProp(),
  8263. currency: makeStringProp("\xA5"),
  8264. showCount: truthProp,
  8265. emptyImage: String,
  8266. chosenCoupon: makeNumberProp(-1),
  8267. enabledTitle: String,
  8268. disabledTitle: String,
  8269. disabledCoupons: makeArrayProp(),
  8270. showExchangeBar: truthProp,
  8271. showCloseButton: truthProp,
  8272. closeButtonText: String,
  8273. inputPlaceholder: String,
  8274. exchangeMinLength: makeNumberProp(1),
  8275. exchangeButtonText: String,
  8276. displayedCouponIndex: makeNumberProp(-1),
  8277. exchangeButtonLoading: Boolean,
  8278. exchangeButtonDisabled: Boolean
  8279. };
  8280. var stdin_default$K = vue.defineComponent({
  8281. name: name$E,
  8282. props: couponListProps,
  8283. emits: ["change", "exchange", "update:code"],
  8284. setup(props, {
  8285. emit,
  8286. slots
  8287. }) {
  8288. const [couponRefs, setCouponRefs] = useRefs();
  8289. const root = vue.ref();
  8290. const barRef = vue.ref();
  8291. const activeTab = vue.ref(0);
  8292. const listHeight = vue.ref(0);
  8293. const currentCode = vue.ref(props.code);
  8294. const buttonDisabled = vue.computed(() => !props.exchangeButtonLoading && (props.exchangeButtonDisabled || !currentCode.value || currentCode.value.length < props.exchangeMinLength));
  8295. const updateListHeight = () => {
  8296. const TABS_HEIGHT = 44;
  8297. const rootHeight = use.useRect(root).height;
  8298. const headerHeight = use.useRect(barRef).height + TABS_HEIGHT;
  8299. listHeight.value = (rootHeight > headerHeight ? rootHeight : windowHeight.value) - headerHeight;
  8300. };
  8301. const onExchange = () => {
  8302. emit("exchange", currentCode.value);
  8303. if (!props.code) {
  8304. currentCode.value = "";
  8305. }
  8306. };
  8307. const scrollToCoupon = (index) => {
  8308. vue.nextTick(() => {
  8309. var _a;
  8310. return (_a = couponRefs.value[index]) == null ? void 0 : _a.scrollIntoView();
  8311. });
  8312. };
  8313. const renderEmpty = () => vue.createVNode(Empty, {
  8314. "image": props.emptyImage
  8315. }, {
  8316. default: () => [vue.createVNode("p", {
  8317. "class": bem$D("empty-tip")
  8318. }, [t$8("noCoupon")])]
  8319. });
  8320. const renderExchangeBar = () => {
  8321. if (props.showExchangeBar) {
  8322. return vue.createVNode("div", {
  8323. "ref": barRef,
  8324. "class": bem$D("exchange-bar")
  8325. }, [vue.createVNode(Field, {
  8326. "modelValue": currentCode.value,
  8327. "onUpdate:modelValue": ($event) => currentCode.value = $event,
  8328. "clearable": true,
  8329. "border": false,
  8330. "class": bem$D("field"),
  8331. "placeholder": props.inputPlaceholder || t$8("placeholder"),
  8332. "maxlength": "20"
  8333. }, null), vue.createVNode(Button, {
  8334. "plain": true,
  8335. "type": "danger",
  8336. "class": bem$D("exchange"),
  8337. "text": props.exchangeButtonText || t$8("exchange"),
  8338. "loading": props.exchangeButtonLoading,
  8339. "disabled": buttonDisabled.value,
  8340. "onClick": onExchange
  8341. }, null)]);
  8342. }
  8343. };
  8344. const renderCouponTab = () => {
  8345. const {
  8346. coupons
  8347. } = props;
  8348. const count = props.showCount ? ` (${coupons.length})` : "";
  8349. const title = (props.enabledTitle || t$8("enable")) + count;
  8350. return vue.createVNode(Tab, {
  8351. "title": title
  8352. }, {
  8353. default: () => {
  8354. var _a;
  8355. return [vue.createVNode("div", {
  8356. "class": bem$D("list", {
  8357. "with-bottom": props.showCloseButton
  8358. }),
  8359. "style": {
  8360. height: `${listHeight.value}px`
  8361. }
  8362. }, [coupons.map((coupon, index) => vue.createVNode(Coupon, {
  8363. "key": coupon.id,
  8364. "ref": setCouponRefs(index),
  8365. "coupon": coupon,
  8366. "chosen": index === props.chosenCoupon,
  8367. "currency": props.currency,
  8368. "onClick": () => emit("change", index)
  8369. }, null)), !coupons.length && renderEmpty(), (_a = slots["list-footer"]) == null ? void 0 : _a.call(slots)])];
  8370. }
  8371. });
  8372. };
  8373. const renderDisabledTab = () => {
  8374. const {
  8375. disabledCoupons
  8376. } = props;
  8377. const count = props.showCount ? ` (${disabledCoupons.length})` : "";
  8378. const title = (props.disabledTitle || t$8("disabled")) + count;
  8379. return vue.createVNode(Tab, {
  8380. "title": title
  8381. }, {
  8382. default: () => {
  8383. var _a;
  8384. return [vue.createVNode("div", {
  8385. "class": bem$D("list", {
  8386. "with-bottom": props.showCloseButton
  8387. }),
  8388. "style": {
  8389. height: `${listHeight.value}px`
  8390. }
  8391. }, [disabledCoupons.map((coupon) => vue.createVNode(Coupon, {
  8392. "disabled": true,
  8393. "key": coupon.id,
  8394. "coupon": coupon,
  8395. "currency": props.currency
  8396. }, null)), !disabledCoupons.length && renderEmpty(), (_a = slots["disabled-list-footer"]) == null ? void 0 : _a.call(slots)])];
  8397. }
  8398. });
  8399. };
  8400. vue.watch(() => props.code, (value) => {
  8401. currentCode.value = value;
  8402. });
  8403. vue.watch(windowHeight, updateListHeight);
  8404. vue.watch(currentCode, (value) => emit("update:code", value));
  8405. vue.watch(() => props.displayedCouponIndex, scrollToCoupon);
  8406. vue.onMounted(() => {
  8407. updateListHeight();
  8408. scrollToCoupon(props.displayedCouponIndex);
  8409. });
  8410. return () => vue.createVNode("div", {
  8411. "ref": root,
  8412. "class": bem$D()
  8413. }, [renderExchangeBar(), vue.createVNode(Tabs, {
  8414. "active": activeTab.value,
  8415. "onUpdate:active": ($event) => activeTab.value = $event,
  8416. "class": bem$D("tab")
  8417. }, {
  8418. default: () => [renderCouponTab(), renderDisabledTab()]
  8419. }), vue.createVNode("div", {
  8420. "class": bem$D("bottom")
  8421. }, [vue.withDirectives(vue.createVNode(Button, {
  8422. "round": true,
  8423. "block": true,
  8424. "type": "danger",
  8425. "class": bem$D("close"),
  8426. "text": props.closeButtonText || t$8("close"),
  8427. "onClick": () => emit("change", -1)
  8428. }, null), [[vue.vShow, props.showCloseButton]])])]);
  8429. }
  8430. });
  8431. const CouponList = withInstall(stdin_default$K);
  8432. const [name$D] = createNamespace("time-picker");
  8433. var stdin_default$J = vue.defineComponent({
  8434. name: name$D,
  8435. props: extend({}, sharedProps, {
  8436. minHour: makeNumericProp(0),
  8437. maxHour: makeNumericProp(23),
  8438. minMinute: makeNumericProp(0),
  8439. maxMinute: makeNumericProp(59),
  8440. modelValue: String
  8441. }),
  8442. emits: ["confirm", "cancel", "change", "update:modelValue"],
  8443. setup(props, {
  8444. emit,
  8445. slots
  8446. }) {
  8447. const formatValue2 = (value) => {
  8448. const {
  8449. minHour,
  8450. maxHour,
  8451. maxMinute,
  8452. minMinute
  8453. } = props;
  8454. if (!value) {
  8455. value = `${padZero(minHour)}:${padZero(minMinute)}`;
  8456. }
  8457. let [hour, minute] = value.split(":");
  8458. hour = padZero(clamp(+hour, +minHour, +maxHour));
  8459. minute = padZero(clamp(+minute, +minMinute, +maxMinute));
  8460. return `${hour}:${minute}`;
  8461. };
  8462. const picker = vue.ref();
  8463. const currentDate = vue.ref(formatValue2(props.modelValue));
  8464. const ranges = vue.computed(() => [{
  8465. type: "hour",
  8466. range: [+props.minHour, +props.maxHour]
  8467. }, {
  8468. type: "minute",
  8469. range: [+props.minMinute, +props.maxMinute]
  8470. }]);
  8471. const originColumns = vue.computed(() => ranges.value.map(({
  8472. type,
  8473. range: rangeArr
  8474. }) => {
  8475. let values = times(rangeArr[1] - rangeArr[0] + 1, (index) => padZero(rangeArr[0] + index));
  8476. if (props.filter) {
  8477. values = props.filter(type, values);
  8478. }
  8479. return {
  8480. type,
  8481. values
  8482. };
  8483. }));
  8484. const columns = vue.computed(() => originColumns.value.map((column) => ({
  8485. values: column.values.map((value) => props.formatter(column.type, value))
  8486. })));
  8487. const updateColumnValue = () => {
  8488. const pair = currentDate.value.split(":");
  8489. const values = [props.formatter("hour", pair[0]), props.formatter("minute", pair[1])];
  8490. vue.nextTick(() => {
  8491. var _a;
  8492. (_a = picker.value) == null ? void 0 : _a.setValues(values);
  8493. });
  8494. };
  8495. const updateInnerValue = () => {
  8496. const [hourIndex, minuteIndex] = picker.value.getIndexes();
  8497. const [hourColumn, minuteColumn] = originColumns.value;
  8498. const hour = hourColumn.values[hourIndex] || hourColumn.values[0];
  8499. const minute = minuteColumn.values[minuteIndex] || minuteColumn.values[0];
  8500. currentDate.value = formatValue2(`${hour}:${minute}`);
  8501. updateColumnValue();
  8502. };
  8503. const onConfirm = () => emit("confirm", currentDate.value);
  8504. const onCancel = () => emit("cancel");
  8505. const onChange = () => {
  8506. updateInnerValue();
  8507. vue.nextTick(() => {
  8508. vue.nextTick(() => emit("change", currentDate.value));
  8509. });
  8510. };
  8511. vue.onMounted(() => {
  8512. updateColumnValue();
  8513. vue.nextTick(updateInnerValue);
  8514. });
  8515. vue.watch(columns, updateColumnValue);
  8516. vue.watch(() => [props.filter, props.maxHour, props.minMinute, props.maxMinute], updateInnerValue);
  8517. vue.watch(() => props.minHour, () => {
  8518. vue.nextTick(updateInnerValue);
  8519. });
  8520. vue.watch(currentDate, (value) => emit("update:modelValue", value));
  8521. vue.watch(() => props.modelValue, (value) => {
  8522. value = formatValue2(value);
  8523. if (value !== currentDate.value) {
  8524. currentDate.value = value;
  8525. updateColumnValue();
  8526. }
  8527. });
  8528. useExpose({
  8529. getPicker: () => picker.value && proxyPickerMethods(picker.value, updateInnerValue)
  8530. });
  8531. return () => vue.createVNode(Picker, vue.mergeProps({
  8532. "ref": picker,
  8533. "columns": columns.value,
  8534. "onChange": onChange,
  8535. "onCancel": onCancel,
  8536. "onConfirm": onConfirm
  8537. }, pick(props, pickerInheritKeys)), slots);
  8538. }
  8539. });
  8540. const currentYear = new Date().getFullYear();
  8541. const [name$C] = createNamespace("date-picker");
  8542. var stdin_default$I = vue.defineComponent({
  8543. name: name$C,
  8544. props: extend({}, sharedProps, {
  8545. type: makeStringProp("datetime"),
  8546. modelValue: Date,
  8547. minDate: {
  8548. type: Date,
  8549. default: () => new Date(currentYear - 10, 0, 1),
  8550. validator: isDate
  8551. },
  8552. maxDate: {
  8553. type: Date,
  8554. default: () => new Date(currentYear + 10, 11, 31),
  8555. validator: isDate
  8556. }
  8557. }),
  8558. emits: ["confirm", "cancel", "change", "update:modelValue"],
  8559. setup(props, {
  8560. emit,
  8561. slots
  8562. }) {
  8563. const formatValue2 = (value) => {
  8564. if (isDate(value)) {
  8565. const timestamp = clamp(value.getTime(), props.minDate.getTime(), props.maxDate.getTime());
  8566. return new Date(timestamp);
  8567. }
  8568. return void 0;
  8569. };
  8570. const picker = vue.ref();
  8571. const currentDate = vue.ref(formatValue2(props.modelValue));
  8572. const getBoundary = (type, value) => {
  8573. const boundary = props[`${type}Date`];
  8574. const year = boundary.getFullYear();
  8575. let month = 1;
  8576. let date = 1;
  8577. let hour = 0;
  8578. let minute = 0;
  8579. if (type === "max") {
  8580. month = 12;
  8581. date = getMonthEndDay(value.getFullYear(), value.getMonth() + 1);
  8582. hour = 23;
  8583. minute = 59;
  8584. }
  8585. if (value.getFullYear() === year) {
  8586. month = boundary.getMonth() + 1;
  8587. if (value.getMonth() + 1 === month) {
  8588. date = boundary.getDate();
  8589. if (value.getDate() === date) {
  8590. hour = boundary.getHours();
  8591. if (value.getHours() === hour) {
  8592. minute = boundary.getMinutes();
  8593. }
  8594. }
  8595. }
  8596. }
  8597. return {
  8598. [`${type}Year`]: year,
  8599. [`${type}Month`]: month,
  8600. [`${type}Date`]: date,
  8601. [`${type}Hour`]: hour,
  8602. [`${type}Minute`]: minute
  8603. };
  8604. };
  8605. const ranges = vue.computed(() => {
  8606. const {
  8607. maxYear,
  8608. maxDate,
  8609. maxMonth,
  8610. maxHour,
  8611. maxMinute
  8612. } = getBoundary("max", currentDate.value || props.minDate);
  8613. const {
  8614. minYear,
  8615. minDate,
  8616. minMonth,
  8617. minHour,
  8618. minMinute
  8619. } = getBoundary("min", currentDate.value || props.minDate);
  8620. let result = [{
  8621. type: "year",
  8622. range: [minYear, maxYear]
  8623. }, {
  8624. type: "month",
  8625. range: [minMonth, maxMonth]
  8626. }, {
  8627. type: "day",
  8628. range: [minDate, maxDate]
  8629. }, {
  8630. type: "hour",
  8631. range: [minHour, maxHour]
  8632. }, {
  8633. type: "minute",
  8634. range: [minMinute, maxMinute]
  8635. }];
  8636. switch (props.type) {
  8637. case "date":
  8638. result = result.slice(0, 3);
  8639. break;
  8640. case "year-month":
  8641. result = result.slice(0, 2);
  8642. break;
  8643. case "month-day":
  8644. result = result.slice(1, 3);
  8645. break;
  8646. case "datehour":
  8647. result = result.slice(0, 4);
  8648. break;
  8649. }
  8650. if (props.columnsOrder) {
  8651. const columnsOrder = props.columnsOrder.concat(result.map((column) => column.type));
  8652. result.sort((a, b) => columnsOrder.indexOf(a.type) - columnsOrder.indexOf(b.type));
  8653. }
  8654. return result;
  8655. });
  8656. const originColumns = vue.computed(() => ranges.value.map(({
  8657. type,
  8658. range: rangeArr
  8659. }) => {
  8660. let values = times(rangeArr[1] - rangeArr[0] + 1, (index) => padZero(rangeArr[0] + index));
  8661. if (props.filter) {
  8662. values = props.filter(type, values);
  8663. }
  8664. return {
  8665. type,
  8666. values
  8667. };
  8668. }));
  8669. const columns = vue.computed(() => originColumns.value.map((column) => ({
  8670. values: column.values.map((value) => props.formatter(column.type, value))
  8671. })));
  8672. const updateColumnValue = () => {
  8673. const value = currentDate.value || props.minDate;
  8674. const {
  8675. formatter
  8676. } = props;
  8677. const values = originColumns.value.map((column) => {
  8678. switch (column.type) {
  8679. case "year":
  8680. return formatter("year", `${value.getFullYear()}`);
  8681. case "month":
  8682. return formatter("month", padZero(value.getMonth() + 1));
  8683. case "day":
  8684. return formatter("day", padZero(value.getDate()));
  8685. case "hour":
  8686. return formatter("hour", padZero(value.getHours()));
  8687. case "minute":
  8688. return formatter("minute", padZero(value.getMinutes()));
  8689. default:
  8690. return "";
  8691. }
  8692. });
  8693. vue.nextTick(() => {
  8694. var _a;
  8695. (_a = picker.value) == null ? void 0 : _a.setValues(values);
  8696. });
  8697. };
  8698. const updateInnerValue = () => {
  8699. const {
  8700. type
  8701. } = props;
  8702. const indexes = picker.value.getIndexes();
  8703. const getValue = (type2) => {
  8704. let index = 0;
  8705. originColumns.value.forEach((column, columnIndex) => {
  8706. if (type2 === column.type) {
  8707. index = columnIndex;
  8708. }
  8709. });
  8710. const {
  8711. values
  8712. } = originColumns.value[index];
  8713. return getTrueValue(values[indexes[index]]);
  8714. };
  8715. let year;
  8716. let month;
  8717. let day;
  8718. if (type === "month-day") {
  8719. year = (currentDate.value || props.minDate).getFullYear();
  8720. month = getValue("month");
  8721. day = getValue("day");
  8722. } else {
  8723. year = getValue("year");
  8724. month = getValue("month");
  8725. day = type === "year-month" ? 1 : getValue("day");
  8726. }
  8727. const maxDay = getMonthEndDay(year, month);
  8728. day = day > maxDay ? maxDay : day;
  8729. let hour = 0;
  8730. let minute = 0;
  8731. if (type === "datehour") {
  8732. hour = getValue("hour");
  8733. }
  8734. if (type === "datetime") {
  8735. hour = getValue("hour");
  8736. minute = getValue("minute");
  8737. }
  8738. const value = new Date(year, month - 1, day, hour, minute);
  8739. currentDate.value = formatValue2(value);
  8740. };
  8741. const onConfirm = () => {
  8742. emit("update:modelValue", currentDate.value);
  8743. emit("confirm", currentDate.value);
  8744. };
  8745. const onCancel = () => emit("cancel");
  8746. const onChange = () => {
  8747. updateInnerValue();
  8748. vue.nextTick(() => {
  8749. updateInnerValue();
  8750. vue.nextTick(() => emit("change", currentDate.value));
  8751. });
  8752. };
  8753. vue.onMounted(() => {
  8754. updateColumnValue();
  8755. vue.nextTick(updateInnerValue);
  8756. });
  8757. vue.watch(columns, updateColumnValue);
  8758. vue.watch(currentDate, (value, oldValue) => emit("update:modelValue", oldValue ? value : null));
  8759. vue.watch(() => [props.filter, props.minDate, props.maxDate], () => {
  8760. vue.nextTick(updateInnerValue);
  8761. });
  8762. vue.watch(() => props.modelValue, (value) => {
  8763. var _a;
  8764. value = formatValue2(value);
  8765. if (value && value.valueOf() !== ((_a = currentDate.value) == null ? void 0 : _a.valueOf())) {
  8766. currentDate.value = value;
  8767. }
  8768. });
  8769. useExpose({
  8770. getPicker: () => picker.value && proxyPickerMethods(picker.value, updateInnerValue)
  8771. });
  8772. return () => vue.createVNode(Picker, vue.mergeProps({
  8773. "ref": picker,
  8774. "columns": columns.value,
  8775. "onChange": onChange,
  8776. "onCancel": onCancel,
  8777. "onConfirm": onConfirm
  8778. }, pick(props, pickerInheritKeys)), slots);
  8779. }
  8780. });
  8781. const [name$B, bem$C] = createNamespace("datetime-picker");
  8782. const timePickerPropKeys = Object.keys(stdin_default$J.props);
  8783. const datePickerPropKeys = Object.keys(stdin_default$I.props);
  8784. const datetimePickerProps = extend({}, stdin_default$J.props, stdin_default$I.props, {
  8785. modelValue: [String, Date]
  8786. });
  8787. var stdin_default$H = vue.defineComponent({
  8788. name: name$B,
  8789. props: datetimePickerProps,
  8790. setup(props, {
  8791. attrs,
  8792. slots
  8793. }) {
  8794. const root = vue.ref();
  8795. useExpose({
  8796. getPicker: () => {
  8797. var _a;
  8798. return (_a = root.value) == null ? void 0 : _a.getPicker();
  8799. }
  8800. });
  8801. return () => {
  8802. const isTimePicker = props.type === "time";
  8803. const Component = isTimePicker ? stdin_default$J : stdin_default$I;
  8804. const inheritProps = pick(props, isTimePicker ? timePickerPropKeys : datePickerPropKeys);
  8805. return vue.createVNode(Component, vue.mergeProps({
  8806. "ref": root,
  8807. "class": bem$C()
  8808. }, inheritProps, attrs), slots);
  8809. };
  8810. }
  8811. });
  8812. const DatetimePicker = withInstall(stdin_default$H);
  8813. const [name$A, bem$B, t$7] = createNamespace("dialog");
  8814. const dialogProps = extend({}, popupSharedProps, {
  8815. title: String,
  8816. theme: String,
  8817. width: numericProp,
  8818. message: [String, Function],
  8819. callback: Function,
  8820. allowHtml: Boolean,
  8821. className: unknownProp,
  8822. transition: makeStringProp("van-dialog-bounce"),
  8823. messageAlign: String,
  8824. closeOnPopstate: truthProp,
  8825. showCancelButton: Boolean,
  8826. cancelButtonText: String,
  8827. cancelButtonColor: String,
  8828. cancelButtonDisabled: Boolean,
  8829. confirmButtonText: String,
  8830. confirmButtonColor: String,
  8831. confirmButtonDisabled: Boolean,
  8832. showConfirmButton: truthProp,
  8833. closeOnClickOverlay: Boolean
  8834. });
  8835. const popupInheritKeys$1 = [...popupSharedPropKeys, "transition", "closeOnPopstate"];
  8836. var stdin_default$G = vue.defineComponent({
  8837. name: name$A,
  8838. props: dialogProps,
  8839. emits: ["confirm", "cancel", "keydown", "update:show"],
  8840. setup(props, {
  8841. emit,
  8842. slots
  8843. }) {
  8844. const root = vue.ref();
  8845. const loading = vue.reactive({
  8846. confirm: false,
  8847. cancel: false
  8848. });
  8849. const updateShow = (value) => emit("update:show", value);
  8850. const close = (action) => {
  8851. var _a;
  8852. updateShow(false);
  8853. (_a = props.callback) == null ? void 0 : _a.call(props, action);
  8854. };
  8855. const getActionHandler = (action) => () => {
  8856. if (!props.show) {
  8857. return;
  8858. }
  8859. emit(action);
  8860. if (props.beforeClose) {
  8861. loading[action] = true;
  8862. callInterceptor(props.beforeClose, {
  8863. args: [action],
  8864. done() {
  8865. close(action);
  8866. loading[action] = false;
  8867. },
  8868. canceled() {
  8869. loading[action] = false;
  8870. }
  8871. });
  8872. } else {
  8873. close(action);
  8874. }
  8875. };
  8876. const onCancel = getActionHandler("cancel");
  8877. const onConfirm = getActionHandler("confirm");
  8878. const onKeydown = vue.withKeys((event) => {
  8879. var _a, _b;
  8880. if (event.target !== ((_b = (_a = root.value) == null ? void 0 : _a.popupRef) == null ? void 0 : _b.value)) {
  8881. return;
  8882. }
  8883. const onEventType = {
  8884. Enter: props.showConfirmButton ? onConfirm : noop,
  8885. Escape: props.showCancelButton ? onCancel : noop
  8886. };
  8887. onEventType[event.key]();
  8888. emit("keydown", event);
  8889. }, ["enter", "esc"]);
  8890. const renderTitle = () => {
  8891. const title = slots.title ? slots.title() : props.title;
  8892. if (title) {
  8893. return vue.createVNode("div", {
  8894. "class": bem$B("header", {
  8895. isolated: !props.message && !slots.default
  8896. })
  8897. }, [title]);
  8898. }
  8899. };
  8900. const renderMessage = (hasTitle) => {
  8901. const {
  8902. message,
  8903. allowHtml,
  8904. messageAlign
  8905. } = props;
  8906. const classNames = bem$B("message", {
  8907. "has-title": hasTitle,
  8908. [messageAlign]: messageAlign
  8909. });
  8910. const content = isFunction(message) ? message() : message;
  8911. if (allowHtml && typeof content === "string") {
  8912. return vue.createVNode("div", {
  8913. "class": classNames,
  8914. "innerHTML": content
  8915. }, null);
  8916. }
  8917. return vue.createVNode("div", {
  8918. "class": classNames
  8919. }, [content]);
  8920. };
  8921. const renderContent = () => {
  8922. if (slots.default) {
  8923. return vue.createVNode("div", {
  8924. "class": bem$B("content")
  8925. }, [slots.default()]);
  8926. }
  8927. const {
  8928. title,
  8929. message,
  8930. allowHtml
  8931. } = props;
  8932. if (message) {
  8933. const hasTitle = !!(title || slots.title);
  8934. return vue.createVNode("div", {
  8935. "key": allowHtml ? 1 : 0,
  8936. "class": bem$B("content", {
  8937. isolated: !hasTitle
  8938. })
  8939. }, [renderMessage(hasTitle)]);
  8940. }
  8941. };
  8942. const renderButtons = () => vue.createVNode("div", {
  8943. "class": [BORDER_TOP, bem$B("footer")]
  8944. }, [props.showCancelButton && vue.createVNode(Button, {
  8945. "size": "large",
  8946. "text": props.cancelButtonText || t$7("cancel"),
  8947. "class": bem$B("cancel"),
  8948. "style": {
  8949. color: props.cancelButtonColor
  8950. },
  8951. "loading": loading.cancel,
  8952. "disabled": props.cancelButtonDisabled,
  8953. "onClick": onCancel
  8954. }, null), props.showConfirmButton && vue.createVNode(Button, {
  8955. "size": "large",
  8956. "text": props.confirmButtonText || t$7("confirm"),
  8957. "class": [bem$B("confirm"), {
  8958. [BORDER_LEFT]: props.showCancelButton
  8959. }],
  8960. "style": {
  8961. color: props.confirmButtonColor
  8962. },
  8963. "loading": loading.confirm,
  8964. "disabled": props.confirmButtonDisabled,
  8965. "onClick": onConfirm
  8966. }, null)]);
  8967. const renderRoundButtons = () => vue.createVNode(ActionBar, {
  8968. "class": bem$B("footer")
  8969. }, {
  8970. default: () => [props.showCancelButton && vue.createVNode(ActionBarButton, {
  8971. "type": "warning",
  8972. "text": props.cancelButtonText || t$7("cancel"),
  8973. "class": bem$B("cancel"),
  8974. "color": props.cancelButtonColor,
  8975. "loading": loading.cancel,
  8976. "disabled": props.cancelButtonDisabled,
  8977. "onClick": onCancel
  8978. }, null), props.showConfirmButton && vue.createVNode(ActionBarButton, {
  8979. "type": "danger",
  8980. "text": props.confirmButtonText || t$7("confirm"),
  8981. "class": bem$B("confirm"),
  8982. "color": props.confirmButtonColor,
  8983. "loading": loading.confirm,
  8984. "disabled": props.confirmButtonDisabled,
  8985. "onClick": onConfirm
  8986. }, null)]
  8987. });
  8988. const renderFooter = () => {
  8989. if (slots.footer) {
  8990. return slots.footer();
  8991. }
  8992. return props.theme === "round-button" ? renderRoundButtons() : renderButtons();
  8993. };
  8994. return () => {
  8995. const {
  8996. width,
  8997. title,
  8998. theme,
  8999. message,
  9000. className
  9001. } = props;
  9002. return vue.createVNode(Popup, vue.mergeProps({
  9003. "ref": root,
  9004. "role": "dialog",
  9005. "class": [bem$B([theme]), className],
  9006. "style": {
  9007. width: addUnit(width)
  9008. },
  9009. "tabindex": 0,
  9010. "aria-labelledby": title || message,
  9011. "onKeydown": onKeydown,
  9012. "onUpdate:show": updateShow
  9013. }, pick(props, popupInheritKeys$1)), {
  9014. default: () => [renderTitle(), renderContent(), renderFooter()]
  9015. });
  9016. };
  9017. }
  9018. });
  9019. let instance$2;
  9020. function initInstance$2() {
  9021. const Wrapper = {
  9022. setup() {
  9023. const {
  9024. state,
  9025. toggle
  9026. } = usePopupState();
  9027. return () => vue.createVNode(stdin_default$G, vue.mergeProps(state, {
  9028. "onUpdate:show": toggle
  9029. }), null);
  9030. }
  9031. };
  9032. ({
  9033. instance: instance$2
  9034. } = mountComponent(Wrapper));
  9035. }
  9036. function Dialog(options) {
  9037. if (!inBrowser) {
  9038. return Promise.resolve();
  9039. }
  9040. return new Promise((resolve, reject) => {
  9041. if (!instance$2) {
  9042. initInstance$2();
  9043. }
  9044. instance$2.open(extend({}, Dialog.currentOptions, options, {
  9045. callback: (action) => {
  9046. (action === "confirm" ? resolve : reject)(action);
  9047. }
  9048. }));
  9049. });
  9050. }
  9051. Dialog.defaultOptions = {
  9052. title: "",
  9053. width: "",
  9054. theme: null,
  9055. message: "",
  9056. overlay: true,
  9057. callback: null,
  9058. teleport: "body",
  9059. className: "",
  9060. allowHtml: false,
  9061. lockScroll: true,
  9062. transition: void 0,
  9063. beforeClose: null,
  9064. overlayClass: "",
  9065. overlayStyle: void 0,
  9066. messageAlign: "",
  9067. cancelButtonText: "",
  9068. cancelButtonColor: null,
  9069. cancelButtonDisabled: false,
  9070. confirmButtonText: "",
  9071. confirmButtonColor: null,
  9072. confirmButtonDisabled: false,
  9073. showConfirmButton: true,
  9074. showCancelButton: false,
  9075. closeOnPopstate: true,
  9076. closeOnClickOverlay: false
  9077. };
  9078. Dialog.currentOptions = extend({}, Dialog.defaultOptions);
  9079. Dialog.alert = Dialog;
  9080. Dialog.confirm = (options) => Dialog(extend({
  9081. showCancelButton: true
  9082. }, options));
  9083. Dialog.close = () => {
  9084. if (instance$2) {
  9085. instance$2.toggle(false);
  9086. }
  9087. };
  9088. Dialog.setDefaultOptions = (options) => {
  9089. extend(Dialog.currentOptions, options);
  9090. };
  9091. Dialog.resetDefaultOptions = () => {
  9092. Dialog.currentOptions = extend({}, Dialog.defaultOptions);
  9093. };
  9094. Dialog.Component = withInstall(stdin_default$G);
  9095. Dialog.install = (app) => {
  9096. app.use(Dialog.Component);
  9097. app.config.globalProperties.$dialog = Dialog;
  9098. };
  9099. const [name$z, bem$A] = createNamespace("divider");
  9100. const dividerProps = {
  9101. dashed: Boolean,
  9102. hairline: truthProp,
  9103. contentPosition: makeStringProp("center")
  9104. };
  9105. var stdin_default$F = vue.defineComponent({
  9106. name: name$z,
  9107. props: dividerProps,
  9108. setup(props, {
  9109. slots
  9110. }) {
  9111. return () => {
  9112. var _a;
  9113. return vue.createVNode("div", {
  9114. "role": "separator",
  9115. "class": bem$A({
  9116. dashed: props.dashed,
  9117. hairline: props.hairline,
  9118. [`content-${props.contentPosition}`]: !!slots.default
  9119. })
  9120. }, [(_a = slots.default) == null ? void 0 : _a.call(slots)]);
  9121. };
  9122. }
  9123. });
  9124. const Divider = withInstall(stdin_default$F);
  9125. const [name$y, bem$z] = createNamespace("dropdown-menu");
  9126. const dropdownMenuProps = {
  9127. overlay: truthProp,
  9128. zIndex: numericProp,
  9129. duration: makeNumericProp(0.2),
  9130. direction: makeStringProp("down"),
  9131. activeColor: String,
  9132. closeOnClickOutside: truthProp,
  9133. closeOnClickOverlay: truthProp
  9134. };
  9135. const DROPDOWN_KEY = Symbol(name$y);
  9136. var stdin_default$E = vue.defineComponent({
  9137. name: name$y,
  9138. props: dropdownMenuProps,
  9139. setup(props, {
  9140. slots
  9141. }) {
  9142. const id = useId();
  9143. const root = vue.ref();
  9144. const barRef = vue.ref();
  9145. const offset = vue.ref(0);
  9146. const {
  9147. children,
  9148. linkChildren
  9149. } = use.useChildren(DROPDOWN_KEY);
  9150. const scrollParent = use.useScrollParent(root);
  9151. const opened = vue.computed(() => children.some((item) => item.state.showWrapper));
  9152. const barStyle = vue.computed(() => {
  9153. if (opened.value && isDef(props.zIndex)) {
  9154. return {
  9155. zIndex: +props.zIndex + 1
  9156. };
  9157. }
  9158. });
  9159. const onClickAway = () => {
  9160. if (props.closeOnClickOutside) {
  9161. children.forEach((item) => {
  9162. item.toggle(false);
  9163. });
  9164. }
  9165. };
  9166. const updateOffset = () => {
  9167. if (barRef.value) {
  9168. const rect = use.useRect(barRef);
  9169. if (props.direction === "down") {
  9170. offset.value = rect.bottom;
  9171. } else {
  9172. offset.value = windowHeight.value - rect.top;
  9173. }
  9174. }
  9175. };
  9176. const onScroll = () => {
  9177. if (opened.value) {
  9178. updateOffset();
  9179. }
  9180. };
  9181. const toggleItem = (active) => {
  9182. children.forEach((item, index) => {
  9183. if (index === active) {
  9184. updateOffset();
  9185. item.toggle();
  9186. } else if (item.state.showPopup) {
  9187. item.toggle(false, {
  9188. immediate: true
  9189. });
  9190. }
  9191. });
  9192. };
  9193. const renderTitle = (item, index) => {
  9194. const {
  9195. showPopup
  9196. } = item.state;
  9197. const {
  9198. disabled,
  9199. titleClass
  9200. } = item;
  9201. return vue.createVNode("div", {
  9202. "id": `${id}-${index}`,
  9203. "role": "button",
  9204. "tabindex": disabled ? void 0 : 0,
  9205. "class": [bem$z("item", {
  9206. disabled
  9207. }), {
  9208. [HAPTICS_FEEDBACK]: !disabled
  9209. }],
  9210. "onClick": () => {
  9211. if (!disabled) {
  9212. toggleItem(index);
  9213. }
  9214. }
  9215. }, [vue.createVNode("span", {
  9216. "class": [bem$z("title", {
  9217. down: showPopup === (props.direction === "down"),
  9218. active: showPopup
  9219. }), titleClass],
  9220. "style": {
  9221. color: showPopup ? props.activeColor : ""
  9222. }
  9223. }, [vue.createVNode("div", {
  9224. "class": "van-ellipsis"
  9225. }, [item.renderTitle()])])]);
  9226. };
  9227. linkChildren({
  9228. id,
  9229. props,
  9230. offset
  9231. });
  9232. use.useClickAway(root, onClickAway);
  9233. use.useEventListener("scroll", onScroll, {
  9234. target: scrollParent,
  9235. passive: true
  9236. });
  9237. return () => {
  9238. var _a;
  9239. return vue.createVNode("div", {
  9240. "ref": root,
  9241. "class": bem$z()
  9242. }, [vue.createVNode("div", {
  9243. "ref": barRef,
  9244. "style": barStyle.value,
  9245. "class": bem$z("bar", {
  9246. opened: opened.value
  9247. })
  9248. }, [children.map(renderTitle)]), (_a = slots.default) == null ? void 0 : _a.call(slots)]);
  9249. };
  9250. }
  9251. });
  9252. const [name$x, bem$y] = createNamespace("dropdown-item");
  9253. const dropdownItemProps = {
  9254. title: String,
  9255. options: makeArrayProp(),
  9256. disabled: Boolean,
  9257. teleport: [String, Object],
  9258. lazyRender: truthProp,
  9259. modelValue: unknownProp,
  9260. titleClass: unknownProp
  9261. };
  9262. var stdin_default$D = vue.defineComponent({
  9263. name: name$x,
  9264. props: dropdownItemProps,
  9265. emits: ["open", "opened", "close", "closed", "change", "update:modelValue"],
  9266. setup(props, {
  9267. emit,
  9268. slots
  9269. }) {
  9270. const state = vue.reactive({
  9271. showPopup: false,
  9272. transition: true,
  9273. showWrapper: false
  9274. });
  9275. const {
  9276. parent,
  9277. index
  9278. } = use.useParent(DROPDOWN_KEY);
  9279. if (!parent) {
  9280. if (process.env.NODE_ENV !== "production") {
  9281. console.error("[Vant] <DropdownItem> must be a child component of <DropdownMenu>.");
  9282. }
  9283. return;
  9284. }
  9285. const getEmitter = (name2) => () => emit(name2);
  9286. const onOpen = getEmitter("open");
  9287. const onClose = getEmitter("close");
  9288. const onOpened = getEmitter("opened");
  9289. const onClosed = () => {
  9290. state.showWrapper = false;
  9291. emit("closed");
  9292. };
  9293. const onClickWrapper = (event) => {
  9294. if (props.teleport) {
  9295. event.stopPropagation();
  9296. }
  9297. };
  9298. const toggle = (show = !state.showPopup, options = {}) => {
  9299. if (show === state.showPopup) {
  9300. return;
  9301. }
  9302. state.showPopup = show;
  9303. state.transition = !options.immediate;
  9304. if (show) {
  9305. state.showWrapper = true;
  9306. }
  9307. };
  9308. const renderTitle = () => {
  9309. if (slots.title) {
  9310. return slots.title();
  9311. }
  9312. if (props.title) {
  9313. return props.title;
  9314. }
  9315. const match = props.options.find((option) => option.value === props.modelValue);
  9316. return match ? match.text : "";
  9317. };
  9318. const renderOption = (option) => {
  9319. const {
  9320. activeColor
  9321. } = parent.props;
  9322. const active = option.value === props.modelValue;
  9323. const onClick = () => {
  9324. state.showPopup = false;
  9325. if (option.value !== props.modelValue) {
  9326. emit("update:modelValue", option.value);
  9327. emit("change", option.value);
  9328. }
  9329. };
  9330. const renderIcon = () => {
  9331. if (active) {
  9332. return vue.createVNode(Icon, {
  9333. "class": bem$y("icon"),
  9334. "color": activeColor,
  9335. "name": "success"
  9336. }, null);
  9337. }
  9338. };
  9339. return vue.createVNode(Cell, {
  9340. "role": "menuitem",
  9341. "key": option.value,
  9342. "icon": option.icon,
  9343. "title": option.text,
  9344. "class": bem$y("option", {
  9345. active
  9346. }),
  9347. "style": {
  9348. color: active ? activeColor : ""
  9349. },
  9350. "tabindex": active ? 0 : -1,
  9351. "clickable": true,
  9352. "onClick": onClick
  9353. }, {
  9354. value: renderIcon
  9355. });
  9356. };
  9357. const renderContent = () => {
  9358. const {
  9359. offset
  9360. } = parent;
  9361. const {
  9362. zIndex,
  9363. overlay,
  9364. duration,
  9365. direction,
  9366. closeOnClickOverlay
  9367. } = parent.props;
  9368. const style = getZIndexStyle(zIndex);
  9369. if (direction === "down") {
  9370. style.top = `${offset.value}px`;
  9371. } else {
  9372. style.bottom = `${offset.value}px`;
  9373. }
  9374. return vue.withDirectives(vue.createVNode("div", {
  9375. "style": style,
  9376. "class": bem$y([direction]),
  9377. "onClick": onClickWrapper
  9378. }, [vue.createVNode(Popup, {
  9379. "show": state.showPopup,
  9380. "onUpdate:show": ($event) => state.showPopup = $event,
  9381. "role": "menu",
  9382. "class": bem$y("content"),
  9383. "overlay": overlay,
  9384. "position": direction === "down" ? "top" : "bottom",
  9385. "duration": state.transition ? duration : 0,
  9386. "lazyRender": props.lazyRender,
  9387. "overlayStyle": {
  9388. position: "absolute"
  9389. },
  9390. "aria-labelledby": `${parent.id}-${index.value}`,
  9391. "closeOnClickOverlay": closeOnClickOverlay,
  9392. "onOpen": onOpen,
  9393. "onClose": onClose,
  9394. "onOpened": onOpened,
  9395. "onClosed": onClosed
  9396. }, {
  9397. default: () => {
  9398. var _a;
  9399. return [props.options.map(renderOption), (_a = slots.default) == null ? void 0 : _a.call(slots)];
  9400. }
  9401. })]), [[vue.vShow, state.showWrapper]]);
  9402. };
  9403. useExpose({
  9404. state,
  9405. toggle,
  9406. renderTitle
  9407. });
  9408. return () => {
  9409. if (props.teleport) {
  9410. return vue.createVNode(vue.Teleport, {
  9411. "to": props.teleport
  9412. }, {
  9413. default: () => [renderContent()]
  9414. });
  9415. }
  9416. return renderContent();
  9417. };
  9418. }
  9419. });
  9420. const DropdownItem = withInstall(stdin_default$D);
  9421. const DropdownMenu = withInstall(stdin_default$E);
  9422. const [name$w, bem$x] = createNamespace("grid");
  9423. const gridProps = {
  9424. square: Boolean,
  9425. center: truthProp,
  9426. border: truthProp,
  9427. gutter: numericProp,
  9428. reverse: Boolean,
  9429. iconSize: numericProp,
  9430. direction: String,
  9431. clickable: Boolean,
  9432. columnNum: makeNumericProp(4)
  9433. };
  9434. const GRID_KEY = Symbol(name$w);
  9435. var stdin_default$C = vue.defineComponent({
  9436. name: name$w,
  9437. props: gridProps,
  9438. setup(props, {
  9439. slots
  9440. }) {
  9441. const {
  9442. linkChildren
  9443. } = use.useChildren(GRID_KEY);
  9444. linkChildren({
  9445. props
  9446. });
  9447. return () => {
  9448. var _a;
  9449. return vue.createVNode("div", {
  9450. "style": {
  9451. paddingLeft: addUnit(props.gutter)
  9452. },
  9453. "class": [bem$x(), {
  9454. [BORDER_TOP]: props.border && !props.gutter
  9455. }]
  9456. }, [(_a = slots.default) == null ? void 0 : _a.call(slots)]);
  9457. };
  9458. }
  9459. });
  9460. const Grid = withInstall(stdin_default$C);
  9461. const [name$v, bem$w] = createNamespace("grid-item");
  9462. const gridItemProps = extend({}, routeProps, {
  9463. dot: Boolean,
  9464. text: String,
  9465. icon: String,
  9466. badge: numericProp,
  9467. iconColor: String,
  9468. iconPrefix: String,
  9469. badgeProps: Object
  9470. });
  9471. var stdin_default$B = vue.defineComponent({
  9472. name: name$v,
  9473. props: gridItemProps,
  9474. setup(props, {
  9475. slots
  9476. }) {
  9477. const {
  9478. parent,
  9479. index
  9480. } = use.useParent(GRID_KEY);
  9481. const route2 = useRoute();
  9482. if (!parent) {
  9483. if (process.env.NODE_ENV !== "production") {
  9484. console.error("[Vant] <GridItem> must be a child component of <Grid>.");
  9485. }
  9486. return;
  9487. }
  9488. const rootStyle = vue.computed(() => {
  9489. const {
  9490. square,
  9491. gutter,
  9492. columnNum
  9493. } = parent.props;
  9494. const percent = `${100 / +columnNum}%`;
  9495. const style = {
  9496. flexBasis: percent
  9497. };
  9498. if (square) {
  9499. style.paddingTop = percent;
  9500. } else if (gutter) {
  9501. const gutterValue = addUnit(gutter);
  9502. style.paddingRight = gutterValue;
  9503. if (index.value >= columnNum) {
  9504. style.marginTop = gutterValue;
  9505. }
  9506. }
  9507. return style;
  9508. });
  9509. const contentStyle = vue.computed(() => {
  9510. const {
  9511. square,
  9512. gutter
  9513. } = parent.props;
  9514. if (square && gutter) {
  9515. const gutterValue = addUnit(gutter);
  9516. return {
  9517. right: gutterValue,
  9518. bottom: gutterValue,
  9519. height: "auto"
  9520. };
  9521. }
  9522. });
  9523. const renderIcon = () => {
  9524. if (slots.icon) {
  9525. return vue.createVNode(Badge, vue.mergeProps({
  9526. "dot": props.dot,
  9527. "content": props.badge
  9528. }, props.badgeProps), {
  9529. default: slots.icon
  9530. });
  9531. }
  9532. if (props.icon) {
  9533. return vue.createVNode(Icon, {
  9534. "dot": props.dot,
  9535. "name": props.icon,
  9536. "size": parent.props.iconSize,
  9537. "badge": props.badge,
  9538. "class": bem$w("icon"),
  9539. "color": props.iconColor,
  9540. "badgeProps": props.badgeProps,
  9541. "classPrefix": props.iconPrefix
  9542. }, null);
  9543. }
  9544. };
  9545. const renderText = () => {
  9546. if (slots.text) {
  9547. return slots.text();
  9548. }
  9549. if (props.text) {
  9550. return vue.createVNode("span", {
  9551. "class": bem$w("text")
  9552. }, [props.text]);
  9553. }
  9554. };
  9555. const renderContent = () => {
  9556. if (slots.default) {
  9557. return slots.default();
  9558. }
  9559. return [renderIcon(), renderText()];
  9560. };
  9561. return () => {
  9562. const {
  9563. center,
  9564. border,
  9565. square,
  9566. gutter,
  9567. reverse,
  9568. direction,
  9569. clickable
  9570. } = parent.props;
  9571. const classes = [bem$w("content", [direction, {
  9572. center,
  9573. square,
  9574. reverse,
  9575. clickable,
  9576. surround: border && gutter
  9577. }]), {
  9578. [BORDER]: border
  9579. }];
  9580. return vue.createVNode("div", {
  9581. "class": [bem$w({
  9582. square
  9583. })],
  9584. "style": rootStyle.value
  9585. }, [vue.createVNode("div", {
  9586. "role": clickable ? "button" : void 0,
  9587. "class": classes,
  9588. "style": contentStyle.value,
  9589. "tabindex": clickable ? 0 : void 0,
  9590. "onClick": route2
  9591. }, [renderContent()])]);
  9592. };
  9593. }
  9594. });
  9595. const GridItem = withInstall(stdin_default$B);
  9596. const getDistance = (touches) => Math.sqrt((touches[0].clientX - touches[1].clientX) ** 2 + (touches[0].clientY - touches[1].clientY) ** 2);
  9597. const bem$v = createNamespace("image-preview")[1];
  9598. var stdin_default$A = vue.defineComponent({
  9599. props: {
  9600. src: String,
  9601. show: Boolean,
  9602. active: Number,
  9603. minZoom: makeRequiredProp(numericProp),
  9604. maxZoom: makeRequiredProp(numericProp),
  9605. rootWidth: makeRequiredProp(Number),
  9606. rootHeight: makeRequiredProp(Number)
  9607. },
  9608. emits: ["scale", "close"],
  9609. setup(props, {
  9610. emit,
  9611. slots
  9612. }) {
  9613. const state = vue.reactive({
  9614. scale: 1,
  9615. moveX: 0,
  9616. moveY: 0,
  9617. moving: false,
  9618. zooming: false,
  9619. imageRatio: 0,
  9620. displayWidth: 0,
  9621. displayHeight: 0
  9622. });
  9623. const touch = useTouch();
  9624. const swipeItem = vue.ref();
  9625. const vertical = vue.computed(() => {
  9626. const {
  9627. rootWidth,
  9628. rootHeight
  9629. } = props;
  9630. const rootRatio = rootHeight / rootWidth;
  9631. return state.imageRatio > rootRatio;
  9632. });
  9633. const imageStyle = vue.computed(() => {
  9634. const {
  9635. scale,
  9636. moveX,
  9637. moveY,
  9638. moving,
  9639. zooming
  9640. } = state;
  9641. const style = {
  9642. transitionDuration: zooming || moving ? "0s" : ".3s"
  9643. };
  9644. if (scale !== 1) {
  9645. const offsetX = moveX / scale;
  9646. const offsetY = moveY / scale;
  9647. style.transform = `scale(${scale}, ${scale}) translate(${offsetX}px, ${offsetY}px)`;
  9648. }
  9649. return style;
  9650. });
  9651. const maxMoveX = vue.computed(() => {
  9652. if (state.imageRatio) {
  9653. const {
  9654. rootWidth,
  9655. rootHeight
  9656. } = props;
  9657. const displayWidth = vertical.value ? rootHeight / state.imageRatio : rootWidth;
  9658. return Math.max(0, (state.scale * displayWidth - rootWidth) / 2);
  9659. }
  9660. return 0;
  9661. });
  9662. const maxMoveY = vue.computed(() => {
  9663. if (state.imageRatio) {
  9664. const {
  9665. rootWidth,
  9666. rootHeight
  9667. } = props;
  9668. const displayHeight = vertical.value ? rootHeight : rootWidth * state.imageRatio;
  9669. return Math.max(0, (state.scale * displayHeight - rootHeight) / 2);
  9670. }
  9671. return 0;
  9672. });
  9673. const setScale = (scale) => {
  9674. scale = clamp(scale, +props.minZoom, +props.maxZoom + 1);
  9675. if (scale !== state.scale) {
  9676. state.scale = scale;
  9677. emit("scale", {
  9678. scale,
  9679. index: props.active
  9680. });
  9681. }
  9682. };
  9683. const resetScale = () => {
  9684. setScale(1);
  9685. state.moveX = 0;
  9686. state.moveY = 0;
  9687. };
  9688. const toggleScale = () => {
  9689. const scale = state.scale > 1 ? 1 : 2;
  9690. setScale(scale);
  9691. state.moveX = 0;
  9692. state.moveY = 0;
  9693. };
  9694. let fingerNum;
  9695. let startMoveX;
  9696. let startMoveY;
  9697. let startScale;
  9698. let startDistance;
  9699. let doubleTapTimer;
  9700. let touchStartTime;
  9701. const onTouchStart = (event) => {
  9702. const {
  9703. touches
  9704. } = event;
  9705. const {
  9706. offsetX
  9707. } = touch;
  9708. touch.start(event);
  9709. fingerNum = touches.length;
  9710. startMoveX = state.moveX;
  9711. startMoveY = state.moveY;
  9712. touchStartTime = Date.now();
  9713. state.moving = fingerNum === 1 && state.scale !== 1;
  9714. state.zooming = fingerNum === 2 && !offsetX.value;
  9715. if (state.zooming) {
  9716. startScale = state.scale;
  9717. startDistance = getDistance(event.touches);
  9718. }
  9719. };
  9720. const onTouchMove = (event) => {
  9721. const {
  9722. touches
  9723. } = event;
  9724. touch.move(event);
  9725. if (state.moving || state.zooming) {
  9726. preventDefault(event, true);
  9727. }
  9728. if (state.moving) {
  9729. const {
  9730. deltaX,
  9731. deltaY
  9732. } = touch;
  9733. const moveX = deltaX.value + startMoveX;
  9734. const moveY = deltaY.value + startMoveY;
  9735. state.moveX = clamp(moveX, -maxMoveX.value, maxMoveX.value);
  9736. state.moveY = clamp(moveY, -maxMoveY.value, maxMoveY.value);
  9737. }
  9738. if (state.zooming && touches.length === 2) {
  9739. const distance = getDistance(touches);
  9740. const scale = startScale * distance / startDistance;
  9741. setScale(scale);
  9742. }
  9743. };
  9744. const checkTap = () => {
  9745. if (fingerNum > 1) {
  9746. return;
  9747. }
  9748. const {
  9749. offsetX,
  9750. offsetY
  9751. } = touch;
  9752. const deltaTime = Date.now() - touchStartTime;
  9753. const TAP_TIME = 250;
  9754. const TAP_OFFSET = 5;
  9755. if (offsetX.value < TAP_OFFSET && offsetY.value < TAP_OFFSET && deltaTime < TAP_TIME) {
  9756. if (doubleTapTimer) {
  9757. clearTimeout(doubleTapTimer);
  9758. doubleTapTimer = null;
  9759. toggleScale();
  9760. } else {
  9761. doubleTapTimer = setTimeout(() => {
  9762. emit("close");
  9763. doubleTapTimer = null;
  9764. }, TAP_TIME);
  9765. }
  9766. }
  9767. };
  9768. const onTouchEnd = (event) => {
  9769. let stopPropagation2 = false;
  9770. if (state.moving || state.zooming) {
  9771. stopPropagation2 = true;
  9772. if (state.moving && startMoveX === state.moveX && startMoveY === state.moveY) {
  9773. stopPropagation2 = false;
  9774. }
  9775. if (!event.touches.length) {
  9776. if (state.zooming) {
  9777. state.moveX = clamp(state.moveX, -maxMoveX.value, maxMoveX.value);
  9778. state.moveY = clamp(state.moveY, -maxMoveY.value, maxMoveY.value);
  9779. state.zooming = false;
  9780. }
  9781. state.moving = false;
  9782. startMoveX = 0;
  9783. startMoveY = 0;
  9784. startScale = 1;
  9785. if (state.scale < 1) {
  9786. resetScale();
  9787. }
  9788. if (state.scale > props.maxZoom) {
  9789. state.scale = +props.maxZoom;
  9790. }
  9791. }
  9792. }
  9793. preventDefault(event, stopPropagation2);
  9794. checkTap();
  9795. touch.reset();
  9796. };
  9797. const onLoad = (event) => {
  9798. const {
  9799. naturalWidth,
  9800. naturalHeight
  9801. } = event.target;
  9802. state.imageRatio = naturalHeight / naturalWidth;
  9803. };
  9804. vue.watch(() => props.active, resetScale);
  9805. vue.watch(() => props.show, (value) => {
  9806. if (!value) {
  9807. resetScale();
  9808. }
  9809. });
  9810. use.useEventListener("touchmove", onTouchMove, {
  9811. target: vue.computed(() => {
  9812. var _a;
  9813. return (_a = swipeItem.value) == null ? void 0 : _a.$el;
  9814. })
  9815. });
  9816. return () => {
  9817. const imageSlots = {
  9818. loading: () => vue.createVNode(Loading, {
  9819. "type": "spinner"
  9820. }, null)
  9821. };
  9822. return vue.createVNode(SwipeItem, {
  9823. "ref": swipeItem,
  9824. "class": bem$v("swipe-item"),
  9825. "onTouchstartPassive": onTouchStart,
  9826. "onTouchend": onTouchEnd,
  9827. "onTouchcancel": onTouchEnd
  9828. }, {
  9829. default: () => [slots.image ? vue.createVNode("div", {
  9830. "class": bem$v("image-wrap")
  9831. }, [slots.image({
  9832. src: props.src
  9833. })]) : vue.createVNode(Image$1, {
  9834. "src": props.src,
  9835. "fit": "contain",
  9836. "class": bem$v("image", {
  9837. vertical: vertical.value
  9838. }),
  9839. "style": imageStyle.value,
  9840. "onLoad": onLoad
  9841. }, imageSlots)]
  9842. });
  9843. };
  9844. }
  9845. });
  9846. const [name$u, bem$u] = createNamespace("image-preview");
  9847. const popupProps$1 = ["show", "transition", "overlayStyle", "closeOnPopstate"];
  9848. const imagePreviewProps = {
  9849. show: Boolean,
  9850. loop: truthProp,
  9851. images: makeArrayProp(),
  9852. minZoom: makeNumericProp(1 / 3),
  9853. maxZoom: makeNumericProp(3),
  9854. overlay: truthProp,
  9855. closeable: Boolean,
  9856. showIndex: truthProp,
  9857. className: unknownProp,
  9858. closeIcon: makeStringProp("clear"),
  9859. transition: String,
  9860. beforeClose: Function,
  9861. overlayClass: unknownProp,
  9862. overlayStyle: Object,
  9863. swipeDuration: makeNumericProp(300),
  9864. startPosition: makeNumericProp(0),
  9865. showIndicators: Boolean,
  9866. closeOnPopstate: truthProp,
  9867. closeIconPosition: makeStringProp("top-right")
  9868. };
  9869. var stdin_default$z = vue.defineComponent({
  9870. name: name$u,
  9871. props: imagePreviewProps,
  9872. emits: ["scale", "close", "closed", "change", "update:show"],
  9873. setup(props, {
  9874. emit,
  9875. slots
  9876. }) {
  9877. const swipeRef = vue.ref();
  9878. const state = vue.reactive({
  9879. active: 0,
  9880. rootWidth: 0,
  9881. rootHeight: 0
  9882. });
  9883. const resize = () => {
  9884. if (swipeRef.value) {
  9885. const rect = use.useRect(swipeRef.value.$el);
  9886. state.rootWidth = rect.width;
  9887. state.rootHeight = rect.height;
  9888. swipeRef.value.resize();
  9889. }
  9890. };
  9891. const emitScale = (args) => emit("scale", args);
  9892. const updateShow = (show) => emit("update:show", show);
  9893. const emitClose = () => {
  9894. callInterceptor(props.beforeClose, {
  9895. args: [state.active],
  9896. done: () => updateShow(false)
  9897. });
  9898. };
  9899. const setActive = (active) => {
  9900. if (active !== state.active) {
  9901. state.active = active;
  9902. emit("change", active);
  9903. }
  9904. };
  9905. const renderIndex = () => {
  9906. if (props.showIndex) {
  9907. return vue.createVNode("div", {
  9908. "class": bem$u("index")
  9909. }, [slots.index ? slots.index({
  9910. index: state.active
  9911. }) : `${state.active + 1} / ${props.images.length}`]);
  9912. }
  9913. };
  9914. const renderCover = () => {
  9915. if (slots.cover) {
  9916. return vue.createVNode("div", {
  9917. "class": bem$u("cover")
  9918. }, [slots.cover()]);
  9919. }
  9920. };
  9921. const renderImages = () => vue.createVNode(Swipe, {
  9922. "ref": swipeRef,
  9923. "lazyRender": true,
  9924. "loop": props.loop,
  9925. "class": bem$u("swipe"),
  9926. "duration": props.swipeDuration,
  9927. "initialSwipe": props.startPosition,
  9928. "showIndicators": props.showIndicators,
  9929. "indicatorColor": "white",
  9930. "onChange": setActive
  9931. }, {
  9932. default: () => [props.images.map((image) => vue.createVNode(stdin_default$A, {
  9933. "src": image,
  9934. "show": props.show,
  9935. "active": state.active,
  9936. "maxZoom": props.maxZoom,
  9937. "minZoom": props.minZoom,
  9938. "rootWidth": state.rootWidth,
  9939. "rootHeight": state.rootHeight,
  9940. "onScale": emitScale,
  9941. "onClose": emitClose
  9942. }, {
  9943. image: slots.image
  9944. }))]
  9945. });
  9946. const renderClose = () => {
  9947. if (props.closeable) {
  9948. return vue.createVNode(Icon, {
  9949. "role": "button",
  9950. "name": props.closeIcon,
  9951. "class": [bem$u("close-icon", props.closeIconPosition), HAPTICS_FEEDBACK],
  9952. "onClick": emitClose
  9953. }, null);
  9954. }
  9955. };
  9956. const onClosed = () => emit("closed");
  9957. const swipeTo = (index, options) => {
  9958. var _a;
  9959. return (_a = swipeRef.value) == null ? void 0 : _a.swipeTo(index, options);
  9960. };
  9961. useExpose({
  9962. swipeTo
  9963. });
  9964. vue.onMounted(resize);
  9965. vue.watch([windowWidth, windowHeight], resize);
  9966. vue.watch(() => props.startPosition, (value) => setActive(+value));
  9967. vue.watch(() => props.show, (value) => {
  9968. const {
  9969. images,
  9970. startPosition
  9971. } = props;
  9972. if (value) {
  9973. setActive(+startPosition);
  9974. vue.nextTick(() => {
  9975. resize();
  9976. swipeTo(+startPosition, {
  9977. immediate: true
  9978. });
  9979. });
  9980. } else {
  9981. emit("close", {
  9982. index: state.active,
  9983. url: images[state.active]
  9984. });
  9985. }
  9986. });
  9987. return () => vue.createVNode(Popup, vue.mergeProps({
  9988. "class": [bem$u(), props.className],
  9989. "overlayClass": [bem$u("overlay"), props.overlayClass],
  9990. "onClosed": onClosed,
  9991. "onUpdate:show": updateShow
  9992. }, pick(props, popupProps$1)), {
  9993. default: () => [renderClose(), renderImages(), renderIndex(), renderCover()]
  9994. });
  9995. }
  9996. });
  9997. let instance$1;
  9998. const defaultConfig = {
  9999. loop: true,
  10000. images: [],
  10001. maxZoom: 3,
  10002. minZoom: 1 / 3,
  10003. onScale: void 0,
  10004. onClose: void 0,
  10005. onChange: void 0,
  10006. teleport: "body",
  10007. className: "",
  10008. showIndex: true,
  10009. closeable: false,
  10010. closeIcon: "clear",
  10011. transition: void 0,
  10012. beforeClose: void 0,
  10013. overlayStyle: void 0,
  10014. overlayClass: void 0,
  10015. startPosition: 0,
  10016. swipeDuration: 300,
  10017. showIndicators: false,
  10018. closeOnPopstate: true,
  10019. closeIconPosition: "top-right"
  10020. };
  10021. function initInstance$1() {
  10022. ({
  10023. instance: instance$1
  10024. } = mountComponent({
  10025. setup() {
  10026. const {
  10027. state,
  10028. toggle
  10029. } = usePopupState();
  10030. const onClosed = () => {
  10031. state.images = [];
  10032. };
  10033. return () => vue.createVNode(stdin_default$z, vue.mergeProps(state, {
  10034. "onClosed": onClosed,
  10035. "onUpdate:show": toggle
  10036. }), null);
  10037. }
  10038. }));
  10039. }
  10040. const ImagePreview = (options, startPosition = 0) => {
  10041. if (!inBrowser) {
  10042. return;
  10043. }
  10044. if (!instance$1) {
  10045. initInstance$1();
  10046. }
  10047. options = Array.isArray(options) ? {
  10048. images: options,
  10049. startPosition
  10050. } : options;
  10051. instance$1.open(extend({}, defaultConfig, options));
  10052. return instance$1;
  10053. };
  10054. ImagePreview.Component = withInstall(stdin_default$z);
  10055. ImagePreview.install = (app) => {
  10056. app.use(ImagePreview.Component);
  10057. };
  10058. function genAlphabet() {
  10059. const charCodeOfA = "A".charCodeAt(0);
  10060. const indexList = Array(26).fill("").map((_, i) => String.fromCharCode(charCodeOfA + i));
  10061. return indexList;
  10062. }
  10063. const [name$t, bem$t] = createNamespace("index-bar");
  10064. const indexBarProps = {
  10065. sticky: truthProp,
  10066. zIndex: numericProp,
  10067. teleport: [String, Object],
  10068. highlightColor: String,
  10069. stickyOffsetTop: makeNumberProp(0),
  10070. indexList: {
  10071. type: Array,
  10072. default: genAlphabet
  10073. }
  10074. };
  10075. const INDEX_BAR_KEY = Symbol(name$t);
  10076. var stdin_default$y = vue.defineComponent({
  10077. name: name$t,
  10078. props: indexBarProps,
  10079. emits: ["select", "change"],
  10080. setup(props, {
  10081. emit,
  10082. slots
  10083. }) {
  10084. const root = vue.ref();
  10085. const sidebar = vue.ref();
  10086. const activeAnchor = vue.ref("");
  10087. const touch = useTouch();
  10088. const scrollParent = use.useScrollParent(root);
  10089. const {
  10090. children,
  10091. linkChildren
  10092. } = use.useChildren(INDEX_BAR_KEY);
  10093. let selectActiveIndex;
  10094. linkChildren({
  10095. props
  10096. });
  10097. const sidebarStyle = vue.computed(() => {
  10098. if (isDef(props.zIndex)) {
  10099. return {
  10100. zIndex: +props.zIndex + 1
  10101. };
  10102. }
  10103. });
  10104. const highlightStyle = vue.computed(() => {
  10105. if (props.highlightColor) {
  10106. return {
  10107. color: props.highlightColor
  10108. };
  10109. }
  10110. });
  10111. const getActiveAnchor = (scrollTop, rects) => {
  10112. for (let i = children.length - 1; i >= 0; i--) {
  10113. const prevHeight = i > 0 ? rects[i - 1].height : 0;
  10114. const reachTop = props.sticky ? prevHeight + props.stickyOffsetTop : 0;
  10115. if (scrollTop + reachTop >= rects[i].top) {
  10116. return i;
  10117. }
  10118. }
  10119. return -1;
  10120. };
  10121. const getMatchAnchor = (index) => children.find((item) => String(item.index) === index);
  10122. const onScroll = () => {
  10123. if (isHidden(root)) {
  10124. return;
  10125. }
  10126. const {
  10127. sticky,
  10128. indexList
  10129. } = props;
  10130. const scrollTop = getScrollTop(scrollParent.value);
  10131. const scrollParentRect = use.useRect(scrollParent);
  10132. const rects = children.map((item) => item.getRect(scrollParent.value, scrollParentRect));
  10133. let active = -1;
  10134. if (selectActiveIndex) {
  10135. const match = getMatchAnchor(selectActiveIndex);
  10136. if (match) {
  10137. const rect = match.getRect(scrollParent.value, scrollParentRect);
  10138. active = getActiveAnchor(rect.top, rects);
  10139. }
  10140. } else {
  10141. active = getActiveAnchor(scrollTop, rects);
  10142. }
  10143. activeAnchor.value = indexList[active];
  10144. if (sticky) {
  10145. children.forEach((item, index) => {
  10146. const {
  10147. state,
  10148. $el
  10149. } = item;
  10150. if (index === active || index === active - 1) {
  10151. const rect = $el.getBoundingClientRect();
  10152. state.left = rect.left;
  10153. state.width = rect.width;
  10154. } else {
  10155. state.left = null;
  10156. state.width = null;
  10157. }
  10158. if (index === active) {
  10159. state.active = true;
  10160. state.top = Math.max(props.stickyOffsetTop, rects[index].top - scrollTop) + scrollParentRect.top;
  10161. } else if (index === active - 1 && selectActiveIndex === "") {
  10162. const activeItemTop = rects[active].top - scrollTop;
  10163. state.active = activeItemTop > 0;
  10164. state.top = activeItemTop + scrollParentRect.top - rects[index].height;
  10165. } else {
  10166. state.active = false;
  10167. }
  10168. });
  10169. }
  10170. selectActiveIndex = "";
  10171. };
  10172. const init = () => {
  10173. vue.nextTick(onScroll);
  10174. };
  10175. use.useEventListener("scroll", onScroll, {
  10176. target: scrollParent,
  10177. passive: true
  10178. });
  10179. vue.onMounted(init);
  10180. vue.watch(() => props.indexList, init);
  10181. vue.watch(activeAnchor, (value) => {
  10182. if (value) {
  10183. emit("change", value);
  10184. }
  10185. });
  10186. const renderIndexes = () => props.indexList.map((index) => {
  10187. const active = index === activeAnchor.value;
  10188. return vue.createVNode("span", {
  10189. "class": bem$t("index", {
  10190. active
  10191. }),
  10192. "style": active ? highlightStyle.value : void 0,
  10193. "data-index": index
  10194. }, [index]);
  10195. });
  10196. const scrollTo = (index) => {
  10197. selectActiveIndex = String(index);
  10198. const match = getMatchAnchor(selectActiveIndex);
  10199. if (match) {
  10200. const scrollTop = getScrollTop(scrollParent.value);
  10201. const scrollParentRect = use.useRect(scrollParent);
  10202. const {
  10203. offsetHeight
  10204. } = document.documentElement;
  10205. match.$el.scrollIntoView();
  10206. if (scrollTop === offsetHeight - scrollParentRect.height) {
  10207. onScroll();
  10208. return;
  10209. }
  10210. if (props.sticky && props.stickyOffsetTop) {
  10211. setRootScrollTop(getRootScrollTop() - props.stickyOffsetTop);
  10212. }
  10213. emit("select", match.index);
  10214. }
  10215. };
  10216. const scrollToElement = (element) => {
  10217. const {
  10218. index
  10219. } = element.dataset;
  10220. if (index) {
  10221. scrollTo(index);
  10222. }
  10223. };
  10224. const onClickSidebar = (event) => {
  10225. scrollToElement(event.target);
  10226. };
  10227. let touchActiveIndex;
  10228. const onTouchMove = (event) => {
  10229. touch.move(event);
  10230. if (touch.isVertical()) {
  10231. preventDefault(event);
  10232. const {
  10233. clientX,
  10234. clientY
  10235. } = event.touches[0];
  10236. const target = document.elementFromPoint(clientX, clientY);
  10237. if (target) {
  10238. const {
  10239. index
  10240. } = target.dataset;
  10241. if (index && touchActiveIndex !== index) {
  10242. touchActiveIndex = index;
  10243. scrollToElement(target);
  10244. }
  10245. }
  10246. }
  10247. };
  10248. const renderSidebar = () => vue.createVNode("div", {
  10249. "ref": sidebar,
  10250. "class": bem$t("sidebar"),
  10251. "style": sidebarStyle.value,
  10252. "onClick": onClickSidebar,
  10253. "onTouchstartPassive": touch.start
  10254. }, [renderIndexes()]);
  10255. useExpose({
  10256. scrollTo
  10257. });
  10258. use.useEventListener("touchmove", onTouchMove, {
  10259. target: sidebar
  10260. });
  10261. return () => {
  10262. var _a;
  10263. return vue.createVNode("div", {
  10264. "ref": root,
  10265. "class": bem$t()
  10266. }, [props.teleport ? vue.createVNode(vue.Teleport, {
  10267. "to": props.teleport
  10268. }, {
  10269. default: () => [renderSidebar()]
  10270. }) : renderSidebar(), (_a = slots.default) == null ? void 0 : _a.call(slots)]);
  10271. };
  10272. }
  10273. });
  10274. const [name$s, bem$s] = createNamespace("index-anchor");
  10275. const indexAnchorProps = {
  10276. index: numericProp
  10277. };
  10278. var stdin_default$x = vue.defineComponent({
  10279. name: name$s,
  10280. props: indexAnchorProps,
  10281. setup(props, {
  10282. slots
  10283. }) {
  10284. const state = vue.reactive({
  10285. top: 0,
  10286. left: null,
  10287. rect: {
  10288. top: 0,
  10289. height: 0
  10290. },
  10291. width: null,
  10292. active: false
  10293. });
  10294. const root = vue.ref();
  10295. const {
  10296. parent
  10297. } = use.useParent(INDEX_BAR_KEY);
  10298. if (!parent) {
  10299. if (process.env.NODE_ENV !== "production") {
  10300. console.error("[Vant] <IndexAnchor> must be a child component of <IndexBar>.");
  10301. }
  10302. return;
  10303. }
  10304. const isSticky = () => state.active && parent.props.sticky;
  10305. const anchorStyle = vue.computed(() => {
  10306. const {
  10307. zIndex,
  10308. highlightColor
  10309. } = parent.props;
  10310. if (isSticky()) {
  10311. return extend(getZIndexStyle(zIndex), {
  10312. left: state.left ? `${state.left}px` : void 0,
  10313. width: state.width ? `${state.width}px` : void 0,
  10314. transform: state.top ? `translate3d(0, ${state.top}px, 0)` : void 0,
  10315. color: highlightColor
  10316. });
  10317. }
  10318. });
  10319. const getRect = (scrollParent, scrollParentRect) => {
  10320. const rootRect = use.useRect(root);
  10321. state.rect.height = rootRect.height;
  10322. if (scrollParent === window || scrollParent === document.body) {
  10323. state.rect.top = rootRect.top + getRootScrollTop();
  10324. } else {
  10325. state.rect.top = rootRect.top + getScrollTop(scrollParent) - scrollParentRect.top;
  10326. }
  10327. return state.rect;
  10328. };
  10329. useExpose({
  10330. state,
  10331. getRect
  10332. });
  10333. return () => {
  10334. const sticky = isSticky();
  10335. return vue.createVNode("div", {
  10336. "ref": root,
  10337. "style": {
  10338. height: sticky ? `${state.rect.height}px` : void 0
  10339. }
  10340. }, [vue.createVNode("div", {
  10341. "style": anchorStyle.value,
  10342. "class": [bem$s({
  10343. sticky
  10344. }), {
  10345. [BORDER_BOTTOM]: sticky
  10346. }]
  10347. }, [slots.default ? slots.default() : props.index])]);
  10348. };
  10349. }
  10350. });
  10351. const IndexAnchor = withInstall(stdin_default$x);
  10352. const IndexBar = withInstall(stdin_default$y);
  10353. const [name$r, bem$r, t$6] = createNamespace("list");
  10354. const listProps = {
  10355. error: Boolean,
  10356. offset: makeNumericProp(300),
  10357. loading: Boolean,
  10358. finished: Boolean,
  10359. errorText: String,
  10360. direction: makeStringProp("down"),
  10361. loadingText: String,
  10362. finishedText: String,
  10363. immediateCheck: truthProp
  10364. };
  10365. var stdin_default$w = vue.defineComponent({
  10366. name: name$r,
  10367. props: listProps,
  10368. emits: ["load", "update:error", "update:loading"],
  10369. setup(props, {
  10370. emit,
  10371. slots
  10372. }) {
  10373. const loading = vue.ref(props.loading);
  10374. const root = vue.ref();
  10375. const placeholder = vue.ref();
  10376. const tabStatus = useTabStatus();
  10377. const scrollParent = use.useScrollParent(root);
  10378. const check = () => {
  10379. vue.nextTick(() => {
  10380. if (loading.value || props.finished || props.error || (tabStatus == null ? void 0 : tabStatus.value) === false) {
  10381. return;
  10382. }
  10383. const {
  10384. offset,
  10385. direction
  10386. } = props;
  10387. const scrollParentRect = use.useRect(scrollParent);
  10388. if (!scrollParentRect.height || isHidden(root)) {
  10389. return;
  10390. }
  10391. let isReachEdge = false;
  10392. const placeholderRect = use.useRect(placeholder);
  10393. if (direction === "up") {
  10394. isReachEdge = scrollParentRect.top - placeholderRect.top <= offset;
  10395. } else {
  10396. isReachEdge = placeholderRect.bottom - scrollParentRect.bottom <= offset;
  10397. }
  10398. if (isReachEdge) {
  10399. loading.value = true;
  10400. emit("update:loading", true);
  10401. emit("load");
  10402. }
  10403. });
  10404. };
  10405. const renderFinishedText = () => {
  10406. if (props.finished) {
  10407. const text = slots.finished ? slots.finished() : props.finishedText;
  10408. if (text) {
  10409. return vue.createVNode("div", {
  10410. "class": bem$r("finished-text")
  10411. }, [text]);
  10412. }
  10413. }
  10414. };
  10415. const clickErrorText = () => {
  10416. emit("update:error", false);
  10417. check();
  10418. };
  10419. const renderErrorText = () => {
  10420. if (props.error) {
  10421. const text = slots.error ? slots.error() : props.errorText;
  10422. if (text) {
  10423. return vue.createVNode("div", {
  10424. "role": "button",
  10425. "class": bem$r("error-text"),
  10426. "tabindex": 0,
  10427. "onClick": clickErrorText
  10428. }, [text]);
  10429. }
  10430. }
  10431. };
  10432. const renderLoading = () => {
  10433. if (loading.value && !props.finished) {
  10434. return vue.createVNode("div", {
  10435. "class": bem$r("loading")
  10436. }, [slots.loading ? slots.loading() : vue.createVNode(Loading, {
  10437. "class": bem$r("loading-icon")
  10438. }, {
  10439. default: () => [props.loadingText || t$6("loading")]
  10440. })]);
  10441. }
  10442. };
  10443. vue.watch(() => [props.loading, props.finished, props.error], check);
  10444. if (tabStatus) {
  10445. vue.watch(tabStatus, (tabActive) => {
  10446. if (tabActive) {
  10447. check();
  10448. }
  10449. });
  10450. }
  10451. vue.onUpdated(() => {
  10452. loading.value = props.loading;
  10453. });
  10454. vue.onMounted(() => {
  10455. if (props.immediateCheck) {
  10456. check();
  10457. }
  10458. });
  10459. useExpose({
  10460. check
  10461. });
  10462. use.useEventListener("scroll", check, {
  10463. target: scrollParent,
  10464. passive: true
  10465. });
  10466. return () => {
  10467. var _a;
  10468. const Content = (_a = slots.default) == null ? void 0 : _a.call(slots);
  10469. const Placeholder = vue.createVNode("div", {
  10470. "ref": placeholder,
  10471. "class": bem$r("placeholder")
  10472. }, null);
  10473. return vue.createVNode("div", {
  10474. "ref": root,
  10475. "role": "feed",
  10476. "class": bem$r(),
  10477. "aria-busy": loading.value
  10478. }, [props.direction === "down" ? Content : Placeholder, renderLoading(), renderFinishedText(), renderErrorText(), props.direction === "up" ? Content : Placeholder]);
  10479. };
  10480. }
  10481. });
  10482. const List = withInstall(stdin_default$w);
  10483. const [name$q, bem$q] = createNamespace("nav-bar");
  10484. const navBarProps = {
  10485. title: String,
  10486. fixed: Boolean,
  10487. zIndex: numericProp,
  10488. border: truthProp,
  10489. leftText: String,
  10490. rightText: String,
  10491. leftArrow: Boolean,
  10492. placeholder: Boolean,
  10493. safeAreaInsetTop: Boolean
  10494. };
  10495. var stdin_default$v = vue.defineComponent({
  10496. name: name$q,
  10497. props: navBarProps,
  10498. emits: ["click-left", "click-right"],
  10499. setup(props, {
  10500. emit,
  10501. slots
  10502. }) {
  10503. const navBarRef = vue.ref();
  10504. const renderPlaceholder = usePlaceholder(navBarRef, bem$q);
  10505. const onClickLeft = (event) => emit("click-left", event);
  10506. const onClickRight = (event) => emit("click-right", event);
  10507. const renderLeft = () => {
  10508. if (slots.left) {
  10509. return slots.left();
  10510. }
  10511. return [props.leftArrow && vue.createVNode(Icon, {
  10512. "class": bem$q("arrow"),
  10513. "name": "arrow-left"
  10514. }, null), props.leftText && vue.createVNode("span", {
  10515. "class": bem$q("text")
  10516. }, [props.leftText])];
  10517. };
  10518. const renderRight = () => {
  10519. if (slots.right) {
  10520. return slots.right();
  10521. }
  10522. return vue.createVNode("span", {
  10523. "class": bem$q("text")
  10524. }, [props.rightText]);
  10525. };
  10526. const renderNavBar = () => {
  10527. const {
  10528. title,
  10529. fixed,
  10530. border,
  10531. zIndex
  10532. } = props;
  10533. const style = getZIndexStyle(zIndex);
  10534. const hasLeft = props.leftArrow || props.leftText || slots.left;
  10535. const hasRight = props.rightText || slots.right;
  10536. return vue.createVNode("div", {
  10537. "ref": navBarRef,
  10538. "style": style,
  10539. "class": [bem$q({
  10540. fixed
  10541. }), {
  10542. [BORDER_BOTTOM]: border,
  10543. "van-safe-area-top": props.safeAreaInsetTop
  10544. }]
  10545. }, [vue.createVNode("div", {
  10546. "class": bem$q("content")
  10547. }, [hasLeft && vue.createVNode("div", {
  10548. "class": [bem$q("left"), HAPTICS_FEEDBACK],
  10549. "onClick": onClickLeft
  10550. }, [renderLeft()]), vue.createVNode("div", {
  10551. "class": [bem$q("title"), "van-ellipsis"]
  10552. }, [slots.title ? slots.title() : title]), hasRight && vue.createVNode("div", {
  10553. "class": [bem$q("right"), HAPTICS_FEEDBACK],
  10554. "onClick": onClickRight
  10555. }, [renderRight()])])]);
  10556. };
  10557. return () => {
  10558. if (props.fixed && props.placeholder) {
  10559. return renderPlaceholder(renderNavBar);
  10560. }
  10561. return renderNavBar();
  10562. };
  10563. }
  10564. });
  10565. const NavBar = withInstall(stdin_default$v);
  10566. const [name$p, bem$p] = createNamespace("notice-bar");
  10567. const noticeBarProps = {
  10568. text: String,
  10569. mode: String,
  10570. color: String,
  10571. delay: makeNumericProp(1),
  10572. speed: makeNumericProp(60),
  10573. leftIcon: String,
  10574. wrapable: Boolean,
  10575. background: String,
  10576. scrollable: {
  10577. type: Boolean,
  10578. default: null
  10579. }
  10580. };
  10581. var stdin_default$u = vue.defineComponent({
  10582. name: name$p,
  10583. props: noticeBarProps,
  10584. emits: ["close", "replay"],
  10585. setup(props, {
  10586. emit,
  10587. slots
  10588. }) {
  10589. let wrapWidth = 0;
  10590. let contentWidth = 0;
  10591. let startTimer;
  10592. const wrapRef = vue.ref();
  10593. const contentRef = vue.ref();
  10594. const state = vue.reactive({
  10595. show: true,
  10596. offset: 0,
  10597. duration: 0
  10598. });
  10599. const renderLeftIcon = () => {
  10600. if (slots["left-icon"]) {
  10601. return slots["left-icon"]();
  10602. }
  10603. if (props.leftIcon) {
  10604. return vue.createVNode(Icon, {
  10605. "class": bem$p("left-icon"),
  10606. "name": props.leftIcon
  10607. }, null);
  10608. }
  10609. };
  10610. const getRightIconName = () => {
  10611. if (props.mode === "closeable") {
  10612. return "cross";
  10613. }
  10614. if (props.mode === "link") {
  10615. return "arrow";
  10616. }
  10617. };
  10618. const onClickRightIcon = (event) => {
  10619. if (props.mode === "closeable") {
  10620. state.show = false;
  10621. emit("close", event);
  10622. }
  10623. };
  10624. const renderRightIcon = () => {
  10625. if (slots["right-icon"]) {
  10626. return slots["right-icon"]();
  10627. }
  10628. const name2 = getRightIconName();
  10629. if (name2) {
  10630. return vue.createVNode(Icon, {
  10631. "name": name2,
  10632. "class": bem$p("right-icon"),
  10633. "onClick": onClickRightIcon
  10634. }, null);
  10635. }
  10636. };
  10637. const onTransitionEnd = () => {
  10638. state.offset = wrapWidth;
  10639. state.duration = 0;
  10640. use.raf(() => {
  10641. use.doubleRaf(() => {
  10642. state.offset = -contentWidth;
  10643. state.duration = (contentWidth + wrapWidth) / +props.speed;
  10644. emit("replay");
  10645. });
  10646. });
  10647. };
  10648. const renderMarquee = () => {
  10649. const ellipsis = props.scrollable === false && !props.wrapable;
  10650. const style = {
  10651. transform: state.offset ? `translateX(${state.offset}px)` : "",
  10652. transitionDuration: `${state.duration}s`
  10653. };
  10654. return vue.createVNode("div", {
  10655. "ref": wrapRef,
  10656. "role": "marquee",
  10657. "class": bem$p("wrap")
  10658. }, [vue.createVNode("div", {
  10659. "ref": contentRef,
  10660. "style": style,
  10661. "class": [bem$p("content"), {
  10662. "van-ellipsis": ellipsis
  10663. }],
  10664. "onTransitionend": onTransitionEnd
  10665. }, [slots.default ? slots.default() : props.text])]);
  10666. };
  10667. const reset = () => {
  10668. const {
  10669. delay,
  10670. speed,
  10671. scrollable
  10672. } = props;
  10673. const ms = isDef(delay) ? +delay * 1e3 : 0;
  10674. wrapWidth = 0;
  10675. contentWidth = 0;
  10676. state.offset = 0;
  10677. state.duration = 0;
  10678. clearTimeout(startTimer);
  10679. startTimer = setTimeout(() => {
  10680. if (!wrapRef.value || !contentRef.value || scrollable === false) {
  10681. return;
  10682. }
  10683. const wrapRefWidth = use.useRect(wrapRef).width;
  10684. const contentRefWidth = use.useRect(contentRef).width;
  10685. if (scrollable || contentRefWidth > wrapRefWidth) {
  10686. use.doubleRaf(() => {
  10687. wrapWidth = wrapRefWidth;
  10688. contentWidth = contentRefWidth;
  10689. state.offset = -contentWidth;
  10690. state.duration = contentWidth / +speed;
  10691. });
  10692. }
  10693. }, ms);
  10694. };
  10695. onPopupReopen(reset);
  10696. use.onMountedOrActivated(reset);
  10697. use.useEventListener("pageshow", reset);
  10698. useExpose({
  10699. reset
  10700. });
  10701. vue.watch(() => [props.text, props.scrollable], reset);
  10702. return () => {
  10703. const {
  10704. color,
  10705. wrapable,
  10706. background
  10707. } = props;
  10708. return vue.withDirectives(vue.createVNode("div", {
  10709. "role": "alert",
  10710. "class": bem$p({
  10711. wrapable
  10712. }),
  10713. "style": {
  10714. color,
  10715. background
  10716. }
  10717. }, [renderLeftIcon(), renderMarquee(), renderRightIcon()]), [[vue.vShow, state.show]]);
  10718. };
  10719. }
  10720. });
  10721. const NoticeBar = withInstall(stdin_default$u);
  10722. const [name$o, bem$o] = createNamespace("notify");
  10723. const notifyProps = extend({}, popupSharedProps, {
  10724. type: makeStringProp("danger"),
  10725. color: String,
  10726. message: numericProp,
  10727. position: makeStringProp("top"),
  10728. className: unknownProp,
  10729. background: String,
  10730. lockScroll: Boolean
  10731. });
  10732. var stdin_default$t = vue.defineComponent({
  10733. name: name$o,
  10734. props: notifyProps,
  10735. emits: ["update:show"],
  10736. setup(props, {
  10737. emit,
  10738. slots
  10739. }) {
  10740. const updateShow = (show) => emit("update:show", show);
  10741. return () => vue.createVNode(Popup, {
  10742. "show": props.show,
  10743. "class": [bem$o([props.type]), props.className],
  10744. "style": {
  10745. color: props.color,
  10746. background: props.background
  10747. },
  10748. "overlay": false,
  10749. "position": props.position,
  10750. "duration": 0.2,
  10751. "lockScroll": props.lockScroll,
  10752. "onUpdate:show": updateShow
  10753. }, {
  10754. default: () => [slots.default ? slots.default() : props.message]
  10755. });
  10756. }
  10757. });
  10758. let timer;
  10759. let instance;
  10760. const parseOptions = (message) => isObject(message) ? message : {
  10761. message
  10762. };
  10763. function initInstance() {
  10764. ({
  10765. instance
  10766. } = mountComponent({
  10767. setup() {
  10768. const {
  10769. state,
  10770. toggle
  10771. } = usePopupState();
  10772. return () => vue.createVNode(stdin_default$t, vue.mergeProps(state, {
  10773. "onUpdate:show": toggle
  10774. }), null);
  10775. }
  10776. }));
  10777. }
  10778. function Notify(options) {
  10779. if (!inBrowser) {
  10780. return;
  10781. }
  10782. if (!instance) {
  10783. initInstance();
  10784. }
  10785. options = extend({}, Notify.currentOptions, parseOptions(options));
  10786. instance.open(options);
  10787. clearTimeout(timer);
  10788. if (options.duration > 0) {
  10789. timer = window.setTimeout(Notify.clear, options.duration);
  10790. }
  10791. return instance;
  10792. }
  10793. const getDefaultOptions = () => ({
  10794. type: "danger",
  10795. color: void 0,
  10796. message: "",
  10797. onClose: void 0,
  10798. onClick: void 0,
  10799. onOpened: void 0,
  10800. duration: 3e3,
  10801. position: void 0,
  10802. className: "",
  10803. lockScroll: false,
  10804. background: void 0
  10805. });
  10806. Notify.clear = () => {
  10807. if (instance) {
  10808. instance.toggle(false);
  10809. }
  10810. };
  10811. Notify.currentOptions = getDefaultOptions();
  10812. Notify.setDefaultOptions = (options) => {
  10813. extend(Notify.currentOptions, options);
  10814. };
  10815. Notify.resetDefaultOptions = () => {
  10816. Notify.currentOptions = getDefaultOptions();
  10817. };
  10818. Notify.Component = withInstall(stdin_default$t);
  10819. Notify.install = (app) => {
  10820. app.use(Notify.Component);
  10821. app.config.globalProperties.$notify = Notify;
  10822. };
  10823. const [name$n, bem$n] = createNamespace("key");
  10824. const CollapseIcon = vue.createVNode("svg", {
  10825. "class": bem$n("collapse-icon"),
  10826. "viewBox": "0 0 30 24"
  10827. }, [vue.createVNode("path", {
  10828. "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",
  10829. "fill": "currentColor"
  10830. }, null)]);
  10831. const DeleteIcon = vue.createVNode("svg", {
  10832. "class": bem$n("delete-icon"),
  10833. "viewBox": "0 0 32 22"
  10834. }, [vue.createVNode("path", {
  10835. "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",
  10836. "fill": "currentColor"
  10837. }, null)]);
  10838. var stdin_default$s = vue.defineComponent({
  10839. name: name$n,
  10840. props: {
  10841. type: String,
  10842. text: numericProp,
  10843. color: String,
  10844. wider: Boolean,
  10845. large: Boolean,
  10846. loading: Boolean
  10847. },
  10848. emits: ["press"],
  10849. setup(props, {
  10850. emit,
  10851. slots
  10852. }) {
  10853. const active = vue.ref(false);
  10854. const touch = useTouch();
  10855. const onTouchStart = (event) => {
  10856. touch.start(event);
  10857. active.value = true;
  10858. };
  10859. const onTouchMove = (event) => {
  10860. touch.move(event);
  10861. if (touch.direction.value) {
  10862. active.value = false;
  10863. }
  10864. };
  10865. const onTouchEnd = (event) => {
  10866. if (active.value) {
  10867. if (!slots.default) {
  10868. preventDefault(event);
  10869. }
  10870. active.value = false;
  10871. emit("press", props.text, props.type);
  10872. }
  10873. };
  10874. const renderContent = () => {
  10875. if (props.loading) {
  10876. return vue.createVNode(Loading, {
  10877. "class": bem$n("loading-icon")
  10878. }, null);
  10879. }
  10880. const text = slots.default ? slots.default() : props.text;
  10881. switch (props.type) {
  10882. case "delete":
  10883. return text || DeleteIcon;
  10884. case "extra":
  10885. return text || CollapseIcon;
  10886. default:
  10887. return text;
  10888. }
  10889. };
  10890. return () => vue.createVNode("div", {
  10891. "class": bem$n("wrapper", {
  10892. wider: props.wider
  10893. }),
  10894. "onTouchstartPassive": onTouchStart,
  10895. "onTouchmovePassive": onTouchMove,
  10896. "onTouchend": onTouchEnd,
  10897. "onTouchcancel": onTouchEnd
  10898. }, [vue.createVNode("div", {
  10899. "role": "button",
  10900. "tabindex": 0,
  10901. "class": bem$n([props.color, {
  10902. large: props.large,
  10903. active: active.value,
  10904. delete: props.type === "delete"
  10905. }])
  10906. }, [renderContent()])]);
  10907. }
  10908. });
  10909. const [name$m, bem$m] = createNamespace("number-keyboard");
  10910. const numberKeyboardProps = {
  10911. show: Boolean,
  10912. title: String,
  10913. theme: makeStringProp("default"),
  10914. zIndex: numericProp,
  10915. teleport: [String, Object],
  10916. maxlength: makeNumericProp(Infinity),
  10917. modelValue: makeStringProp(""),
  10918. transition: truthProp,
  10919. blurOnClose: truthProp,
  10920. showDeleteKey: truthProp,
  10921. randomKeyOrder: Boolean,
  10922. closeButtonText: String,
  10923. deleteButtonText: String,
  10924. closeButtonLoading: Boolean,
  10925. hideOnClickOutside: truthProp,
  10926. safeAreaInsetBottom: truthProp,
  10927. extraKey: {
  10928. type: [String, Array],
  10929. default: ""
  10930. }
  10931. };
  10932. function shuffle(array) {
  10933. for (let i = array.length - 1; i > 0; i--) {
  10934. const j = Math.floor(Math.random() * (i + 1));
  10935. const temp = array[i];
  10936. array[i] = array[j];
  10937. array[j] = temp;
  10938. }
  10939. return array;
  10940. }
  10941. var stdin_default$r = vue.defineComponent({
  10942. name: name$m,
  10943. inheritAttrs: false,
  10944. props: numberKeyboardProps,
  10945. emits: ["show", "hide", "blur", "input", "close", "delete", "update:modelValue"],
  10946. setup(props, {
  10947. emit,
  10948. slots,
  10949. attrs
  10950. }) {
  10951. const root = vue.ref();
  10952. const genBasicKeys = () => {
  10953. const keys2 = Array(9).fill("").map((_, i) => ({
  10954. text: i + 1
  10955. }));
  10956. if (props.randomKeyOrder) {
  10957. shuffle(keys2);
  10958. }
  10959. return keys2;
  10960. };
  10961. const genDefaultKeys = () => [...genBasicKeys(), {
  10962. text: props.extraKey,
  10963. type: "extra"
  10964. }, {
  10965. text: 0
  10966. }, {
  10967. text: props.showDeleteKey ? props.deleteButtonText : "",
  10968. type: props.showDeleteKey ? "delete" : ""
  10969. }];
  10970. const genCustomKeys = () => {
  10971. const keys2 = genBasicKeys();
  10972. const {
  10973. extraKey
  10974. } = props;
  10975. const extraKeys = Array.isArray(extraKey) ? extraKey : [extraKey];
  10976. if (extraKeys.length === 1) {
  10977. keys2.push({
  10978. text: 0,
  10979. wider: true
  10980. }, {
  10981. text: extraKeys[0],
  10982. type: "extra"
  10983. });
  10984. } else if (extraKeys.length === 2) {
  10985. keys2.push({
  10986. text: extraKeys[0],
  10987. type: "extra"
  10988. }, {
  10989. text: 0
  10990. }, {
  10991. text: extraKeys[1],
  10992. type: "extra"
  10993. });
  10994. }
  10995. return keys2;
  10996. };
  10997. const keys = vue.computed(() => props.theme === "custom" ? genCustomKeys() : genDefaultKeys());
  10998. const onBlur = () => {
  10999. if (props.show) {
  11000. emit("blur");
  11001. }
  11002. };
  11003. const onClose = () => {
  11004. emit("close");
  11005. if (props.blurOnClose) {
  11006. onBlur();
  11007. }
  11008. };
  11009. const onAnimationEnd = () => emit(props.show ? "show" : "hide");
  11010. const onPress = (text, type) => {
  11011. if (text === "") {
  11012. if (type === "extra") {
  11013. onBlur();
  11014. }
  11015. return;
  11016. }
  11017. const value = props.modelValue;
  11018. if (type === "delete") {
  11019. emit("delete");
  11020. emit("update:modelValue", value.slice(0, value.length - 1));
  11021. } else if (type === "close") {
  11022. onClose();
  11023. } else if (value.length < props.maxlength) {
  11024. emit("input", text);
  11025. emit("update:modelValue", value + text);
  11026. }
  11027. };
  11028. const renderTitle = () => {
  11029. const {
  11030. title,
  11031. theme,
  11032. closeButtonText
  11033. } = props;
  11034. const leftSlot = slots["title-left"];
  11035. const showClose = closeButtonText && theme === "default";
  11036. const showTitle = title || showClose || leftSlot;
  11037. if (!showTitle) {
  11038. return;
  11039. }
  11040. return vue.createVNode("div", {
  11041. "class": bem$m("header")
  11042. }, [leftSlot && vue.createVNode("span", {
  11043. "class": bem$m("title-left")
  11044. }, [leftSlot()]), title && vue.createVNode("h2", {
  11045. "class": bem$m("title")
  11046. }, [title]), showClose && vue.createVNode("button", {
  11047. "type": "button",
  11048. "class": [bem$m("close"), HAPTICS_FEEDBACK],
  11049. "onClick": onClose
  11050. }, [closeButtonText])]);
  11051. };
  11052. const renderKeys = () => keys.value.map((key) => {
  11053. const keySlots = {};
  11054. if (key.type === "delete") {
  11055. keySlots.default = slots.delete;
  11056. }
  11057. if (key.type === "extra") {
  11058. keySlots.default = slots["extra-key"];
  11059. }
  11060. return vue.createVNode(stdin_default$s, {
  11061. "key": key.text,
  11062. "text": key.text,
  11063. "type": key.type,
  11064. "wider": key.wider,
  11065. "color": key.color,
  11066. "onPress": onPress
  11067. }, keySlots);
  11068. });
  11069. const renderSidebar = () => {
  11070. if (props.theme === "custom") {
  11071. return vue.createVNode("div", {
  11072. "class": bem$m("sidebar")
  11073. }, [props.showDeleteKey && vue.createVNode(stdin_default$s, {
  11074. "large": true,
  11075. "text": props.deleteButtonText,
  11076. "type": "delete",
  11077. "onPress": onPress
  11078. }, {
  11079. delete: slots.delete
  11080. }), vue.createVNode(stdin_default$s, {
  11081. "large": true,
  11082. "text": props.closeButtonText,
  11083. "type": "close",
  11084. "color": "blue",
  11085. "loading": props.closeButtonLoading,
  11086. "onPress": onPress
  11087. }, null)]);
  11088. }
  11089. };
  11090. vue.watch(() => props.show, (value) => {
  11091. if (!props.transition) {
  11092. emit(value ? "show" : "hide");
  11093. }
  11094. });
  11095. if (props.hideOnClickOutside) {
  11096. use.useClickAway(root, onBlur, {
  11097. eventName: "touchstart"
  11098. });
  11099. }
  11100. return () => {
  11101. const Title = renderTitle();
  11102. const Content = vue.createVNode(vue.Transition, {
  11103. "name": props.transition ? "van-slide-up" : ""
  11104. }, {
  11105. default: () => [vue.withDirectives(vue.createVNode("div", vue.mergeProps({
  11106. "ref": root,
  11107. "style": getZIndexStyle(props.zIndex),
  11108. "class": bem$m({
  11109. unfit: !props.safeAreaInsetBottom,
  11110. "with-title": !!Title
  11111. }),
  11112. "onAnimationend": onAnimationEnd,
  11113. "onTouchstartPassive": stopPropagation
  11114. }, attrs), [Title, vue.createVNode("div", {
  11115. "class": bem$m("body")
  11116. }, [vue.createVNode("div", {
  11117. "class": bem$m("keys")
  11118. }, [renderKeys()]), renderSidebar()])]), [[vue.vShow, props.show]])]
  11119. });
  11120. if (props.teleport) {
  11121. return vue.createVNode(vue.Teleport, {
  11122. "to": props.teleport
  11123. }, {
  11124. default: () => [Content]
  11125. });
  11126. }
  11127. return Content;
  11128. };
  11129. }
  11130. });
  11131. const NumberKeyboard = withInstall(stdin_default$r);
  11132. const [name$l, bem$l, t$5] = createNamespace("pagination");
  11133. const makePage = (number, text, active) => ({
  11134. number,
  11135. text,
  11136. active
  11137. });
  11138. const paginationProps = {
  11139. mode: makeStringProp("multi"),
  11140. prevText: String,
  11141. nextText: String,
  11142. pageCount: makeNumericProp(0),
  11143. modelValue: makeNumberProp(0),
  11144. totalItems: makeNumericProp(0),
  11145. showPageSize: makeNumericProp(5),
  11146. itemsPerPage: makeNumericProp(10),
  11147. forceEllipses: Boolean
  11148. };
  11149. var stdin_default$q = vue.defineComponent({
  11150. name: name$l,
  11151. props: paginationProps,
  11152. emits: ["change", "update:modelValue"],
  11153. setup(props, {
  11154. emit,
  11155. slots
  11156. }) {
  11157. const count = vue.computed(() => {
  11158. const {
  11159. pageCount,
  11160. totalItems,
  11161. itemsPerPage
  11162. } = props;
  11163. const count2 = +pageCount || Math.ceil(+totalItems / +itemsPerPage);
  11164. return Math.max(1, count2);
  11165. });
  11166. const pages = vue.computed(() => {
  11167. const items = [];
  11168. const pageCount = count.value;
  11169. const showPageSize = +props.showPageSize;
  11170. const {
  11171. modelValue,
  11172. forceEllipses
  11173. } = props;
  11174. let startPage = 1;
  11175. let endPage = pageCount;
  11176. const isMaxSized = showPageSize < pageCount;
  11177. if (isMaxSized) {
  11178. startPage = Math.max(modelValue - Math.floor(showPageSize / 2), 1);
  11179. endPage = startPage + showPageSize - 1;
  11180. if (endPage > pageCount) {
  11181. endPage = pageCount;
  11182. startPage = endPage - showPageSize + 1;
  11183. }
  11184. }
  11185. for (let number = startPage; number <= endPage; number++) {
  11186. const page = makePage(number, number, number === modelValue);
  11187. items.push(page);
  11188. }
  11189. if (isMaxSized && showPageSize > 0 && forceEllipses) {
  11190. if (startPage > 1) {
  11191. const prevPages = makePage(startPage - 1, "...");
  11192. items.unshift(prevPages);
  11193. }
  11194. if (endPage < pageCount) {
  11195. const nextPages = makePage(endPage + 1, "...");
  11196. items.push(nextPages);
  11197. }
  11198. }
  11199. return items;
  11200. });
  11201. const updateModelValue = (value, emitChange) => {
  11202. value = clamp(value, 1, count.value);
  11203. if (props.modelValue !== value) {
  11204. emit("update:modelValue", value);
  11205. if (emitChange) {
  11206. emit("change", value);
  11207. }
  11208. }
  11209. };
  11210. vue.watchEffect(() => updateModelValue(props.modelValue));
  11211. const renderDesc = () => vue.createVNode("li", {
  11212. "class": bem$l("page-desc")
  11213. }, [slots.pageDesc ? slots.pageDesc() : `${props.modelValue}/${count.value}`]);
  11214. const renderPrevButton = () => {
  11215. const {
  11216. mode,
  11217. modelValue
  11218. } = props;
  11219. const slot = slots["prev-text"];
  11220. const disabled = modelValue === 1;
  11221. return vue.createVNode("li", {
  11222. "class": [bem$l("item", {
  11223. disabled,
  11224. border: mode === "simple",
  11225. prev: true
  11226. }), BORDER_SURROUND]
  11227. }, [vue.createVNode("button", {
  11228. "type": "button",
  11229. "disabled": disabled,
  11230. "onClick": () => updateModelValue(modelValue - 1, true)
  11231. }, [slot ? slot() : props.prevText || t$5("prev")])]);
  11232. };
  11233. const renderNextButton = () => {
  11234. const {
  11235. mode,
  11236. modelValue
  11237. } = props;
  11238. const slot = slots["next-text"];
  11239. const disabled = modelValue === count.value;
  11240. return vue.createVNode("li", {
  11241. "class": [bem$l("item", {
  11242. disabled,
  11243. border: mode === "simple",
  11244. next: true
  11245. }), BORDER_SURROUND]
  11246. }, [vue.createVNode("button", {
  11247. "type": "button",
  11248. "disabled": disabled,
  11249. "onClick": () => updateModelValue(modelValue + 1, true)
  11250. }, [slot ? slot() : props.nextText || t$5("next")])]);
  11251. };
  11252. const renderPages = () => pages.value.map((page) => vue.createVNode("li", {
  11253. "class": [bem$l("item", {
  11254. active: page.active,
  11255. page: true
  11256. }), BORDER_SURROUND]
  11257. }, [vue.createVNode("button", {
  11258. "type": "button",
  11259. "aria-current": page.active || void 0,
  11260. "onClick": () => updateModelValue(page.number, true)
  11261. }, [slots.page ? slots.page(page) : page.text])]));
  11262. return () => vue.createVNode("nav", {
  11263. "role": "navigation",
  11264. "class": bem$l()
  11265. }, [vue.createVNode("ul", {
  11266. "class": bem$l("items")
  11267. }, [renderPrevButton(), props.mode === "simple" ? renderDesc() : renderPages(), renderNextButton()])]);
  11268. }
  11269. });
  11270. const Pagination = withInstall(stdin_default$q);
  11271. const [name$k, bem$k] = createNamespace("password-input");
  11272. const passwordInputProps = {
  11273. info: String,
  11274. mask: truthProp,
  11275. value: makeStringProp(""),
  11276. gutter: numericProp,
  11277. length: makeNumericProp(6),
  11278. focused: Boolean,
  11279. errorInfo: String
  11280. };
  11281. var stdin_default$p = vue.defineComponent({
  11282. name: name$k,
  11283. props: passwordInputProps,
  11284. emits: ["focus"],
  11285. setup(props, {
  11286. emit
  11287. }) {
  11288. const onTouchStart = (event) => {
  11289. event.stopPropagation();
  11290. emit("focus", event);
  11291. };
  11292. const renderPoints = () => {
  11293. const Points = [];
  11294. const {
  11295. mask,
  11296. value,
  11297. length,
  11298. gutter,
  11299. focused
  11300. } = props;
  11301. for (let i = 0; i < length; i++) {
  11302. const char = value[i];
  11303. const showBorder = i !== 0 && !gutter;
  11304. const showCursor = focused && i === value.length;
  11305. let style;
  11306. if (i !== 0 && gutter) {
  11307. style = {
  11308. marginLeft: addUnit(gutter)
  11309. };
  11310. }
  11311. Points.push(vue.createVNode("li", {
  11312. "class": [{
  11313. [BORDER_LEFT]: showBorder
  11314. }, bem$k("item", {
  11315. focus: showCursor
  11316. })],
  11317. "style": style
  11318. }, [mask ? vue.createVNode("i", {
  11319. "style": {
  11320. visibility: char ? "visible" : "hidden"
  11321. }
  11322. }, null) : char, showCursor && vue.createVNode("div", {
  11323. "class": bem$k("cursor")
  11324. }, null)]));
  11325. }
  11326. return Points;
  11327. };
  11328. return () => {
  11329. const info = props.errorInfo || props.info;
  11330. return vue.createVNode("div", {
  11331. "class": bem$k()
  11332. }, [vue.createVNode("ul", {
  11333. "class": [bem$k("security"), {
  11334. [BORDER_SURROUND]: !props.gutter
  11335. }],
  11336. "onTouchstartPassive": onTouchStart
  11337. }, [renderPoints()]), info && vue.createVNode("div", {
  11338. "class": bem$k(props.errorInfo ? "error-info" : "info")
  11339. }, [info])]);
  11340. };
  11341. }
  11342. });
  11343. const PasswordInput = withInstall(stdin_default$p);
  11344. const [name$j, bem$j] = createNamespace("popover");
  11345. const popupProps = ["show", "overlay", "duration", "teleport", "overlayStyle", "overlayClass", "closeOnClickOverlay"];
  11346. const popoverProps = {
  11347. show: Boolean,
  11348. theme: makeStringProp("light"),
  11349. overlay: Boolean,
  11350. actions: makeArrayProp(),
  11351. trigger: makeStringProp("click"),
  11352. duration: numericProp,
  11353. showArrow: truthProp,
  11354. placement: makeStringProp("bottom"),
  11355. iconPrefix: String,
  11356. overlayClass: unknownProp,
  11357. overlayStyle: Object,
  11358. closeOnClickAction: truthProp,
  11359. closeOnClickOverlay: truthProp,
  11360. closeOnClickOutside: truthProp,
  11361. offset: {
  11362. type: Array,
  11363. default: () => [0, 8]
  11364. },
  11365. teleport: {
  11366. type: [String, Object],
  11367. default: "body"
  11368. }
  11369. };
  11370. var stdin_default$o = vue.defineComponent({
  11371. name: name$j,
  11372. props: popoverProps,
  11373. emits: ["select", "touchstart", "update:show"],
  11374. setup(props, {
  11375. emit,
  11376. slots,
  11377. attrs
  11378. }) {
  11379. let popper;
  11380. const popupRef = vue.ref();
  11381. const wrapperRef = vue.ref();
  11382. const popoverRef = vue.ref();
  11383. const getPopoverOptions = () => ({
  11384. placement: props.placement,
  11385. modifiers: [{
  11386. name: "computeStyles",
  11387. options: {
  11388. adaptive: false,
  11389. gpuAcceleration: false
  11390. }
  11391. }, extend({}, popperjs.offsetModifier, {
  11392. options: {
  11393. offset: props.offset
  11394. }
  11395. })]
  11396. });
  11397. const createPopperInstance = () => {
  11398. if (wrapperRef.value && popoverRef.value) {
  11399. return popperjs.createPopper(wrapperRef.value, popoverRef.value.popupRef.value, getPopoverOptions());
  11400. }
  11401. return null;
  11402. };
  11403. const updateLocation = () => {
  11404. vue.nextTick(() => {
  11405. if (!props.show) {
  11406. return;
  11407. }
  11408. if (!popper) {
  11409. popper = createPopperInstance();
  11410. } else {
  11411. popper.setOptions(getPopoverOptions());
  11412. }
  11413. });
  11414. };
  11415. const updateShow = (value) => emit("update:show", value);
  11416. const onClickWrapper = () => {
  11417. if (props.trigger === "click") {
  11418. updateShow(!props.show);
  11419. }
  11420. };
  11421. const onClickAction = (action, index) => {
  11422. if (action.disabled) {
  11423. return;
  11424. }
  11425. emit("select", action, index);
  11426. if (props.closeOnClickAction) {
  11427. updateShow(false);
  11428. }
  11429. };
  11430. const onClickAway = () => {
  11431. if (props.show && props.closeOnClickOutside && (!props.overlay || props.closeOnClickOverlay)) {
  11432. updateShow(false);
  11433. }
  11434. };
  11435. const renderActionContent = (action, index) => {
  11436. if (slots.action) {
  11437. return slots.action({
  11438. action,
  11439. index
  11440. });
  11441. }
  11442. return [action.icon && vue.createVNode(Icon, {
  11443. "name": action.icon,
  11444. "classPrefix": props.iconPrefix,
  11445. "class": bem$j("action-icon")
  11446. }, null), vue.createVNode("div", {
  11447. "class": [bem$j("action-text"), BORDER_BOTTOM]
  11448. }, [action.text])];
  11449. };
  11450. const renderAction = (action, index) => {
  11451. const {
  11452. icon,
  11453. color,
  11454. disabled,
  11455. className
  11456. } = action;
  11457. return vue.createVNode("div", {
  11458. "role": "menuitem",
  11459. "class": [bem$j("action", {
  11460. disabled,
  11461. "with-icon": icon
  11462. }), className],
  11463. "style": {
  11464. color
  11465. },
  11466. "tabindex": disabled ? void 0 : 0,
  11467. "aria-disabled": disabled || void 0,
  11468. "onClick": () => onClickAction(action, index)
  11469. }, [renderActionContent(action, index)]);
  11470. };
  11471. vue.onMounted(() => {
  11472. updateLocation();
  11473. vue.watchEffect(() => {
  11474. var _a;
  11475. popupRef.value = (_a = popoverRef.value) == null ? void 0 : _a.popupRef.value;
  11476. });
  11477. });
  11478. vue.onBeforeUnmount(() => {
  11479. if (popper) {
  11480. popper.destroy();
  11481. popper = null;
  11482. }
  11483. });
  11484. vue.watch(() => [props.show, props.offset, props.placement], updateLocation);
  11485. use.useClickAway([wrapperRef, popupRef], onClickAway, {
  11486. eventName: "touchstart"
  11487. });
  11488. return () => {
  11489. var _a;
  11490. return vue.createVNode(vue.Fragment, null, [vue.createVNode("span", {
  11491. "ref": wrapperRef,
  11492. "class": bem$j("wrapper"),
  11493. "onClick": onClickWrapper
  11494. }, [(_a = slots.reference) == null ? void 0 : _a.call(slots)]), vue.createVNode(Popup, vue.mergeProps({
  11495. "ref": popoverRef,
  11496. "class": bem$j([props.theme]),
  11497. "position": "",
  11498. "transition": "van-popover-zoom",
  11499. "lockScroll": false,
  11500. "onUpdate:show": updateShow
  11501. }, attrs, pick(props, popupProps)), {
  11502. default: () => [props.showArrow && vue.createVNode("div", {
  11503. "class": bem$j("arrow")
  11504. }, null), vue.createVNode("div", {
  11505. "role": "menu",
  11506. "class": bem$j("content")
  11507. }, [slots.default ? slots.default() : props.actions.map(renderAction)])]
  11508. })]);
  11509. };
  11510. }
  11511. });
  11512. const Popover = withInstall(stdin_default$o);
  11513. const [name$i, bem$i] = createNamespace("progress");
  11514. const progressProps = {
  11515. color: String,
  11516. inactive: Boolean,
  11517. pivotText: String,
  11518. textColor: String,
  11519. showPivot: truthProp,
  11520. pivotColor: String,
  11521. trackColor: String,
  11522. strokeWidth: numericProp,
  11523. percentage: {
  11524. type: numericProp,
  11525. default: 0,
  11526. validator: (value) => value >= 0 && value <= 100
  11527. }
  11528. };
  11529. var stdin_default$n = vue.defineComponent({
  11530. name: name$i,
  11531. props: progressProps,
  11532. setup(props) {
  11533. const background = vue.computed(() => props.inactive ? void 0 : props.color);
  11534. const renderPivot = () => {
  11535. const {
  11536. textColor,
  11537. pivotText,
  11538. pivotColor,
  11539. percentage
  11540. } = props;
  11541. const text = pivotText != null ? pivotText : `${percentage}%`;
  11542. if (props.showPivot && text) {
  11543. const style = {
  11544. color: textColor,
  11545. left: `${+percentage}%`,
  11546. transform: `translate(-${+percentage}%,-50%)`,
  11547. background: pivotColor || background.value
  11548. };
  11549. return vue.createVNode("span", {
  11550. "style": style,
  11551. "class": bem$i("pivot", {
  11552. inactive: props.inactive
  11553. })
  11554. }, [text]);
  11555. }
  11556. };
  11557. return () => {
  11558. const {
  11559. trackColor,
  11560. percentage,
  11561. strokeWidth
  11562. } = props;
  11563. const rootStyle = {
  11564. background: trackColor,
  11565. height: addUnit(strokeWidth)
  11566. };
  11567. const portionStyle = {
  11568. width: `${percentage}%`,
  11569. background: background.value
  11570. };
  11571. return vue.createVNode("div", {
  11572. "class": bem$i(),
  11573. "style": rootStyle
  11574. }, [vue.createVNode("span", {
  11575. "class": bem$i("portion", {
  11576. inactive: props.inactive
  11577. }),
  11578. "style": portionStyle
  11579. }, null), renderPivot()]);
  11580. };
  11581. }
  11582. });
  11583. const Progress = withInstall(stdin_default$n);
  11584. const [name$h, bem$h, t$4] = createNamespace("pull-refresh");
  11585. const DEFAULT_HEAD_HEIGHT = 50;
  11586. const TEXT_STATUS = ["pulling", "loosing", "success"];
  11587. const pullRefreshProps = {
  11588. disabled: Boolean,
  11589. modelValue: Boolean,
  11590. headHeight: makeNumericProp(DEFAULT_HEAD_HEIGHT),
  11591. successText: String,
  11592. pullingText: String,
  11593. loosingText: String,
  11594. loadingText: String,
  11595. pullDistance: numericProp,
  11596. successDuration: makeNumericProp(500),
  11597. animationDuration: makeNumericProp(300)
  11598. };
  11599. var stdin_default$m = vue.defineComponent({
  11600. name: name$h,
  11601. props: pullRefreshProps,
  11602. emits: ["change", "refresh", "update:modelValue"],
  11603. setup(props, {
  11604. emit,
  11605. slots
  11606. }) {
  11607. let reachTop;
  11608. const root = vue.ref();
  11609. const track = vue.ref();
  11610. const scrollParent = use.useScrollParent(root);
  11611. const state = vue.reactive({
  11612. status: "normal",
  11613. distance: 0,
  11614. duration: 0
  11615. });
  11616. const touch = useTouch();
  11617. const getHeadStyle = () => {
  11618. if (props.headHeight !== DEFAULT_HEAD_HEIGHT) {
  11619. return {
  11620. height: `${props.headHeight}px`
  11621. };
  11622. }
  11623. };
  11624. const isTouchable = () => state.status !== "loading" && state.status !== "success" && !props.disabled;
  11625. const ease = (distance) => {
  11626. const pullDistance = +(props.pullDistance || props.headHeight);
  11627. if (distance > pullDistance) {
  11628. if (distance < pullDistance * 2) {
  11629. distance = pullDistance + (distance - pullDistance) / 2;
  11630. } else {
  11631. distance = pullDistance * 1.5 + (distance - pullDistance * 2) / 4;
  11632. }
  11633. }
  11634. return Math.round(distance);
  11635. };
  11636. const setStatus = (distance, isLoading) => {
  11637. const pullDistance = +(props.pullDistance || props.headHeight);
  11638. state.distance = distance;
  11639. if (isLoading) {
  11640. state.status = "loading";
  11641. } else if (distance === 0) {
  11642. state.status = "normal";
  11643. } else if (distance < pullDistance) {
  11644. state.status = "pulling";
  11645. } else {
  11646. state.status = "loosing";
  11647. }
  11648. emit("change", {
  11649. status: state.status,
  11650. distance
  11651. });
  11652. };
  11653. const getStatusText = () => {
  11654. const {
  11655. status
  11656. } = state;
  11657. if (status === "normal") {
  11658. return "";
  11659. }
  11660. return props[`${status}Text`] || t$4(status);
  11661. };
  11662. const renderStatus = () => {
  11663. const {
  11664. status,
  11665. distance
  11666. } = state;
  11667. if (slots[status]) {
  11668. return slots[status]({
  11669. distance
  11670. });
  11671. }
  11672. const nodes = [];
  11673. if (TEXT_STATUS.includes(status)) {
  11674. nodes.push(vue.createVNode("div", {
  11675. "class": bem$h("text")
  11676. }, [getStatusText()]));
  11677. }
  11678. if (status === "loading") {
  11679. nodes.push(vue.createVNode(Loading, {
  11680. "class": bem$h("loading")
  11681. }, {
  11682. default: getStatusText
  11683. }));
  11684. }
  11685. return nodes;
  11686. };
  11687. const showSuccessTip = () => {
  11688. state.status = "success";
  11689. setTimeout(() => {
  11690. setStatus(0);
  11691. }, +props.successDuration);
  11692. };
  11693. const checkPosition = (event) => {
  11694. reachTop = getScrollTop(scrollParent.value) === 0;
  11695. if (reachTop) {
  11696. state.duration = 0;
  11697. touch.start(event);
  11698. }
  11699. };
  11700. const onTouchStart = (event) => {
  11701. if (isTouchable()) {
  11702. checkPosition(event);
  11703. }
  11704. };
  11705. const onTouchMove = (event) => {
  11706. if (isTouchable()) {
  11707. if (!reachTop) {
  11708. checkPosition(event);
  11709. }
  11710. const {
  11711. deltaY
  11712. } = touch;
  11713. touch.move(event);
  11714. if (reachTop && deltaY.value >= 0 && touch.isVertical()) {
  11715. preventDefault(event);
  11716. setStatus(ease(deltaY.value));
  11717. }
  11718. }
  11719. };
  11720. const onTouchEnd = () => {
  11721. if (reachTop && touch.deltaY.value && isTouchable()) {
  11722. state.duration = +props.animationDuration;
  11723. if (state.status === "loosing") {
  11724. setStatus(+props.headHeight, true);
  11725. emit("update:modelValue", true);
  11726. vue.nextTick(() => emit("refresh"));
  11727. } else {
  11728. setStatus(0);
  11729. }
  11730. }
  11731. };
  11732. vue.watch(() => props.modelValue, (value) => {
  11733. state.duration = +props.animationDuration;
  11734. if (value) {
  11735. setStatus(+props.headHeight, true);
  11736. } else if (slots.success || props.successText) {
  11737. showSuccessTip();
  11738. } else {
  11739. setStatus(0, false);
  11740. }
  11741. });
  11742. use.useEventListener("touchmove", onTouchMove, {
  11743. target: track
  11744. });
  11745. return () => {
  11746. var _a;
  11747. const trackStyle = {
  11748. transitionDuration: `${state.duration}ms`,
  11749. transform: state.distance ? `translate3d(0,${state.distance}px, 0)` : ""
  11750. };
  11751. return vue.createVNode("div", {
  11752. "ref": root,
  11753. "class": bem$h()
  11754. }, [vue.createVNode("div", {
  11755. "ref": track,
  11756. "class": bem$h("track"),
  11757. "style": trackStyle,
  11758. "onTouchstartPassive": onTouchStart,
  11759. "onTouchend": onTouchEnd,
  11760. "onTouchcancel": onTouchEnd
  11761. }, [vue.createVNode("div", {
  11762. "class": bem$h("head"),
  11763. "style": getHeadStyle()
  11764. }, [renderStatus()]), (_a = slots.default) == null ? void 0 : _a.call(slots)])]);
  11765. };
  11766. }
  11767. });
  11768. const PullRefresh = withInstall(stdin_default$m);
  11769. const [name$g, bem$g] = createNamespace("rate");
  11770. function getRateStatus(value, index, allowHalf, readonly) {
  11771. if (value >= index) {
  11772. return {
  11773. status: "full",
  11774. value: 1
  11775. };
  11776. }
  11777. if (value + 0.5 >= index && allowHalf && !readonly) {
  11778. return {
  11779. status: "half",
  11780. value: 0.5
  11781. };
  11782. }
  11783. if (value + 1 >= index && allowHalf && readonly) {
  11784. const cardinal = 10 ** 10;
  11785. return {
  11786. status: "half",
  11787. value: Math.round((value - index + 1) * cardinal) / cardinal
  11788. };
  11789. }
  11790. return {
  11791. status: "void",
  11792. value: 0
  11793. };
  11794. }
  11795. const rateProps = {
  11796. size: numericProp,
  11797. icon: makeStringProp("star"),
  11798. color: String,
  11799. count: makeNumericProp(5),
  11800. gutter: numericProp,
  11801. readonly: Boolean,
  11802. disabled: Boolean,
  11803. voidIcon: makeStringProp("star-o"),
  11804. allowHalf: Boolean,
  11805. voidColor: String,
  11806. touchable: truthProp,
  11807. iconPrefix: String,
  11808. modelValue: makeNumberProp(0),
  11809. disabledColor: String
  11810. };
  11811. var stdin_default$l = vue.defineComponent({
  11812. name: name$g,
  11813. props: rateProps,
  11814. emits: ["change", "update:modelValue"],
  11815. setup(props, {
  11816. emit
  11817. }) {
  11818. const touch = useTouch();
  11819. const [itemRefs, setItemRefs] = useRefs();
  11820. const groupRef = vue.ref();
  11821. const untouchable = () => props.readonly || props.disabled || !props.touchable;
  11822. const list = vue.computed(() => Array(+props.count).fill("").map((_, i) => getRateStatus(props.modelValue, i + 1, props.allowHalf, props.readonly)));
  11823. let ranges;
  11824. let groupRefRect;
  11825. let minRectTop = Number.MAX_SAFE_INTEGER;
  11826. let maxRectTop = Number.MIN_SAFE_INTEGER;
  11827. const updateRanges = () => {
  11828. groupRefRect = use.useRect(groupRef);
  11829. const rects = itemRefs.value.map(use.useRect);
  11830. ranges = [];
  11831. rects.forEach((rect, index) => {
  11832. minRectTop = Math.min(rect.top, minRectTop);
  11833. maxRectTop = Math.max(rect.top, maxRectTop);
  11834. if (props.allowHalf) {
  11835. ranges.push({
  11836. score: index + 0.5,
  11837. left: rect.left,
  11838. top: rect.top,
  11839. height: rect.height
  11840. }, {
  11841. score: index + 1,
  11842. left: rect.left + rect.width / 2,
  11843. top: rect.top,
  11844. height: rect.height
  11845. });
  11846. } else {
  11847. ranges.push({
  11848. score: index + 1,
  11849. left: rect.left,
  11850. top: rect.top,
  11851. height: rect.height
  11852. });
  11853. }
  11854. });
  11855. };
  11856. const getScoreByPosition = (x, y) => {
  11857. for (let i = ranges.length - 1; i > 0; i--) {
  11858. if (y >= groupRefRect.top && y <= groupRefRect.bottom) {
  11859. if (x > ranges[i].left && y >= ranges[i].top && y <= ranges[i].top + ranges[i].height) {
  11860. return ranges[i].score;
  11861. }
  11862. } else {
  11863. const curTop = y < groupRefRect.top ? minRectTop : maxRectTop;
  11864. if (x > ranges[i].left && ranges[i].top === curTop) {
  11865. return ranges[i].score;
  11866. }
  11867. }
  11868. }
  11869. return props.allowHalf ? 0.5 : 1;
  11870. };
  11871. const select = (index) => {
  11872. if (!props.disabled && !props.readonly && index !== props.modelValue) {
  11873. emit("update:modelValue", index);
  11874. emit("change", index);
  11875. }
  11876. };
  11877. const onTouchStart = (event) => {
  11878. if (untouchable()) {
  11879. return;
  11880. }
  11881. touch.start(event);
  11882. updateRanges();
  11883. };
  11884. const onTouchMove = (event) => {
  11885. if (untouchable()) {
  11886. return;
  11887. }
  11888. touch.move(event);
  11889. if (touch.isHorizontal()) {
  11890. const {
  11891. clientX,
  11892. clientY
  11893. } = event.touches[0];
  11894. preventDefault(event);
  11895. select(getScoreByPosition(clientX, clientY));
  11896. }
  11897. };
  11898. const renderStar = (item, index) => {
  11899. const {
  11900. icon,
  11901. size,
  11902. color,
  11903. count,
  11904. gutter,
  11905. voidIcon,
  11906. disabled,
  11907. voidColor,
  11908. allowHalf,
  11909. iconPrefix,
  11910. disabledColor
  11911. } = props;
  11912. const score = index + 1;
  11913. const isFull = item.status === "full";
  11914. const isVoid = item.status === "void";
  11915. const renderHalf = allowHalf && item.value > 0 && item.value < 1;
  11916. let style;
  11917. if (gutter && score !== +count) {
  11918. style = {
  11919. paddingRight: addUnit(gutter)
  11920. };
  11921. }
  11922. const onClickItem = (event) => {
  11923. updateRanges();
  11924. select(allowHalf ? getScoreByPosition(event.clientX, event.clientY) : score);
  11925. };
  11926. return vue.createVNode("div", {
  11927. "key": index,
  11928. "ref": setItemRefs(index),
  11929. "role": "radio",
  11930. "style": style,
  11931. "class": bem$g("item"),
  11932. "tabindex": disabled ? void 0 : 0,
  11933. "aria-setsize": count,
  11934. "aria-posinset": score,
  11935. "aria-checked": !isVoid,
  11936. "onClick": onClickItem
  11937. }, [vue.createVNode(Icon, {
  11938. "size": size,
  11939. "name": isFull ? icon : voidIcon,
  11940. "class": bem$g("icon", {
  11941. disabled,
  11942. full: isFull
  11943. }),
  11944. "color": disabled ? disabledColor : isFull ? color : voidColor,
  11945. "classPrefix": iconPrefix
  11946. }, null), renderHalf && vue.createVNode(Icon, {
  11947. "size": size,
  11948. "style": {
  11949. width: item.value + "em"
  11950. },
  11951. "name": isVoid ? voidIcon : icon,
  11952. "class": bem$g("icon", ["half", {
  11953. disabled,
  11954. full: !isVoid
  11955. }]),
  11956. "color": disabled ? disabledColor : isVoid ? voidColor : color,
  11957. "classPrefix": iconPrefix
  11958. }, null)]);
  11959. };
  11960. use.useCustomFieldValue(() => props.modelValue);
  11961. use.useEventListener("touchmove", onTouchMove, {
  11962. target: groupRef
  11963. });
  11964. return () => vue.createVNode("div", {
  11965. "ref": groupRef,
  11966. "role": "radiogroup",
  11967. "class": bem$g({
  11968. readonly: props.readonly,
  11969. disabled: props.disabled
  11970. }),
  11971. "tabindex": props.disabled ? void 0 : 0,
  11972. "aria-disabled": props.disabled,
  11973. "aria-readonly": props.readonly,
  11974. "onTouchstartPassive": onTouchStart
  11975. }, [list.value.map(renderStar)]);
  11976. }
  11977. });
  11978. const Rate = withInstall(stdin_default$l);
  11979. const Row = withInstall(stdin_default$V);
  11980. const [name$f, bem$f, t$3] = createNamespace("search");
  11981. const searchProps = extend({}, fieldSharedProps, {
  11982. label: String,
  11983. shape: makeStringProp("square"),
  11984. leftIcon: makeStringProp("search"),
  11985. clearable: truthProp,
  11986. actionText: String,
  11987. background: String,
  11988. showAction: Boolean
  11989. });
  11990. var stdin_default$k = vue.defineComponent({
  11991. name: name$f,
  11992. props: searchProps,
  11993. emits: ["blur", "focus", "clear", "search", "cancel", "click-input", "click-left-icon", "click-right-icon", "update:modelValue"],
  11994. setup(props, {
  11995. emit,
  11996. slots,
  11997. attrs
  11998. }) {
  11999. const id = useId();
  12000. const filedRef = vue.ref();
  12001. const onCancel = () => {
  12002. if (!slots.action) {
  12003. emit("update:modelValue", "");
  12004. emit("cancel");
  12005. }
  12006. };
  12007. const onKeypress = (event) => {
  12008. const ENTER_CODE = 13;
  12009. if (event.keyCode === ENTER_CODE) {
  12010. preventDefault(event);
  12011. emit("search", props.modelValue);
  12012. }
  12013. };
  12014. const getInputId = () => props.id || `${id}-input`;
  12015. const renderLabel = () => {
  12016. if (slots.label || props.label) {
  12017. return vue.createVNode("label", {
  12018. "class": bem$f("label"),
  12019. "for": getInputId()
  12020. }, [slots.label ? slots.label() : props.label]);
  12021. }
  12022. };
  12023. const renderAction = () => {
  12024. if (props.showAction) {
  12025. const text = props.actionText || t$3("cancel");
  12026. return vue.createVNode("div", {
  12027. "class": bem$f("action"),
  12028. "role": "button",
  12029. "tabindex": 0,
  12030. "onClick": onCancel
  12031. }, [slots.action ? slots.action() : text]);
  12032. }
  12033. };
  12034. const blur = () => {
  12035. var _a;
  12036. return (_a = filedRef.value) == null ? void 0 : _a.blur();
  12037. };
  12038. const focus = () => {
  12039. var _a;
  12040. return (_a = filedRef.value) == null ? void 0 : _a.focus();
  12041. };
  12042. const onBlur = (event) => emit("blur", event);
  12043. const onFocus = (event) => emit("focus", event);
  12044. const onClear = (event) => emit("clear", event);
  12045. const onClickInput = (event) => emit("click-input", event);
  12046. const onClickLeftIcon = (event) => emit("click-left-icon", event);
  12047. const onClickRightIcon = (event) => emit("click-right-icon", event);
  12048. const fieldPropNames = Object.keys(fieldSharedProps);
  12049. const renderField = () => {
  12050. const fieldAttrs = extend({}, attrs, pick(props, fieldPropNames), {
  12051. id: getInputId()
  12052. });
  12053. const onInput = (value) => emit("update:modelValue", value);
  12054. return vue.createVNode(Field, vue.mergeProps({
  12055. "ref": filedRef,
  12056. "type": "search",
  12057. "class": bem$f("field"),
  12058. "border": false,
  12059. "onBlur": onBlur,
  12060. "onFocus": onFocus,
  12061. "onClear": onClear,
  12062. "onKeypress": onKeypress,
  12063. "onClick-input": onClickInput,
  12064. "onClick-left-icon": onClickLeftIcon,
  12065. "onClick-right-icon": onClickRightIcon,
  12066. "onUpdate:modelValue": onInput
  12067. }, fieldAttrs), pick(slots, ["left-icon", "right-icon"]));
  12068. };
  12069. useExpose({
  12070. focus,
  12071. blur
  12072. });
  12073. return () => {
  12074. var _a;
  12075. return vue.createVNode("div", {
  12076. "class": bem$f({
  12077. "show-action": props.showAction
  12078. }),
  12079. "style": {
  12080. background: props.background
  12081. }
  12082. }, [(_a = slots.left) == null ? void 0 : _a.call(slots), vue.createVNode("div", {
  12083. "class": bem$f("content", props.shape)
  12084. }, [renderLabel(), renderField()]), renderAction()]);
  12085. };
  12086. }
  12087. });
  12088. const Search = withInstall(stdin_default$k);
  12089. const popupInheritKeys = [...popupSharedPropKeys, "round", "closeOnPopstate", "safeAreaInsetBottom"];
  12090. const iconMap = {
  12091. qq: "qq",
  12092. link: "link-o",
  12093. weibo: "weibo",
  12094. qrcode: "qr",
  12095. poster: "photo-o",
  12096. wechat: "wechat",
  12097. "weapp-qrcode": "miniprogram-o",
  12098. "wechat-moments": "wechat-moments"
  12099. };
  12100. const [name$e, bem$e, t$2] = createNamespace("share-sheet");
  12101. const shareSheetProps = extend({}, popupSharedProps, {
  12102. title: String,
  12103. round: truthProp,
  12104. options: makeArrayProp(),
  12105. cancelText: String,
  12106. description: String,
  12107. closeOnPopstate: truthProp,
  12108. safeAreaInsetBottom: truthProp
  12109. });
  12110. var stdin_default$j = vue.defineComponent({
  12111. name: name$e,
  12112. props: shareSheetProps,
  12113. emits: ["cancel", "select", "update:show"],
  12114. setup(props, {
  12115. emit,
  12116. slots
  12117. }) {
  12118. const updateShow = (value) => emit("update:show", value);
  12119. const onCancel = () => {
  12120. updateShow(false);
  12121. emit("cancel");
  12122. };
  12123. const onSelect = (option, index) => emit("select", option, index);
  12124. const renderHeader = () => {
  12125. const title = slots.title ? slots.title() : props.title;
  12126. const description = slots.description ? slots.description() : props.description;
  12127. if (title || description) {
  12128. return vue.createVNode("div", {
  12129. "class": bem$e("header")
  12130. }, [title && vue.createVNode("h2", {
  12131. "class": bem$e("title")
  12132. }, [title]), description && vue.createVNode("span", {
  12133. "class": bem$e("description")
  12134. }, [description])]);
  12135. }
  12136. };
  12137. const renderIcon = (icon) => {
  12138. if (iconMap[icon]) {
  12139. return vue.createVNode("div", {
  12140. "class": bem$e("icon", [icon])
  12141. }, [vue.createVNode(Icon, {
  12142. "name": iconMap[icon] || icon
  12143. }, null)]);
  12144. }
  12145. return vue.createVNode("img", {
  12146. "src": icon,
  12147. "class": bem$e("image-icon")
  12148. }, null);
  12149. };
  12150. const renderOption = (option, index) => {
  12151. const {
  12152. name: name2,
  12153. icon,
  12154. className,
  12155. description
  12156. } = option;
  12157. return vue.createVNode("div", {
  12158. "role": "button",
  12159. "tabindex": 0,
  12160. "class": [bem$e("option"), className, HAPTICS_FEEDBACK],
  12161. "onClick": () => onSelect(option, index)
  12162. }, [renderIcon(icon), name2 && vue.createVNode("span", {
  12163. "class": bem$e("name")
  12164. }, [name2]), description && vue.createVNode("span", {
  12165. "class": bem$e("option-description")
  12166. }, [description])]);
  12167. };
  12168. const renderOptions = (options, border) => vue.createVNode("div", {
  12169. "class": bem$e("options", {
  12170. border
  12171. })
  12172. }, [options.map(renderOption)]);
  12173. const renderRows = () => {
  12174. const {
  12175. options
  12176. } = props;
  12177. if (Array.isArray(options[0])) {
  12178. return options.map((item, index) => renderOptions(item, index !== 0));
  12179. }
  12180. return renderOptions(options);
  12181. };
  12182. const renderCancelButton = () => {
  12183. var _a;
  12184. const cancelText = (_a = props.cancelText) != null ? _a : t$2("cancel");
  12185. if (slots.cancel || cancelText) {
  12186. return vue.createVNode("button", {
  12187. "type": "button",
  12188. "class": bem$e("cancel"),
  12189. "onClick": onCancel
  12190. }, [slots.cancel ? slots.cancel() : cancelText]);
  12191. }
  12192. };
  12193. return () => vue.createVNode(Popup, vue.mergeProps({
  12194. "class": bem$e(),
  12195. "position": "bottom",
  12196. "onUpdate:show": updateShow
  12197. }, pick(props, popupInheritKeys)), {
  12198. default: () => [renderHeader(), renderRows(), renderCancelButton()]
  12199. });
  12200. }
  12201. });
  12202. const ShareSheet = withInstall(stdin_default$j);
  12203. const [name$d, bem$d] = createNamespace("sidebar");
  12204. const SIDEBAR_KEY = Symbol(name$d);
  12205. const sidebarProps = {
  12206. modelValue: makeNumericProp(0)
  12207. };
  12208. var stdin_default$i = vue.defineComponent({
  12209. name: name$d,
  12210. props: sidebarProps,
  12211. emits: ["change", "update:modelValue"],
  12212. setup(props, {
  12213. emit,
  12214. slots
  12215. }) {
  12216. const {
  12217. linkChildren
  12218. } = use.useChildren(SIDEBAR_KEY);
  12219. const getActive = () => +props.modelValue;
  12220. const setActive = (value) => {
  12221. if (value !== getActive()) {
  12222. emit("update:modelValue", value);
  12223. emit("change", value);
  12224. }
  12225. };
  12226. linkChildren({
  12227. getActive,
  12228. setActive
  12229. });
  12230. return () => {
  12231. var _a;
  12232. return vue.createVNode("div", {
  12233. "role": "tablist",
  12234. "class": bem$d()
  12235. }, [(_a = slots.default) == null ? void 0 : _a.call(slots)]);
  12236. };
  12237. }
  12238. });
  12239. const Sidebar = withInstall(stdin_default$i);
  12240. const [name$c, bem$c] = createNamespace("sidebar-item");
  12241. const sidebarItemProps = extend({}, routeProps, {
  12242. dot: Boolean,
  12243. title: String,
  12244. badge: numericProp,
  12245. disabled: Boolean,
  12246. badgeProps: Object
  12247. });
  12248. var stdin_default$h = vue.defineComponent({
  12249. name: name$c,
  12250. props: sidebarItemProps,
  12251. emits: ["click"],
  12252. setup(props, {
  12253. emit,
  12254. slots
  12255. }) {
  12256. const route2 = useRoute();
  12257. const {
  12258. parent,
  12259. index
  12260. } = use.useParent(SIDEBAR_KEY);
  12261. if (!parent) {
  12262. if (process.env.NODE_ENV !== "production") {
  12263. console.error("[Vant] <SidebarItem> must be a child component of <Sidebar>.");
  12264. }
  12265. return;
  12266. }
  12267. const onClick = () => {
  12268. if (props.disabled) {
  12269. return;
  12270. }
  12271. emit("click", index.value);
  12272. parent.setActive(index.value);
  12273. route2();
  12274. };
  12275. return () => {
  12276. const {
  12277. dot,
  12278. badge,
  12279. title,
  12280. disabled
  12281. } = props;
  12282. const selected = index.value === parent.getActive();
  12283. return vue.createVNode("div", {
  12284. "role": "tab",
  12285. "class": bem$c({
  12286. select: selected,
  12287. disabled
  12288. }),
  12289. "tabindex": disabled ? void 0 : 0,
  12290. "aria-selected": selected,
  12291. "onClick": onClick
  12292. }, [vue.createVNode(Badge, vue.mergeProps({
  12293. "dot": dot,
  12294. "class": bem$c("text"),
  12295. "content": badge
  12296. }, props.badgeProps), {
  12297. default: () => [slots.title ? slots.title() : title]
  12298. })]);
  12299. };
  12300. }
  12301. });
  12302. const SidebarItem = withInstall(stdin_default$h);
  12303. const [name$b, bem$b] = createNamespace("skeleton");
  12304. const DEFAULT_ROW_WIDTH = "100%";
  12305. const DEFAULT_LAST_ROW_WIDTH = "60%";
  12306. const skeletonProps = {
  12307. row: makeNumericProp(0),
  12308. title: Boolean,
  12309. round: Boolean,
  12310. avatar: Boolean,
  12311. loading: truthProp,
  12312. animate: truthProp,
  12313. avatarSize: numericProp,
  12314. titleWidth: numericProp,
  12315. avatarShape: makeStringProp("round"),
  12316. rowWidth: {
  12317. type: [Number, String, Array],
  12318. default: DEFAULT_ROW_WIDTH
  12319. }
  12320. };
  12321. var stdin_default$g = vue.defineComponent({
  12322. name: name$b,
  12323. inheritAttrs: false,
  12324. props: skeletonProps,
  12325. setup(props, {
  12326. slots,
  12327. attrs
  12328. }) {
  12329. const renderAvatar = () => {
  12330. if (props.avatar) {
  12331. return vue.createVNode("div", {
  12332. "class": bem$b("avatar", props.avatarShape),
  12333. "style": getSizeStyle(props.avatarSize)
  12334. }, null);
  12335. }
  12336. };
  12337. const renderTitle = () => {
  12338. if (props.title) {
  12339. return vue.createVNode("h3", {
  12340. "class": bem$b("title"),
  12341. "style": {
  12342. width: addUnit(props.titleWidth)
  12343. }
  12344. }, null);
  12345. }
  12346. };
  12347. const getRowWidth = (index) => {
  12348. const {
  12349. rowWidth
  12350. } = props;
  12351. if (rowWidth === DEFAULT_ROW_WIDTH && index === +props.row - 1) {
  12352. return DEFAULT_LAST_ROW_WIDTH;
  12353. }
  12354. if (Array.isArray(rowWidth)) {
  12355. return rowWidth[index];
  12356. }
  12357. return rowWidth;
  12358. };
  12359. const renderRows = () => Array(+props.row).fill("").map((_, i) => vue.createVNode("div", {
  12360. "class": bem$b("row"),
  12361. "style": {
  12362. width: addUnit(getRowWidth(i))
  12363. }
  12364. }, null));
  12365. return () => {
  12366. var _a;
  12367. if (!props.loading) {
  12368. return (_a = slots.default) == null ? void 0 : _a.call(slots);
  12369. }
  12370. return vue.createVNode("div", vue.mergeProps({
  12371. "class": bem$b({
  12372. animate: props.animate,
  12373. round: props.round
  12374. })
  12375. }, attrs), [renderAvatar(), vue.createVNode("div", {
  12376. "class": bem$b("content")
  12377. }, [renderTitle(), renderRows()])]);
  12378. };
  12379. }
  12380. });
  12381. const Skeleton = withInstall(stdin_default$g);
  12382. const [name$a, bem$a] = createNamespace("slider");
  12383. const sliderProps = {
  12384. min: makeNumericProp(0),
  12385. max: makeNumericProp(100),
  12386. step: makeNumericProp(1),
  12387. range: Boolean,
  12388. reverse: Boolean,
  12389. disabled: Boolean,
  12390. readonly: Boolean,
  12391. vertical: Boolean,
  12392. barHeight: numericProp,
  12393. buttonSize: numericProp,
  12394. activeColor: String,
  12395. inactiveColor: String,
  12396. modelValue: {
  12397. type: [Number, Array],
  12398. default: 0
  12399. }
  12400. };
  12401. var stdin_default$f = vue.defineComponent({
  12402. name: name$a,
  12403. props: sliderProps,
  12404. emits: ["change", "drag-end", "drag-start", "update:modelValue"],
  12405. setup(props, {
  12406. emit,
  12407. slots
  12408. }) {
  12409. let buttonIndex;
  12410. let current2;
  12411. let startValue;
  12412. const root = vue.ref();
  12413. const slider = vue.ref();
  12414. const dragStatus = vue.ref();
  12415. const touch = useTouch();
  12416. const scope = vue.computed(() => Number(props.max) - Number(props.min));
  12417. const wrapperStyle = vue.computed(() => {
  12418. const crossAxis = props.vertical ? "width" : "height";
  12419. return {
  12420. background: props.inactiveColor,
  12421. [crossAxis]: addUnit(props.barHeight)
  12422. };
  12423. });
  12424. const isRange = (val) => props.range && Array.isArray(val);
  12425. const calcMainAxis = () => {
  12426. const {
  12427. modelValue,
  12428. min
  12429. } = props;
  12430. if (isRange(modelValue)) {
  12431. return `${(modelValue[1] - modelValue[0]) * 100 / scope.value}%`;
  12432. }
  12433. return `${(modelValue - Number(min)) * 100 / scope.value}%`;
  12434. };
  12435. const calcOffset = () => {
  12436. const {
  12437. modelValue,
  12438. min
  12439. } = props;
  12440. if (isRange(modelValue)) {
  12441. return `${(modelValue[0] - Number(min)) * 100 / scope.value}%`;
  12442. }
  12443. return "0%";
  12444. };
  12445. const barStyle = vue.computed(() => {
  12446. const mainAxis = props.vertical ? "height" : "width";
  12447. const style = {
  12448. [mainAxis]: calcMainAxis(),
  12449. background: props.activeColor
  12450. };
  12451. if (dragStatus.value) {
  12452. style.transition = "none";
  12453. }
  12454. const getPositionKey = () => {
  12455. if (props.vertical) {
  12456. return props.reverse ? "bottom" : "top";
  12457. }
  12458. return props.reverse ? "right" : "left";
  12459. };
  12460. style[getPositionKey()] = calcOffset();
  12461. return style;
  12462. });
  12463. const format2 = (value) => {
  12464. const min = +props.min;
  12465. const max = +props.max;
  12466. const step = +props.step;
  12467. value = clamp(value, min, max);
  12468. const diff = Math.round((value - min) / step) * step;
  12469. return addNumber(min, diff);
  12470. };
  12471. const isSameValue = (newValue, oldValue) => JSON.stringify(newValue) === JSON.stringify(oldValue);
  12472. const handleRangeValue = (value) => {
  12473. var _a, _b;
  12474. const left = (_a = value[0]) != null ? _a : Number(props.min);
  12475. const right = (_b = value[1]) != null ? _b : Number(props.max);
  12476. return left > right ? [right, left] : [left, right];
  12477. };
  12478. const updateValue = (value, end) => {
  12479. if (isRange(value)) {
  12480. value = handleRangeValue(value).map(format2);
  12481. } else {
  12482. value = format2(value);
  12483. }
  12484. if (!isSameValue(value, props.modelValue)) {
  12485. emit("update:modelValue", value);
  12486. }
  12487. if (end && !isSameValue(value, startValue)) {
  12488. emit("change", value);
  12489. }
  12490. };
  12491. const onClick = (event) => {
  12492. event.stopPropagation();
  12493. if (props.disabled || props.readonly) {
  12494. return;
  12495. }
  12496. const {
  12497. min,
  12498. reverse,
  12499. vertical,
  12500. modelValue
  12501. } = props;
  12502. const rect = use.useRect(root);
  12503. const getDelta = () => {
  12504. if (vertical) {
  12505. if (reverse) {
  12506. return rect.bottom - event.clientY;
  12507. }
  12508. return event.clientY - rect.top;
  12509. }
  12510. if (reverse) {
  12511. return rect.right - event.clientX;
  12512. }
  12513. return event.clientX - rect.left;
  12514. };
  12515. const total = vertical ? rect.height : rect.width;
  12516. const value = Number(min) + getDelta() / total * scope.value;
  12517. if (isRange(modelValue)) {
  12518. const [left, right] = modelValue;
  12519. const middle = (left + right) / 2;
  12520. if (value <= middle) {
  12521. updateValue([value, right], true);
  12522. } else {
  12523. updateValue([left, value], true);
  12524. }
  12525. } else {
  12526. updateValue(value, true);
  12527. }
  12528. };
  12529. const onTouchStart = (event) => {
  12530. if (props.disabled || props.readonly) {
  12531. return;
  12532. }
  12533. touch.start(event);
  12534. current2 = props.modelValue;
  12535. if (isRange(current2)) {
  12536. startValue = current2.map(format2);
  12537. } else {
  12538. startValue = format2(current2);
  12539. }
  12540. dragStatus.value = "start";
  12541. };
  12542. const onTouchMove = (event) => {
  12543. if (props.disabled || props.readonly) {
  12544. return;
  12545. }
  12546. if (dragStatus.value === "start") {
  12547. emit("drag-start", event);
  12548. }
  12549. preventDefault(event, true);
  12550. touch.move(event);
  12551. dragStatus.value = "dragging";
  12552. const rect = use.useRect(root);
  12553. const delta = props.vertical ? touch.deltaY.value : touch.deltaX.value;
  12554. const total = props.vertical ? rect.height : rect.width;
  12555. let diff = delta / total * scope.value;
  12556. if (props.reverse) {
  12557. diff = -diff;
  12558. }
  12559. if (isRange(startValue)) {
  12560. const index = props.reverse ? 1 - buttonIndex : buttonIndex;
  12561. current2[index] = startValue[index] + diff;
  12562. } else {
  12563. current2 = startValue + diff;
  12564. }
  12565. updateValue(current2);
  12566. };
  12567. const onTouchEnd = (event) => {
  12568. if (props.disabled || props.readonly) {
  12569. return;
  12570. }
  12571. if (dragStatus.value === "dragging") {
  12572. updateValue(current2, true);
  12573. emit("drag-end", event);
  12574. }
  12575. dragStatus.value = "";
  12576. };
  12577. const getButtonClassName = (index) => {
  12578. if (typeof index === "number") {
  12579. const position = ["left", "right"];
  12580. return bem$a(`button-wrapper`, position[index]);
  12581. }
  12582. return bem$a("button-wrapper", props.reverse ? "left" : "right");
  12583. };
  12584. const renderButtonContent = (value, index) => {
  12585. if (typeof index === "number") {
  12586. const slot = slots[index === 0 ? "left-button" : "right-button"];
  12587. if (slot) {
  12588. return slot({
  12589. value
  12590. });
  12591. }
  12592. }
  12593. if (slots.button) {
  12594. return slots.button({
  12595. value
  12596. });
  12597. }
  12598. return vue.createVNode("div", {
  12599. "class": bem$a("button"),
  12600. "style": getSizeStyle(props.buttonSize)
  12601. }, null);
  12602. };
  12603. const renderButton = (index) => {
  12604. const current22 = typeof index === "number" ? props.modelValue[index] : props.modelValue;
  12605. return vue.createVNode("div", {
  12606. "ref": slider,
  12607. "role": "slider",
  12608. "class": getButtonClassName(index),
  12609. "tabindex": props.disabled ? void 0 : 0,
  12610. "aria-valuemin": props.min,
  12611. "aria-valuenow": current22,
  12612. "aria-valuemax": props.max,
  12613. "aria-disabled": props.disabled || void 0,
  12614. "aria-readonly": props.readonly || void 0,
  12615. "aria-orientation": props.vertical ? "vertical" : "horizontal",
  12616. "onTouchstartPassive": (event) => {
  12617. if (typeof index === "number") {
  12618. buttonIndex = index;
  12619. }
  12620. onTouchStart(event);
  12621. },
  12622. "onTouchend": onTouchEnd,
  12623. "onTouchcancel": onTouchEnd,
  12624. "onClick": stopPropagation
  12625. }, [renderButtonContent(current22, index)]);
  12626. };
  12627. updateValue(props.modelValue);
  12628. use.useCustomFieldValue(() => props.modelValue);
  12629. use.useEventListener("touchmove", onTouchMove, {
  12630. target: slider
  12631. });
  12632. return () => vue.createVNode("div", {
  12633. "ref": root,
  12634. "style": wrapperStyle.value,
  12635. "class": bem$a({
  12636. vertical: props.vertical,
  12637. disabled: props.disabled
  12638. }),
  12639. "onClick": onClick
  12640. }, [vue.createVNode("div", {
  12641. "class": bem$a("bar"),
  12642. "style": barStyle.value
  12643. }, [props.range ? [renderButton(0), renderButton(1)] : renderButton()])]);
  12644. }
  12645. });
  12646. const Slider = withInstall(stdin_default$f);
  12647. const [name$9, bem$9] = createNamespace("space");
  12648. const spaceProps = {
  12649. align: String,
  12650. direction: {
  12651. type: String,
  12652. default: "horizontal"
  12653. },
  12654. size: {
  12655. type: [Number, String, Array],
  12656. default: 8
  12657. },
  12658. wrap: Boolean,
  12659. fill: Boolean
  12660. };
  12661. function filterEmpty(children = []) {
  12662. const nodes = [];
  12663. children.forEach((child) => {
  12664. if (Array.isArray(child)) {
  12665. nodes.push(...child);
  12666. } else if (child.type === vue.Fragment) {
  12667. nodes.push(...filterEmpty(child.children));
  12668. } else {
  12669. nodes.push(child);
  12670. }
  12671. });
  12672. return nodes.filter((c) => {
  12673. var _a;
  12674. 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() === ""));
  12675. });
  12676. }
  12677. var stdin_default$e = vue.defineComponent({
  12678. name: name$9,
  12679. props: spaceProps,
  12680. setup(props, {
  12681. slots
  12682. }) {
  12683. const mergedAlign = vue.computed(() => {
  12684. var _a;
  12685. return (_a = props.align) != null ? _a : props.direction === "horizontal" ? "center" : "";
  12686. });
  12687. const getMargin = (size) => {
  12688. if (typeof size === "number") {
  12689. return size + "px";
  12690. }
  12691. return size;
  12692. };
  12693. const getMarginStyle = (isLast) => {
  12694. const style = {};
  12695. const marginRight = `${getMargin(Array.isArray(props.size) ? props.size[0] : props.size)}`;
  12696. const marginBottom = `${getMargin(Array.isArray(props.size) ? props.size[1] : props.size)}`;
  12697. if (isLast) {
  12698. return props.wrap ? {
  12699. marginBottom
  12700. } : {};
  12701. }
  12702. if (props.direction === "horizontal") {
  12703. style.marginRight = marginRight;
  12704. }
  12705. if (props.direction === "vertical" || props.wrap) {
  12706. style.marginBottom = marginBottom;
  12707. }
  12708. return style;
  12709. };
  12710. return () => {
  12711. var _a;
  12712. const children = filterEmpty((_a = slots.default) == null ? void 0 : _a.call(slots));
  12713. return vue.createVNode("div", {
  12714. "class": [bem$9({
  12715. [props.direction]: props.direction,
  12716. [`align-${mergedAlign.value}`]: mergedAlign.value,
  12717. wrap: props.wrap,
  12718. fill: props.fill
  12719. })]
  12720. }, [children.map((c, i) => vue.createVNode("div", {
  12721. "key": `item-${i}`,
  12722. "class": `${name$9}-item`,
  12723. "style": getMarginStyle(i === children.length - 1)
  12724. }, [c]))]);
  12725. };
  12726. }
  12727. });
  12728. const Space = withInstall(stdin_default$e);
  12729. const [name$8, bem$8] = createNamespace("steps");
  12730. const stepsProps = {
  12731. active: makeNumericProp(0),
  12732. direction: makeStringProp("horizontal"),
  12733. activeIcon: makeStringProp("checked"),
  12734. iconPrefix: String,
  12735. finishIcon: String,
  12736. activeColor: String,
  12737. inactiveIcon: String,
  12738. inactiveColor: String
  12739. };
  12740. const STEPS_KEY = Symbol(name$8);
  12741. var stdin_default$d = vue.defineComponent({
  12742. name: name$8,
  12743. props: stepsProps,
  12744. emits: ["click-step"],
  12745. setup(props, {
  12746. emit,
  12747. slots
  12748. }) {
  12749. const {
  12750. linkChildren
  12751. } = use.useChildren(STEPS_KEY);
  12752. const onClickStep = (index) => emit("click-step", index);
  12753. linkChildren({
  12754. props,
  12755. onClickStep
  12756. });
  12757. return () => {
  12758. var _a;
  12759. return vue.createVNode("div", {
  12760. "class": bem$8([props.direction])
  12761. }, [vue.createVNode("div", {
  12762. "class": bem$8("items")
  12763. }, [(_a = slots.default) == null ? void 0 : _a.call(slots)])]);
  12764. };
  12765. }
  12766. });
  12767. const [name$7, bem$7] = createNamespace("step");
  12768. var stdin_default$c = vue.defineComponent({
  12769. name: name$7,
  12770. setup(props, {
  12771. slots
  12772. }) {
  12773. const {
  12774. parent,
  12775. index
  12776. } = use.useParent(STEPS_KEY);
  12777. if (!parent) {
  12778. if (process.env.NODE_ENV !== "production") {
  12779. console.error("[Vant] <Step> must be a child component of <Steps>.");
  12780. }
  12781. return;
  12782. }
  12783. const parentProps = parent.props;
  12784. const getStatus = () => {
  12785. const active = +parentProps.active;
  12786. if (index.value < active) {
  12787. return "finish";
  12788. }
  12789. return index.value === active ? "process" : "waiting";
  12790. };
  12791. const isActive = () => getStatus() === "process";
  12792. const lineStyle = vue.computed(() => ({
  12793. background: getStatus() === "finish" ? parentProps.activeColor : parentProps.inactiveColor
  12794. }));
  12795. const titleStyle = vue.computed(() => {
  12796. if (isActive()) {
  12797. return {
  12798. color: parentProps.activeColor
  12799. };
  12800. }
  12801. if (getStatus() === "waiting") {
  12802. return {
  12803. color: parentProps.inactiveColor
  12804. };
  12805. }
  12806. });
  12807. const onClickStep = () => parent.onClickStep(index.value);
  12808. const renderCircle = () => {
  12809. const {
  12810. iconPrefix,
  12811. finishIcon,
  12812. activeIcon,
  12813. activeColor,
  12814. inactiveIcon
  12815. } = parentProps;
  12816. if (isActive()) {
  12817. if (slots["active-icon"]) {
  12818. return slots["active-icon"]();
  12819. }
  12820. return vue.createVNode(Icon, {
  12821. "class": bem$7("icon", "active"),
  12822. "name": activeIcon,
  12823. "color": activeColor,
  12824. "classPrefix": iconPrefix
  12825. }, null);
  12826. }
  12827. if (getStatus() === "finish" && (finishIcon || slots["finish-icon"])) {
  12828. if (slots["finish-icon"]) {
  12829. return slots["finish-icon"]();
  12830. }
  12831. return vue.createVNode(Icon, {
  12832. "class": bem$7("icon", "finish"),
  12833. "name": finishIcon,
  12834. "color": activeColor,
  12835. "classPrefix": iconPrefix
  12836. }, null);
  12837. }
  12838. if (slots["inactive-icon"]) {
  12839. return slots["inactive-icon"]();
  12840. }
  12841. if (inactiveIcon) {
  12842. return vue.createVNode(Icon, {
  12843. "class": bem$7("icon"),
  12844. "name": inactiveIcon,
  12845. "classPrefix": iconPrefix
  12846. }, null);
  12847. }
  12848. return vue.createVNode("i", {
  12849. "class": bem$7("circle"),
  12850. "style": lineStyle.value
  12851. }, null);
  12852. };
  12853. return () => {
  12854. var _a;
  12855. const status = getStatus();
  12856. return vue.createVNode("div", {
  12857. "class": [BORDER, bem$7([parentProps.direction, {
  12858. [status]: status
  12859. }])]
  12860. }, [vue.createVNode("div", {
  12861. "class": bem$7("title", {
  12862. active: isActive()
  12863. }),
  12864. "style": titleStyle.value,
  12865. "onClick": onClickStep
  12866. }, [(_a = slots.default) == null ? void 0 : _a.call(slots)]), vue.createVNode("div", {
  12867. "class": bem$7("circle-container"),
  12868. "onClick": onClickStep
  12869. }, [renderCircle()]), vue.createVNode("div", {
  12870. "class": bem$7("line"),
  12871. "style": lineStyle.value
  12872. }, null)]);
  12873. };
  12874. }
  12875. });
  12876. const Step = withInstall(stdin_default$c);
  12877. const [name$6, bem$6] = createNamespace("stepper");
  12878. const LONG_PRESS_INTERVAL = 200;
  12879. const LONG_PRESS_START_TIME = 600;
  12880. const isEqual = (value1, value2) => String(value1) === String(value2);
  12881. const stepperProps = {
  12882. min: makeNumericProp(1),
  12883. max: makeNumericProp(Infinity),
  12884. name: makeNumericProp(""),
  12885. step: makeNumericProp(1),
  12886. theme: String,
  12887. integer: Boolean,
  12888. disabled: Boolean,
  12889. showPlus: truthProp,
  12890. showMinus: truthProp,
  12891. showInput: truthProp,
  12892. longPress: truthProp,
  12893. allowEmpty: Boolean,
  12894. modelValue: numericProp,
  12895. inputWidth: numericProp,
  12896. buttonSize: numericProp,
  12897. placeholder: String,
  12898. disablePlus: Boolean,
  12899. disableMinus: Boolean,
  12900. disableInput: Boolean,
  12901. beforeChange: Function,
  12902. defaultValue: makeNumericProp(1),
  12903. decimalLength: numericProp
  12904. };
  12905. var stdin_default$b = vue.defineComponent({
  12906. name: name$6,
  12907. props: stepperProps,
  12908. emits: ["plus", "blur", "minus", "focus", "change", "overlimit", "update:modelValue"],
  12909. setup(props, {
  12910. emit
  12911. }) {
  12912. const format2 = (value) => {
  12913. const {
  12914. min,
  12915. max,
  12916. allowEmpty,
  12917. decimalLength
  12918. } = props;
  12919. if (allowEmpty && value === "") {
  12920. return value;
  12921. }
  12922. value = formatNumber(String(value), !props.integer);
  12923. value = value === "" ? 0 : +value;
  12924. value = Number.isNaN(value) ? +min : value;
  12925. value = Math.max(Math.min(+max, value), +min);
  12926. if (isDef(decimalLength)) {
  12927. value = value.toFixed(+decimalLength);
  12928. }
  12929. return value;
  12930. };
  12931. const getInitialValue = () => {
  12932. var _a;
  12933. const defaultValue = (_a = props.modelValue) != null ? _a : props.defaultValue;
  12934. const value = format2(defaultValue);
  12935. if (!isEqual(value, props.modelValue)) {
  12936. emit("update:modelValue", value);
  12937. }
  12938. return value;
  12939. };
  12940. let actionType;
  12941. const inputRef = vue.ref();
  12942. const current2 = vue.ref(getInitialValue());
  12943. const minusDisabled = vue.computed(() => props.disabled || props.disableMinus || current2.value <= +props.min);
  12944. const plusDisabled = vue.computed(() => props.disabled || props.disablePlus || current2.value >= +props.max);
  12945. const inputStyle = vue.computed(() => ({
  12946. width: addUnit(props.inputWidth),
  12947. height: addUnit(props.buttonSize)
  12948. }));
  12949. const buttonStyle = vue.computed(() => getSizeStyle(props.buttonSize));
  12950. const check = () => {
  12951. const value = format2(current2.value);
  12952. if (!isEqual(value, current2.value)) {
  12953. current2.value = value;
  12954. }
  12955. };
  12956. const setValue = (value) => {
  12957. if (props.beforeChange) {
  12958. callInterceptor(props.beforeChange, {
  12959. args: [value],
  12960. done() {
  12961. current2.value = value;
  12962. }
  12963. });
  12964. } else {
  12965. current2.value = value;
  12966. }
  12967. };
  12968. const onChange = () => {
  12969. if (actionType === "plus" && plusDisabled.value || actionType === "minus" && minusDisabled.value) {
  12970. emit("overlimit", actionType);
  12971. return;
  12972. }
  12973. const diff = actionType === "minus" ? -props.step : +props.step;
  12974. const value = format2(addNumber(+current2.value, diff));
  12975. setValue(value);
  12976. emit(actionType);
  12977. };
  12978. const onInput = (event) => {
  12979. const input = event.target;
  12980. const {
  12981. value
  12982. } = input;
  12983. const {
  12984. decimalLength
  12985. } = props;
  12986. let formatted = formatNumber(String(value), !props.integer);
  12987. if (isDef(decimalLength) && formatted.includes(".")) {
  12988. const pair = formatted.split(".");
  12989. formatted = `${pair[0]}.${pair[1].slice(0, +decimalLength)}`;
  12990. }
  12991. if (props.beforeChange) {
  12992. input.value = String(current2.value);
  12993. } else if (!isEqual(value, formatted)) {
  12994. input.value = formatted;
  12995. }
  12996. const isNumeric2 = formatted === String(+formatted);
  12997. setValue(isNumeric2 ? +formatted : formatted);
  12998. };
  12999. const onFocus = (event) => {
  13000. var _a;
  13001. if (props.disableInput) {
  13002. (_a = inputRef.value) == null ? void 0 : _a.blur();
  13003. } else {
  13004. emit("focus", event);
  13005. }
  13006. };
  13007. const onBlur = (event) => {
  13008. const input = event.target;
  13009. const value = format2(input.value);
  13010. input.value = String(value);
  13011. current2.value = value;
  13012. vue.nextTick(() => {
  13013. emit("blur", event);
  13014. resetScroll();
  13015. });
  13016. };
  13017. let isLongPress;
  13018. let longPressTimer;
  13019. const longPressStep = () => {
  13020. longPressTimer = setTimeout(() => {
  13021. onChange();
  13022. longPressStep();
  13023. }, LONG_PRESS_INTERVAL);
  13024. };
  13025. const onTouchStart = () => {
  13026. if (props.longPress) {
  13027. isLongPress = false;
  13028. clearTimeout(longPressTimer);
  13029. longPressTimer = setTimeout(() => {
  13030. isLongPress = true;
  13031. onChange();
  13032. longPressStep();
  13033. }, LONG_PRESS_START_TIME);
  13034. }
  13035. };
  13036. const onTouchEnd = (event) => {
  13037. if (props.longPress) {
  13038. clearTimeout(longPressTimer);
  13039. if (isLongPress) {
  13040. preventDefault(event);
  13041. }
  13042. }
  13043. };
  13044. const onMousedown = (event) => {
  13045. if (props.disableInput) {
  13046. preventDefault(event);
  13047. }
  13048. };
  13049. const createListeners = (type) => ({
  13050. onClick: (event) => {
  13051. preventDefault(event);
  13052. actionType = type;
  13053. onChange();
  13054. },
  13055. onTouchstartPassive: () => {
  13056. actionType = type;
  13057. onTouchStart();
  13058. },
  13059. onTouchend: onTouchEnd,
  13060. onTouchcancel: onTouchEnd
  13061. });
  13062. vue.watch(() => [props.max, props.min, props.integer, props.decimalLength], check);
  13063. vue.watch(() => props.modelValue, (value) => {
  13064. if (!isEqual(value, current2.value)) {
  13065. current2.value = format2(value);
  13066. }
  13067. });
  13068. vue.watch(current2, (value) => {
  13069. emit("update:modelValue", value);
  13070. emit("change", value, {
  13071. name: props.name
  13072. });
  13073. });
  13074. use.useCustomFieldValue(() => props.modelValue);
  13075. return () => vue.createVNode("div", {
  13076. "role": "group",
  13077. "class": bem$6([props.theme])
  13078. }, [vue.withDirectives(vue.createVNode("button", vue.mergeProps({
  13079. "type": "button",
  13080. "style": buttonStyle.value,
  13081. "class": [bem$6("minus", {
  13082. disabled: minusDisabled.value
  13083. }), {
  13084. [HAPTICS_FEEDBACK]: !minusDisabled.value
  13085. }],
  13086. "aria-disabled": minusDisabled.value || void 0
  13087. }, createListeners("minus")), null), [[vue.vShow, props.showMinus]]), vue.withDirectives(vue.createVNode("input", {
  13088. "ref": inputRef,
  13089. "type": props.integer ? "tel" : "text",
  13090. "role": "spinbutton",
  13091. "class": bem$6("input"),
  13092. "value": current2.value,
  13093. "style": inputStyle.value,
  13094. "disabled": props.disabled,
  13095. "readonly": props.disableInput,
  13096. "inputmode": props.integer ? "numeric" : "decimal",
  13097. "placeholder": props.placeholder,
  13098. "aria-valuemax": props.max,
  13099. "aria-valuemin": props.min,
  13100. "aria-valuenow": current2.value,
  13101. "onBlur": onBlur,
  13102. "onInput": onInput,
  13103. "onFocus": onFocus,
  13104. "onMousedown": onMousedown
  13105. }, null), [[vue.vShow, props.showInput]]), vue.withDirectives(vue.createVNode("button", vue.mergeProps({
  13106. "type": "button",
  13107. "style": buttonStyle.value,
  13108. "class": [bem$6("plus", {
  13109. disabled: plusDisabled.value
  13110. }), {
  13111. [HAPTICS_FEEDBACK]: !plusDisabled.value
  13112. }],
  13113. "aria-disabled": plusDisabled.value || void 0
  13114. }, createListeners("plus")), null), [[vue.vShow, props.showPlus]])]);
  13115. }
  13116. });
  13117. const Stepper = withInstall(stdin_default$b);
  13118. const Steps = withInstall(stdin_default$d);
  13119. const [name$5, bem$5, t$1] = createNamespace("submit-bar");
  13120. const submitBarProps = {
  13121. tip: String,
  13122. label: String,
  13123. price: Number,
  13124. tipIcon: String,
  13125. loading: Boolean,
  13126. currency: makeStringProp("\xA5"),
  13127. disabled: Boolean,
  13128. textAlign: String,
  13129. buttonText: String,
  13130. buttonType: makeStringProp("danger"),
  13131. buttonColor: String,
  13132. suffixLabel: String,
  13133. placeholder: Boolean,
  13134. decimalLength: makeNumericProp(2),
  13135. safeAreaInsetBottom: truthProp
  13136. };
  13137. var stdin_default$a = vue.defineComponent({
  13138. name: name$5,
  13139. props: submitBarProps,
  13140. emits: ["submit"],
  13141. setup(props, {
  13142. emit,
  13143. slots
  13144. }) {
  13145. const root = vue.ref();
  13146. const renderPlaceholder = usePlaceholder(root, bem$5);
  13147. const renderText = () => {
  13148. const {
  13149. price,
  13150. label,
  13151. currency,
  13152. textAlign,
  13153. suffixLabel,
  13154. decimalLength
  13155. } = props;
  13156. if (typeof price === "number") {
  13157. const pricePair = (price / 100).toFixed(+decimalLength).split(".");
  13158. const decimal = decimalLength ? `.${pricePair[1]}` : "";
  13159. return vue.createVNode("div", {
  13160. "class": bem$5("text"),
  13161. "style": {
  13162. textAlign
  13163. }
  13164. }, [vue.createVNode("span", null, [label || t$1("label")]), vue.createVNode("span", {
  13165. "class": bem$5("price")
  13166. }, [currency, vue.createVNode("span", {
  13167. "class": bem$5("price-integer")
  13168. }, [pricePair[0]]), decimal]), suffixLabel && vue.createVNode("span", {
  13169. "class": bem$5("suffix-label")
  13170. }, [suffixLabel])]);
  13171. }
  13172. };
  13173. const renderTip = () => {
  13174. var _a;
  13175. const {
  13176. tip,
  13177. tipIcon
  13178. } = props;
  13179. if (slots.tip || tip) {
  13180. return vue.createVNode("div", {
  13181. "class": bem$5("tip")
  13182. }, [tipIcon && vue.createVNode(Icon, {
  13183. "class": bem$5("tip-icon"),
  13184. "name": tipIcon
  13185. }, null), tip && vue.createVNode("span", {
  13186. "class": bem$5("tip-text")
  13187. }, [tip]), (_a = slots.tip) == null ? void 0 : _a.call(slots)]);
  13188. }
  13189. };
  13190. const onClickButton = () => emit("submit");
  13191. const renderButton = () => {
  13192. if (slots.button) {
  13193. return slots.button();
  13194. }
  13195. return vue.createVNode(Button, {
  13196. "round": true,
  13197. "type": props.buttonType,
  13198. "text": props.buttonText,
  13199. "class": bem$5("button", props.buttonType),
  13200. "color": props.buttonColor,
  13201. "loading": props.loading,
  13202. "disabled": props.disabled,
  13203. "onClick": onClickButton
  13204. }, null);
  13205. };
  13206. const renderSubmitBar = () => {
  13207. var _a, _b;
  13208. return vue.createVNode("div", {
  13209. "ref": root,
  13210. "class": [bem$5(), {
  13211. "van-safe-area-bottom": props.safeAreaInsetBottom
  13212. }]
  13213. }, [(_a = slots.top) == null ? void 0 : _a.call(slots), renderTip(), vue.createVNode("div", {
  13214. "class": bem$5("bar")
  13215. }, [(_b = slots.default) == null ? void 0 : _b.call(slots), renderText(), renderButton()])]);
  13216. };
  13217. return () => {
  13218. if (props.placeholder) {
  13219. return renderPlaceholder(renderSubmitBar);
  13220. }
  13221. return renderSubmitBar();
  13222. };
  13223. }
  13224. });
  13225. const SubmitBar = withInstall(stdin_default$a);
  13226. const [name$4, bem$4] = createNamespace("swipe-cell");
  13227. const swipeCellProps = {
  13228. name: makeNumericProp(""),
  13229. disabled: Boolean,
  13230. leftWidth: numericProp,
  13231. rightWidth: numericProp,
  13232. beforeClose: Function,
  13233. stopPropagation: Boolean
  13234. };
  13235. var stdin_default$9 = vue.defineComponent({
  13236. name: name$4,
  13237. props: swipeCellProps,
  13238. emits: ["open", "close", "click"],
  13239. setup(props, {
  13240. emit,
  13241. slots
  13242. }) {
  13243. let opened;
  13244. let lockClick2;
  13245. let startOffset;
  13246. const root = vue.ref();
  13247. const leftRef = vue.ref();
  13248. const rightRef = vue.ref();
  13249. const state = vue.reactive({
  13250. offset: 0,
  13251. dragging: false
  13252. });
  13253. const touch = useTouch();
  13254. const getWidthByRef = (ref2) => ref2.value ? use.useRect(ref2).width : 0;
  13255. const leftWidth = vue.computed(() => isDef(props.leftWidth) ? +props.leftWidth : getWidthByRef(leftRef));
  13256. const rightWidth = vue.computed(() => isDef(props.rightWidth) ? +props.rightWidth : getWidthByRef(rightRef));
  13257. const open = (side) => {
  13258. state.offset = side === "left" ? leftWidth.value : -rightWidth.value;
  13259. if (!opened) {
  13260. opened = true;
  13261. emit("open", {
  13262. name: props.name,
  13263. position: side
  13264. });
  13265. }
  13266. };
  13267. const close = (position) => {
  13268. state.offset = 0;
  13269. if (opened) {
  13270. opened = false;
  13271. emit("close", {
  13272. name: props.name,
  13273. position
  13274. });
  13275. }
  13276. };
  13277. const toggle = (side) => {
  13278. const offset = Math.abs(state.offset);
  13279. const THRESHOLD = 0.15;
  13280. const threshold = opened ? 1 - THRESHOLD : THRESHOLD;
  13281. const width = side === "left" ? leftWidth.value : rightWidth.value;
  13282. if (width && offset > width * threshold) {
  13283. open(side);
  13284. } else {
  13285. close(side);
  13286. }
  13287. };
  13288. const onTouchStart = (event) => {
  13289. if (!props.disabled) {
  13290. startOffset = state.offset;
  13291. touch.start(event);
  13292. }
  13293. };
  13294. const onTouchMove = (event) => {
  13295. if (props.disabled) {
  13296. return;
  13297. }
  13298. const {
  13299. deltaX
  13300. } = touch;
  13301. touch.move(event);
  13302. if (touch.isHorizontal()) {
  13303. lockClick2 = true;
  13304. state.dragging = true;
  13305. const isEdge = !opened || deltaX.value * startOffset < 0;
  13306. if (isEdge) {
  13307. preventDefault(event, props.stopPropagation);
  13308. }
  13309. state.offset = clamp(deltaX.value + startOffset, -rightWidth.value, leftWidth.value);
  13310. }
  13311. };
  13312. const onTouchEnd = () => {
  13313. if (state.dragging) {
  13314. state.dragging = false;
  13315. toggle(state.offset > 0 ? "left" : "right");
  13316. setTimeout(() => {
  13317. lockClick2 = false;
  13318. }, 0);
  13319. }
  13320. };
  13321. const onClick = (position = "outside") => {
  13322. emit("click", position);
  13323. if (opened && !lockClick2) {
  13324. callInterceptor(props.beforeClose, {
  13325. args: [{
  13326. name: props.name,
  13327. position
  13328. }],
  13329. done: () => close(position)
  13330. });
  13331. }
  13332. };
  13333. const getClickHandler = (position, stop) => (event) => {
  13334. if (stop) {
  13335. event.stopPropagation();
  13336. }
  13337. onClick(position);
  13338. };
  13339. const renderSideContent = (side, ref2) => {
  13340. const contentSlot = slots[side];
  13341. if (contentSlot) {
  13342. return vue.createVNode("div", {
  13343. "ref": ref2,
  13344. "class": bem$4(side),
  13345. "onClick": getClickHandler(side, true)
  13346. }, [contentSlot()]);
  13347. }
  13348. };
  13349. useExpose({
  13350. open,
  13351. close
  13352. });
  13353. use.useClickAway(root, () => onClick("outside"), {
  13354. eventName: "touchstart"
  13355. });
  13356. use.useEventListener("touchmove", onTouchMove, {
  13357. target: root
  13358. });
  13359. return () => {
  13360. var _a;
  13361. const wrapperStyle = {
  13362. transform: `translate3d(${state.offset}px, 0, 0)`,
  13363. transitionDuration: state.dragging ? "0s" : ".6s"
  13364. };
  13365. return vue.createVNode("div", {
  13366. "ref": root,
  13367. "class": bem$4(),
  13368. "onClick": getClickHandler("cell", lockClick2),
  13369. "onTouchstartPassive": onTouchStart,
  13370. "onTouchend": onTouchEnd,
  13371. "onTouchcancel": onTouchEnd
  13372. }, [vue.createVNode("div", {
  13373. "class": bem$4("wrapper"),
  13374. "style": wrapperStyle
  13375. }, [renderSideContent("left", leftRef), (_a = slots.default) == null ? void 0 : _a.call(slots), renderSideContent("right", rightRef)])]);
  13376. };
  13377. }
  13378. });
  13379. const SwipeCell = withInstall(stdin_default$9);
  13380. const [name$3, bem$3] = createNamespace("tabbar");
  13381. const tabbarProps = {
  13382. route: Boolean,
  13383. fixed: truthProp,
  13384. border: truthProp,
  13385. zIndex: numericProp,
  13386. placeholder: Boolean,
  13387. activeColor: String,
  13388. beforeChange: Function,
  13389. inactiveColor: String,
  13390. modelValue: makeNumericProp(0),
  13391. safeAreaInsetBottom: {
  13392. type: Boolean,
  13393. default: null
  13394. }
  13395. };
  13396. const TABBAR_KEY = Symbol(name$3);
  13397. var stdin_default$8 = vue.defineComponent({
  13398. name: name$3,
  13399. props: tabbarProps,
  13400. emits: ["change", "update:modelValue"],
  13401. setup(props, {
  13402. emit,
  13403. slots
  13404. }) {
  13405. const root = vue.ref();
  13406. const {
  13407. linkChildren
  13408. } = use.useChildren(TABBAR_KEY);
  13409. const renderPlaceholder = usePlaceholder(root, bem$3);
  13410. const enableSafeArea = () => {
  13411. var _a;
  13412. return (_a = props.safeAreaInsetBottom) != null ? _a : props.fixed;
  13413. };
  13414. const renderTabbar = () => {
  13415. var _a;
  13416. const {
  13417. fixed,
  13418. zIndex,
  13419. border
  13420. } = props;
  13421. return vue.createVNode("div", {
  13422. "ref": root,
  13423. "role": "tablist",
  13424. "style": getZIndexStyle(zIndex),
  13425. "class": [bem$3({
  13426. fixed
  13427. }), {
  13428. [BORDER_TOP_BOTTOM]: border,
  13429. "van-safe-area-bottom": enableSafeArea()
  13430. }]
  13431. }, [(_a = slots.default) == null ? void 0 : _a.call(slots)]);
  13432. };
  13433. const setActive = (active, afterChange) => {
  13434. callInterceptor(props.beforeChange, {
  13435. args: [active],
  13436. done() {
  13437. emit("update:modelValue", active);
  13438. emit("change", active);
  13439. afterChange();
  13440. }
  13441. });
  13442. };
  13443. linkChildren({
  13444. props,
  13445. setActive
  13446. });
  13447. return () => {
  13448. if (props.fixed && props.placeholder) {
  13449. return renderPlaceholder(renderTabbar);
  13450. }
  13451. return renderTabbar();
  13452. };
  13453. }
  13454. });
  13455. const Tabbar = withInstall(stdin_default$8);
  13456. const [name$2, bem$2] = createNamespace("tabbar-item");
  13457. const tabbarItemProps = extend({}, routeProps, {
  13458. dot: Boolean,
  13459. icon: String,
  13460. name: numericProp,
  13461. badge: numericProp,
  13462. badgeProps: Object,
  13463. iconPrefix: String
  13464. });
  13465. var stdin_default$7 = vue.defineComponent({
  13466. name: name$2,
  13467. props: tabbarItemProps,
  13468. emits: ["click"],
  13469. setup(props, {
  13470. emit,
  13471. slots
  13472. }) {
  13473. const route2 = useRoute();
  13474. const vm = vue.getCurrentInstance().proxy;
  13475. const {
  13476. parent,
  13477. index
  13478. } = use.useParent(TABBAR_KEY);
  13479. if (!parent) {
  13480. if (process.env.NODE_ENV !== "production") {
  13481. console.error("[Vant] <TabbarItem> must be a child component of <Tabbar>.");
  13482. }
  13483. return;
  13484. }
  13485. const active = vue.computed(() => {
  13486. var _a;
  13487. const {
  13488. route: route22,
  13489. modelValue
  13490. } = parent.props;
  13491. if (route22 && "$route" in vm) {
  13492. const {
  13493. $route
  13494. } = vm;
  13495. const {
  13496. to
  13497. } = props;
  13498. const config = isObject(to) ? to : {
  13499. path: to
  13500. };
  13501. return !!$route.matched.find((val) => {
  13502. const pathMatched = "path" in config && config.path === val.path;
  13503. const nameMatched = "name" in config && config.name === val.name;
  13504. return pathMatched || nameMatched;
  13505. });
  13506. }
  13507. return ((_a = props.name) != null ? _a : index.value) === modelValue;
  13508. });
  13509. const onClick = (event) => {
  13510. var _a;
  13511. if (!active.value) {
  13512. parent.setActive((_a = props.name) != null ? _a : index.value, route2);
  13513. }
  13514. emit("click", event);
  13515. };
  13516. const renderIcon = () => {
  13517. if (slots.icon) {
  13518. return slots.icon({
  13519. active: active.value
  13520. });
  13521. }
  13522. if (props.icon) {
  13523. return vue.createVNode(Icon, {
  13524. "name": props.icon,
  13525. "classPrefix": props.iconPrefix
  13526. }, null);
  13527. }
  13528. };
  13529. return () => {
  13530. var _a;
  13531. const {
  13532. dot,
  13533. badge
  13534. } = props;
  13535. const {
  13536. activeColor,
  13537. inactiveColor
  13538. } = parent.props;
  13539. const color = active.value ? activeColor : inactiveColor;
  13540. return vue.createVNode("div", {
  13541. "role": "tab",
  13542. "class": bem$2({
  13543. active: active.value
  13544. }),
  13545. "style": {
  13546. color
  13547. },
  13548. "tabindex": 0,
  13549. "aria-selected": active.value,
  13550. "onClick": onClick
  13551. }, [vue.createVNode(Badge, vue.mergeProps({
  13552. "dot": dot,
  13553. "class": bem$2("icon"),
  13554. "content": badge
  13555. }, props.badgeProps), {
  13556. default: renderIcon
  13557. }), vue.createVNode("div", {
  13558. "class": bem$2("text")
  13559. }, [(_a = slots.default) == null ? void 0 : _a.call(slots, {
  13560. active: active.value
  13561. })])]);
  13562. };
  13563. }
  13564. });
  13565. const TabbarItem = withInstall(stdin_default$7);
  13566. const [name$1, bem$1] = createNamespace("tree-select");
  13567. const treeSelectProps = {
  13568. max: makeNumericProp(Infinity),
  13569. items: makeArrayProp(),
  13570. height: makeNumericProp(300),
  13571. selectedIcon: makeStringProp("success"),
  13572. mainActiveIndex: makeNumericProp(0),
  13573. activeId: {
  13574. type: [Number, String, Array],
  13575. default: 0
  13576. }
  13577. };
  13578. var stdin_default$6 = vue.defineComponent({
  13579. name: name$1,
  13580. props: treeSelectProps,
  13581. emits: ["click-nav", "click-item", "update:activeId", "update:mainActiveIndex"],
  13582. setup(props, {
  13583. emit,
  13584. slots
  13585. }) {
  13586. const isActiveItem = (id) => Array.isArray(props.activeId) ? props.activeId.includes(id) : props.activeId === id;
  13587. const renderSubItem = (item) => {
  13588. const onClick = () => {
  13589. if (item.disabled) {
  13590. return;
  13591. }
  13592. let activeId;
  13593. if (Array.isArray(props.activeId)) {
  13594. activeId = props.activeId.slice();
  13595. const index = activeId.indexOf(item.id);
  13596. if (index !== -1) {
  13597. activeId.splice(index, 1);
  13598. } else if (activeId.length < props.max) {
  13599. activeId.push(item.id);
  13600. }
  13601. } else {
  13602. activeId = item.id;
  13603. }
  13604. emit("update:activeId", activeId);
  13605. emit("click-item", item);
  13606. };
  13607. return vue.createVNode("div", {
  13608. "key": item.id,
  13609. "class": ["van-ellipsis", bem$1("item", {
  13610. active: isActiveItem(item.id),
  13611. disabled: item.disabled
  13612. })],
  13613. "onClick": onClick
  13614. }, [item.text, isActiveItem(item.id) && vue.createVNode(Icon, {
  13615. "name": props.selectedIcon,
  13616. "class": bem$1("selected")
  13617. }, null)]);
  13618. };
  13619. const onSidebarChange = (index) => {
  13620. emit("update:mainActiveIndex", index);
  13621. };
  13622. const onClickSidebarItem = (index) => emit("click-nav", index);
  13623. const renderSidebar = () => {
  13624. const Items = props.items.map((item) => vue.createVNode(SidebarItem, {
  13625. "dot": item.dot,
  13626. "title": item.text,
  13627. "badge": item.badge,
  13628. "class": [bem$1("nav-item"), item.className],
  13629. "disabled": item.disabled,
  13630. "onClick": onClickSidebarItem
  13631. }, null));
  13632. return vue.createVNode(Sidebar, {
  13633. "class": bem$1("nav"),
  13634. "modelValue": props.mainActiveIndex,
  13635. "onChange": onSidebarChange
  13636. }, {
  13637. default: () => [Items]
  13638. });
  13639. };
  13640. const renderContent = () => {
  13641. if (slots.content) {
  13642. return slots.content();
  13643. }
  13644. const selected = props.items[+props.mainActiveIndex] || {};
  13645. if (selected.children) {
  13646. return selected.children.map(renderSubItem);
  13647. }
  13648. };
  13649. return () => vue.createVNode("div", {
  13650. "class": bem$1(),
  13651. "style": {
  13652. height: addUnit(props.height)
  13653. }
  13654. }, [renderSidebar(), vue.createVNode("div", {
  13655. "class": bem$1("content")
  13656. }, [renderContent()])]);
  13657. }
  13658. });
  13659. const TreeSelect = withInstall(stdin_default$6);
  13660. const [name, bem, t] = createNamespace("uploader");
  13661. function readFileContent(file, resultType) {
  13662. return new Promise((resolve) => {
  13663. if (resultType === "file") {
  13664. resolve();
  13665. return;
  13666. }
  13667. const reader = new FileReader();
  13668. reader.onload = (event) => {
  13669. resolve(event.target.result);
  13670. };
  13671. if (resultType === "dataUrl") {
  13672. reader.readAsDataURL(file);
  13673. } else if (resultType === "text") {
  13674. reader.readAsText(file);
  13675. }
  13676. });
  13677. }
  13678. function isOversize(items, maxSize) {
  13679. return toArray(items).some((item) => {
  13680. if (item.file) {
  13681. if (isFunction(maxSize)) {
  13682. return maxSize(item.file);
  13683. }
  13684. return item.file.size > maxSize;
  13685. }
  13686. return false;
  13687. });
  13688. }
  13689. function filterFiles(items, maxSize) {
  13690. const valid = [];
  13691. const invalid = [];
  13692. items.forEach((item) => {
  13693. if (isOversize(item, maxSize)) {
  13694. invalid.push(item);
  13695. } else {
  13696. valid.push(item);
  13697. }
  13698. });
  13699. return { valid, invalid };
  13700. }
  13701. const IMAGE_REGEXP = /\.(jpeg|jpg|gif|png|svg|webp|jfif|bmp|dpg)/i;
  13702. const isImageUrl = (url) => IMAGE_REGEXP.test(url);
  13703. function isImageFile(item) {
  13704. if (item.isImage) {
  13705. return true;
  13706. }
  13707. if (item.file && item.file.type) {
  13708. return item.file.type.indexOf("image") === 0;
  13709. }
  13710. if (item.url) {
  13711. return isImageUrl(item.url);
  13712. }
  13713. if (typeof item.content === "string") {
  13714. return item.content.indexOf("data:image") === 0;
  13715. }
  13716. return false;
  13717. }
  13718. var stdin_default$5 = vue.defineComponent({
  13719. props: {
  13720. name: numericProp,
  13721. item: makeRequiredProp(Object),
  13722. index: Number,
  13723. imageFit: String,
  13724. lazyLoad: Boolean,
  13725. deletable: Boolean,
  13726. previewSize: [Number, String, Array],
  13727. beforeDelete: Function
  13728. },
  13729. emits: ["delete", "preview"],
  13730. setup(props, {
  13731. emit,
  13732. slots
  13733. }) {
  13734. const renderMask = () => {
  13735. const {
  13736. status,
  13737. message
  13738. } = props.item;
  13739. if (status === "uploading" || status === "failed") {
  13740. const MaskIcon = status === "failed" ? vue.createVNode(Icon, {
  13741. "name": "close",
  13742. "class": bem("mask-icon")
  13743. }, null) : vue.createVNode(Loading, {
  13744. "class": bem("loading")
  13745. }, null);
  13746. const showMessage = isDef(message) && message !== "";
  13747. return vue.createVNode("div", {
  13748. "class": bem("mask")
  13749. }, [MaskIcon, showMessage && vue.createVNode("div", {
  13750. "class": bem("mask-message")
  13751. }, [message])]);
  13752. }
  13753. };
  13754. const onDelete = (event) => {
  13755. const {
  13756. name: name2,
  13757. item,
  13758. index,
  13759. beforeDelete
  13760. } = props;
  13761. event.stopPropagation();
  13762. callInterceptor(beforeDelete, {
  13763. args: [item, {
  13764. name: name2,
  13765. index
  13766. }],
  13767. done: () => emit("delete")
  13768. });
  13769. };
  13770. const onPreview = () => emit("preview");
  13771. const renderDeleteIcon = () => {
  13772. if (props.deletable && props.item.status !== "uploading") {
  13773. const slot = slots["preview-delete"];
  13774. return vue.createVNode("div", {
  13775. "role": "button",
  13776. "class": bem("preview-delete", {
  13777. shadow: !slot
  13778. }),
  13779. "tabindex": 0,
  13780. "aria-label": t("delete"),
  13781. "onClick": onDelete
  13782. }, [slot ? slot() : vue.createVNode(Icon, {
  13783. "name": "cross",
  13784. "class": bem("preview-delete-icon")
  13785. }, null)]);
  13786. }
  13787. };
  13788. const renderCover = () => {
  13789. if (slots["preview-cover"]) {
  13790. const {
  13791. index,
  13792. item
  13793. } = props;
  13794. return vue.createVNode("div", {
  13795. "class": bem("preview-cover")
  13796. }, [slots["preview-cover"](extend({
  13797. index
  13798. }, item))]);
  13799. }
  13800. };
  13801. const renderPreview = () => {
  13802. const {
  13803. item,
  13804. lazyLoad,
  13805. imageFit,
  13806. previewSize
  13807. } = props;
  13808. if (isImageFile(item)) {
  13809. return vue.createVNode(Image$1, {
  13810. "fit": imageFit,
  13811. "src": item.content || item.url,
  13812. "class": bem("preview-image"),
  13813. "width": Array.isArray(previewSize) ? previewSize[0] : previewSize,
  13814. "height": Array.isArray(previewSize) ? previewSize[1] : previewSize,
  13815. "lazyLoad": lazyLoad,
  13816. "onClick": onPreview
  13817. }, {
  13818. default: renderCover
  13819. });
  13820. }
  13821. return vue.createVNode("div", {
  13822. "class": bem("file"),
  13823. "style": getSizeStyle(props.previewSize)
  13824. }, [vue.createVNode(Icon, {
  13825. "class": bem("file-icon"),
  13826. "name": "description"
  13827. }, null), vue.createVNode("div", {
  13828. "class": [bem("file-name"), "van-ellipsis"]
  13829. }, [item.file ? item.file.name : item.url]), renderCover()]);
  13830. };
  13831. return () => vue.createVNode("div", {
  13832. "class": bem("preview")
  13833. }, [renderPreview(), renderMask(), renderDeleteIcon()]);
  13834. }
  13835. });
  13836. const uploaderProps = {
  13837. name: makeNumericProp(""),
  13838. accept: makeStringProp("image/*"),
  13839. capture: String,
  13840. multiple: Boolean,
  13841. disabled: Boolean,
  13842. readonly: Boolean,
  13843. lazyLoad: Boolean,
  13844. maxCount: makeNumericProp(Infinity),
  13845. imageFit: makeStringProp("cover"),
  13846. resultType: makeStringProp("dataUrl"),
  13847. uploadIcon: makeStringProp("photograph"),
  13848. uploadText: String,
  13849. deletable: truthProp,
  13850. afterRead: Function,
  13851. showUpload: truthProp,
  13852. modelValue: makeArrayProp(),
  13853. beforeRead: Function,
  13854. beforeDelete: Function,
  13855. previewSize: [Number, String, Array],
  13856. previewImage: truthProp,
  13857. previewOptions: Object,
  13858. previewFullImage: truthProp,
  13859. maxSize: {
  13860. type: [Number, String, Function],
  13861. default: Infinity
  13862. }
  13863. };
  13864. var stdin_default$4 = vue.defineComponent({
  13865. name,
  13866. props: uploaderProps,
  13867. emits: ["delete", "oversize", "click-upload", "close-preview", "click-preview", "update:modelValue"],
  13868. setup(props, {
  13869. emit,
  13870. slots
  13871. }) {
  13872. const inputRef = vue.ref();
  13873. const urls = [];
  13874. const getDetail = (index = props.modelValue.length) => ({
  13875. name: props.name,
  13876. index
  13877. });
  13878. const resetInput = () => {
  13879. if (inputRef.value) {
  13880. inputRef.value.value = "";
  13881. }
  13882. };
  13883. const onAfterRead = (items) => {
  13884. resetInput();
  13885. if (isOversize(items, props.maxSize)) {
  13886. if (Array.isArray(items)) {
  13887. const result = filterFiles(items, props.maxSize);
  13888. items = result.valid;
  13889. emit("oversize", result.invalid, getDetail());
  13890. if (!items.length) {
  13891. return;
  13892. }
  13893. } else {
  13894. emit("oversize", items, getDetail());
  13895. return;
  13896. }
  13897. }
  13898. items = vue.reactive(items);
  13899. emit("update:modelValue", [...props.modelValue, ...toArray(items)]);
  13900. if (props.afterRead) {
  13901. props.afterRead(items, getDetail());
  13902. }
  13903. };
  13904. const readFile = (files) => {
  13905. const {
  13906. maxCount,
  13907. modelValue,
  13908. resultType
  13909. } = props;
  13910. if (Array.isArray(files)) {
  13911. const remainCount = +maxCount - modelValue.length;
  13912. if (files.length > remainCount) {
  13913. files = files.slice(0, remainCount);
  13914. }
  13915. Promise.all(files.map((file) => readFileContent(file, resultType))).then((contents) => {
  13916. const fileList = files.map((file, index) => {
  13917. const result = {
  13918. file,
  13919. status: "",
  13920. message: ""
  13921. };
  13922. if (contents[index]) {
  13923. result.content = contents[index];
  13924. }
  13925. return result;
  13926. });
  13927. onAfterRead(fileList);
  13928. });
  13929. } else {
  13930. readFileContent(files, resultType).then((content) => {
  13931. const result = {
  13932. file: files,
  13933. status: "",
  13934. message: ""
  13935. };
  13936. if (content) {
  13937. result.content = content;
  13938. }
  13939. onAfterRead(result);
  13940. });
  13941. }
  13942. };
  13943. const onChange = (event) => {
  13944. const {
  13945. files
  13946. } = event.target;
  13947. if (props.disabled || !files || !files.length) {
  13948. return;
  13949. }
  13950. const file = files.length === 1 ? files[0] : [].slice.call(files);
  13951. if (props.beforeRead) {
  13952. const response = props.beforeRead(file, getDetail());
  13953. if (!response) {
  13954. resetInput();
  13955. return;
  13956. }
  13957. if (isPromise(response)) {
  13958. response.then((data) => {
  13959. if (data) {
  13960. readFile(data);
  13961. } else {
  13962. readFile(file);
  13963. }
  13964. }).catch(resetInput);
  13965. return;
  13966. }
  13967. }
  13968. readFile(file);
  13969. };
  13970. let imagePreview;
  13971. const onClosePreview = () => emit("close-preview");
  13972. const previewImage = (item) => {
  13973. if (props.previewFullImage) {
  13974. const imageFiles = props.modelValue.filter(isImageFile);
  13975. const images = imageFiles.map((item2) => {
  13976. if (item2.file && !item2.url && item2.status !== "failed") {
  13977. item2.url = URL.createObjectURL(item2.file);
  13978. urls.push(item2.url);
  13979. }
  13980. return item2.url;
  13981. }).filter(Boolean);
  13982. imagePreview = ImagePreview(extend({
  13983. images,
  13984. startPosition: imageFiles.indexOf(item),
  13985. onClose: onClosePreview
  13986. }, props.previewOptions));
  13987. }
  13988. };
  13989. const closeImagePreview = () => {
  13990. if (imagePreview) {
  13991. imagePreview.close();
  13992. }
  13993. };
  13994. const deleteFile = (item, index) => {
  13995. const fileList = props.modelValue.slice(0);
  13996. fileList.splice(index, 1);
  13997. emit("update:modelValue", fileList);
  13998. emit("delete", item, getDetail(index));
  13999. };
  14000. const renderPreviewItem = (item, index) => {
  14001. const needPickData = ["imageFit", "deletable", "previewSize", "beforeDelete"];
  14002. const previewData = extend(pick(props, needPickData), pick(item, needPickData, true));
  14003. return vue.createVNode(stdin_default$5, vue.mergeProps({
  14004. "item": item,
  14005. "index": index,
  14006. "onClick": () => emit("click-preview", item, getDetail(index)),
  14007. "onDelete": () => deleteFile(item, index),
  14008. "onPreview": () => previewImage(item)
  14009. }, pick(props, ["name", "lazyLoad"]), previewData), pick(slots, ["preview-cover", "preview-delete"]));
  14010. };
  14011. const renderPreviewList = () => {
  14012. if (props.previewImage) {
  14013. return props.modelValue.map(renderPreviewItem);
  14014. }
  14015. };
  14016. const onClickUpload = (event) => emit("click-upload", event);
  14017. const renderUpload = () => {
  14018. if (props.modelValue.length >= props.maxCount || !props.showUpload) {
  14019. return;
  14020. }
  14021. const Input = props.readonly ? null : vue.createVNode("input", {
  14022. "ref": inputRef,
  14023. "type": "file",
  14024. "class": bem("input"),
  14025. "accept": props.accept,
  14026. "capture": props.capture,
  14027. "multiple": props.multiple,
  14028. "disabled": props.disabled,
  14029. "onChange": onChange
  14030. }, null);
  14031. if (slots.default) {
  14032. return vue.createVNode("div", {
  14033. "class": bem("input-wrapper"),
  14034. "onClick": onClickUpload
  14035. }, [slots.default(), Input]);
  14036. }
  14037. return vue.createVNode("div", {
  14038. "class": bem("upload", {
  14039. readonly: props.readonly
  14040. }),
  14041. "style": getSizeStyle(props.previewSize),
  14042. "onClick": onClickUpload
  14043. }, [vue.createVNode(Icon, {
  14044. "name": props.uploadIcon,
  14045. "class": bem("upload-icon")
  14046. }, null), props.uploadText && vue.createVNode("span", {
  14047. "class": bem("upload-text")
  14048. }, [props.uploadText]), Input]);
  14049. };
  14050. const chooseFile = () => {
  14051. if (inputRef.value && !props.disabled) {
  14052. inputRef.value.click();
  14053. }
  14054. };
  14055. vue.onBeforeUnmount(() => {
  14056. urls.forEach((url) => URL.revokeObjectURL(url));
  14057. });
  14058. useExpose({
  14059. chooseFile,
  14060. closeImagePreview
  14061. });
  14062. use.useCustomFieldValue(() => props.modelValue);
  14063. return () => vue.createVNode("div", {
  14064. "class": bem()
  14065. }, [vue.createVNode("div", {
  14066. "class": bem("wrapper", {
  14067. disabled: props.disabled
  14068. })
  14069. }, [renderPreviewList(), renderUpload()])]);
  14070. }
  14071. });
  14072. const Uploader = withInstall(stdin_default$4);
  14073. const hasIntersectionObserver = use.inBrowser && "IntersectionObserver" in window && "IntersectionObserverEntry" in window && "intersectionRatio" in window.IntersectionObserverEntry.prototype;
  14074. const modeType = {
  14075. event: "event",
  14076. observer: "observer"
  14077. };
  14078. function remove(arr, item) {
  14079. if (!arr.length)
  14080. return;
  14081. const index = arr.indexOf(item);
  14082. if (index > -1)
  14083. return arr.splice(index, 1);
  14084. }
  14085. function getBestSelectionFromSrcset(el, scale) {
  14086. if (el.tagName !== "IMG" || !el.getAttribute("data-srcset"))
  14087. return;
  14088. let options = el.getAttribute("data-srcset");
  14089. const container = el.parentNode;
  14090. const containerWidth = container.offsetWidth * scale;
  14091. let spaceIndex;
  14092. let tmpSrc;
  14093. let tmpWidth;
  14094. options = options.trim().split(",");
  14095. const result = options.map((item) => {
  14096. item = item.trim();
  14097. spaceIndex = item.lastIndexOf(" ");
  14098. if (spaceIndex === -1) {
  14099. tmpSrc = item;
  14100. tmpWidth = 999998;
  14101. } else {
  14102. tmpSrc = item.substr(0, spaceIndex);
  14103. tmpWidth = parseInt(
  14104. item.substr(spaceIndex + 1, item.length - spaceIndex - 2),
  14105. 10
  14106. );
  14107. }
  14108. return [tmpWidth, tmpSrc];
  14109. });
  14110. result.sort((a, b) => {
  14111. if (a[0] < b[0]) {
  14112. return 1;
  14113. }
  14114. if (a[0] > b[0]) {
  14115. return -1;
  14116. }
  14117. if (a[0] === b[0]) {
  14118. if (b[1].indexOf(".webp", b[1].length - 5) !== -1) {
  14119. return 1;
  14120. }
  14121. if (a[1].indexOf(".webp", a[1].length - 5) !== -1) {
  14122. return -1;
  14123. }
  14124. }
  14125. return 0;
  14126. });
  14127. let bestSelectedSrc = "";
  14128. let tmpOption;
  14129. for (let i = 0; i < result.length; i++) {
  14130. tmpOption = result[i];
  14131. bestSelectedSrc = tmpOption[1];
  14132. const next = result[i + 1];
  14133. if (next && next[0] < containerWidth) {
  14134. bestSelectedSrc = tmpOption[1];
  14135. break;
  14136. } else if (!next) {
  14137. bestSelectedSrc = tmpOption[1];
  14138. break;
  14139. }
  14140. }
  14141. return bestSelectedSrc;
  14142. }
  14143. const getDPR = (scale = 1) => use.inBrowser ? window.devicePixelRatio || scale : scale;
  14144. function supportWebp() {
  14145. if (!use.inBrowser)
  14146. return false;
  14147. let support = true;
  14148. try {
  14149. const elem = document.createElement("canvas");
  14150. if (elem.getContext && elem.getContext("2d")) {
  14151. support = elem.toDataURL("image/webp").indexOf("data:image/webp") === 0;
  14152. }
  14153. } catch (err) {
  14154. support = false;
  14155. }
  14156. return support;
  14157. }
  14158. function throttle(action, delay) {
  14159. let timeout = null;
  14160. let lastRun = 0;
  14161. return function(...args) {
  14162. if (timeout) {
  14163. return;
  14164. }
  14165. const elapsed = Date.now() - lastRun;
  14166. const runCallback = () => {
  14167. lastRun = Date.now();
  14168. timeout = false;
  14169. action.apply(this, args);
  14170. };
  14171. if (elapsed >= delay) {
  14172. runCallback();
  14173. } else {
  14174. timeout = setTimeout(runCallback, delay);
  14175. }
  14176. };
  14177. }
  14178. function on(el, type, func) {
  14179. el.addEventListener(type, func, {
  14180. capture: false,
  14181. passive: true
  14182. });
  14183. }
  14184. function off(el, type, func) {
  14185. el.removeEventListener(type, func, false);
  14186. }
  14187. const loadImageAsync = (item, resolve, reject) => {
  14188. const image = new Image();
  14189. if (!item || !item.src) {
  14190. return reject(new Error("image src is required"));
  14191. }
  14192. image.src = item.src;
  14193. if (item.cors) {
  14194. image.crossOrigin = item.cors;
  14195. }
  14196. image.onload = () => resolve({
  14197. naturalHeight: image.naturalHeight,
  14198. naturalWidth: image.naturalWidth,
  14199. src: image.src
  14200. });
  14201. image.onerror = (e) => reject(e);
  14202. };
  14203. class ImageCache {
  14204. constructor({ max }) {
  14205. this.options = {
  14206. max: max || 100
  14207. };
  14208. this.caches = [];
  14209. }
  14210. has(key) {
  14211. return this.caches.indexOf(key) > -1;
  14212. }
  14213. add(key) {
  14214. if (this.has(key))
  14215. return;
  14216. this.caches.push(key);
  14217. if (this.caches.length > this.options.max) {
  14218. this.free();
  14219. }
  14220. }
  14221. free() {
  14222. this.caches.shift();
  14223. }
  14224. }
  14225. class ReactiveListener {
  14226. constructor({
  14227. el,
  14228. src,
  14229. error,
  14230. loading,
  14231. bindType,
  14232. $parent,
  14233. options,
  14234. cors,
  14235. elRenderer,
  14236. imageCache
  14237. }) {
  14238. this.el = el;
  14239. this.src = src;
  14240. this.error = error;
  14241. this.loading = loading;
  14242. this.bindType = bindType;
  14243. this.attempt = 0;
  14244. this.cors = cors;
  14245. this.naturalHeight = 0;
  14246. this.naturalWidth = 0;
  14247. this.options = options;
  14248. this.$parent = $parent;
  14249. this.elRenderer = elRenderer;
  14250. this.imageCache = imageCache;
  14251. this.performanceData = {
  14252. loadStart: 0,
  14253. loadEnd: 0
  14254. };
  14255. this.filter();
  14256. this.initState();
  14257. this.render("loading", false);
  14258. }
  14259. initState() {
  14260. if ("dataset" in this.el) {
  14261. this.el.dataset.src = this.src;
  14262. } else {
  14263. this.el.setAttribute("data-src", this.src);
  14264. }
  14265. this.state = {
  14266. loading: false,
  14267. error: false,
  14268. loaded: false,
  14269. rendered: false
  14270. };
  14271. }
  14272. record(event) {
  14273. this.performanceData[event] = Date.now();
  14274. }
  14275. update({ src, loading, error }) {
  14276. const oldSrc = this.src;
  14277. this.src = src;
  14278. this.loading = loading;
  14279. this.error = error;
  14280. this.filter();
  14281. if (oldSrc !== this.src) {
  14282. this.attempt = 0;
  14283. this.initState();
  14284. }
  14285. }
  14286. checkInView() {
  14287. const rect = use.useRect(this.el);
  14288. return rect.top < window.innerHeight * this.options.preLoad && rect.bottom > this.options.preLoadTop && rect.left < window.innerWidth * this.options.preLoad && rect.right > 0;
  14289. }
  14290. filter() {
  14291. Object.keys(this.options.filter).forEach((key) => {
  14292. this.options.filter[key](this, this.options);
  14293. });
  14294. }
  14295. renderLoading(cb) {
  14296. this.state.loading = true;
  14297. loadImageAsync(
  14298. {
  14299. src: this.loading,
  14300. cors: this.cors
  14301. },
  14302. () => {
  14303. this.render("loading", false);
  14304. this.state.loading = false;
  14305. cb();
  14306. },
  14307. () => {
  14308. cb();
  14309. this.state.loading = false;
  14310. if (process.env.NODE_ENV !== "production" && !this.options.silent)
  14311. console.warn(
  14312. `[@vant/lazyload] load failed with loading image(${this.loading})`
  14313. );
  14314. }
  14315. );
  14316. }
  14317. load(onFinish = noop) {
  14318. if (this.attempt > this.options.attempt - 1 && this.state.error) {
  14319. if (process.env.NODE_ENV !== "production" && !this.options.silent) {
  14320. console.log(
  14321. `[@vant/lazyload] ${this.src} tried too more than ${this.options.attempt} times`
  14322. );
  14323. }
  14324. onFinish();
  14325. return;
  14326. }
  14327. if (this.state.rendered && this.state.loaded)
  14328. return;
  14329. if (this.imageCache.has(this.src)) {
  14330. this.state.loaded = true;
  14331. this.render("loaded", true);
  14332. this.state.rendered = true;
  14333. return onFinish();
  14334. }
  14335. this.renderLoading(() => {
  14336. var _a, _b;
  14337. this.attempt++;
  14338. (_b = (_a = this.options.adapter).beforeLoad) == null ? void 0 : _b.call(_a, this, this.options);
  14339. this.record("loadStart");
  14340. loadImageAsync(
  14341. {
  14342. src: this.src,
  14343. cors: this.cors
  14344. },
  14345. (data) => {
  14346. this.naturalHeight = data.naturalHeight;
  14347. this.naturalWidth = data.naturalWidth;
  14348. this.state.loaded = true;
  14349. this.state.error = false;
  14350. this.record("loadEnd");
  14351. this.render("loaded", false);
  14352. this.state.rendered = true;
  14353. this.imageCache.add(this.src);
  14354. onFinish();
  14355. },
  14356. (err) => {
  14357. !this.options.silent && console.error(err);
  14358. this.state.error = true;
  14359. this.state.loaded = false;
  14360. this.render("error", false);
  14361. }
  14362. );
  14363. });
  14364. }
  14365. render(state, cache) {
  14366. this.elRenderer(this, state, cache);
  14367. }
  14368. performance() {
  14369. let state = "loading";
  14370. let time = 0;
  14371. if (this.state.loaded) {
  14372. state = "loaded";
  14373. time = (this.performanceData.loadEnd - this.performanceData.loadStart) / 1e3;
  14374. }
  14375. if (this.state.error)
  14376. state = "error";
  14377. return {
  14378. src: this.src,
  14379. state,
  14380. time
  14381. };
  14382. }
  14383. $destroy() {
  14384. this.el = null;
  14385. this.src = null;
  14386. this.error = null;
  14387. this.loading = null;
  14388. this.bindType = null;
  14389. this.attempt = 0;
  14390. }
  14391. }
  14392. const DEFAULT_URL = "data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7";
  14393. const DEFAULT_EVENTS = [
  14394. "scroll",
  14395. "wheel",
  14396. "mousewheel",
  14397. "resize",
  14398. "animationend",
  14399. "transitionend",
  14400. "touchmove"
  14401. ];
  14402. const DEFAULT_OBSERVER_OPTIONS = {
  14403. rootMargin: "0px",
  14404. threshold: 0
  14405. };
  14406. function stdin_default$3() {
  14407. return class Lazy {
  14408. constructor({
  14409. preLoad,
  14410. error,
  14411. throttleWait,
  14412. preLoadTop,
  14413. dispatchEvent,
  14414. loading,
  14415. attempt,
  14416. silent = true,
  14417. scale,
  14418. listenEvents,
  14419. filter,
  14420. adapter,
  14421. observer,
  14422. observerOptions
  14423. }) {
  14424. this.mode = modeType.event;
  14425. this.listeners = [];
  14426. this.targetIndex = 0;
  14427. this.targets = [];
  14428. this.options = {
  14429. silent,
  14430. dispatchEvent: !!dispatchEvent,
  14431. throttleWait: throttleWait || 200,
  14432. preLoad: preLoad || 1.3,
  14433. preLoadTop: preLoadTop || 0,
  14434. error: error || DEFAULT_URL,
  14435. loading: loading || DEFAULT_URL,
  14436. attempt: attempt || 3,
  14437. scale: scale || getDPR(scale),
  14438. ListenEvents: listenEvents || DEFAULT_EVENTS,
  14439. supportWebp: supportWebp(),
  14440. filter: filter || {},
  14441. adapter: adapter || {},
  14442. observer: !!observer,
  14443. observerOptions: observerOptions || DEFAULT_OBSERVER_OPTIONS
  14444. };
  14445. this.initEvent();
  14446. this.imageCache = new ImageCache({ max: 200 });
  14447. this.lazyLoadHandler = throttle(
  14448. this.lazyLoadHandler.bind(this),
  14449. this.options.throttleWait
  14450. );
  14451. this.setMode(this.options.observer ? modeType.observer : modeType.event);
  14452. }
  14453. config(options = {}) {
  14454. Object.assign(this.options, options);
  14455. }
  14456. performance() {
  14457. return this.listeners.map((item) => item.performance());
  14458. }
  14459. addLazyBox(vm) {
  14460. this.listeners.push(vm);
  14461. if (use.inBrowser) {
  14462. this.addListenerTarget(window);
  14463. this.observer && this.observer.observe(vm.el);
  14464. if (vm.$el && vm.$el.parentNode) {
  14465. this.addListenerTarget(vm.$el.parentNode);
  14466. }
  14467. }
  14468. }
  14469. add(el, binding, vnode) {
  14470. if (this.listeners.some((item) => item.el === el)) {
  14471. this.update(el, binding);
  14472. return vue.nextTick(this.lazyLoadHandler);
  14473. }
  14474. const value = this.valueFormatter(binding.value);
  14475. let { src } = value;
  14476. vue.nextTick(() => {
  14477. src = getBestSelectionFromSrcset(el, this.options.scale) || src;
  14478. this.observer && this.observer.observe(el);
  14479. const container = Object.keys(binding.modifiers)[0];
  14480. let $parent;
  14481. if (container) {
  14482. $parent = vnode.context.$refs[container];
  14483. $parent = $parent ? $parent.$el || $parent : document.getElementById(container);
  14484. }
  14485. if (!$parent) {
  14486. $parent = use.getScrollParent(el);
  14487. }
  14488. const newListener = new ReactiveListener({
  14489. bindType: binding.arg,
  14490. $parent,
  14491. el,
  14492. src,
  14493. loading: value.loading,
  14494. error: value.error,
  14495. cors: value.cors,
  14496. elRenderer: this.elRenderer.bind(this),
  14497. options: this.options,
  14498. imageCache: this.imageCache
  14499. });
  14500. this.listeners.push(newListener);
  14501. if (use.inBrowser) {
  14502. this.addListenerTarget(window);
  14503. this.addListenerTarget($parent);
  14504. }
  14505. this.lazyLoadHandler();
  14506. vue.nextTick(() => this.lazyLoadHandler());
  14507. });
  14508. }
  14509. update(el, binding, vnode) {
  14510. const value = this.valueFormatter(binding.value);
  14511. let { src } = value;
  14512. src = getBestSelectionFromSrcset(el, this.options.scale) || src;
  14513. const exist = this.listeners.find((item) => item.el === el);
  14514. if (!exist) {
  14515. this.add(el, binding, vnode);
  14516. } else {
  14517. exist.update({
  14518. src,
  14519. error: value.error,
  14520. loading: value.loading
  14521. });
  14522. }
  14523. if (this.observer) {
  14524. this.observer.unobserve(el);
  14525. this.observer.observe(el);
  14526. }
  14527. this.lazyLoadHandler();
  14528. vue.nextTick(() => this.lazyLoadHandler());
  14529. }
  14530. remove(el) {
  14531. if (!el)
  14532. return;
  14533. this.observer && this.observer.unobserve(el);
  14534. const existItem = this.listeners.find((item) => item.el === el);
  14535. if (existItem) {
  14536. this.removeListenerTarget(existItem.$parent);
  14537. this.removeListenerTarget(window);
  14538. remove(this.listeners, existItem);
  14539. existItem.$destroy();
  14540. }
  14541. }
  14542. removeComponent(vm) {
  14543. if (!vm)
  14544. return;
  14545. remove(this.listeners, vm);
  14546. this.observer && this.observer.unobserve(vm.el);
  14547. if (vm.$parent && vm.$el.parentNode) {
  14548. this.removeListenerTarget(vm.$el.parentNode);
  14549. }
  14550. this.removeListenerTarget(window);
  14551. }
  14552. setMode(mode) {
  14553. if (!hasIntersectionObserver && mode === modeType.observer) {
  14554. mode = modeType.event;
  14555. }
  14556. this.mode = mode;
  14557. if (mode === modeType.event) {
  14558. if (this.observer) {
  14559. this.listeners.forEach((listener) => {
  14560. this.observer.unobserve(listener.el);
  14561. });
  14562. this.observer = null;
  14563. }
  14564. this.targets.forEach((target) => {
  14565. this.initListen(target.el, true);
  14566. });
  14567. } else {
  14568. this.targets.forEach((target) => {
  14569. this.initListen(target.el, false);
  14570. });
  14571. this.initIntersectionObserver();
  14572. }
  14573. }
  14574. addListenerTarget(el) {
  14575. if (!el)
  14576. return;
  14577. let target = this.targets.find((target2) => target2.el === el);
  14578. if (!target) {
  14579. target = {
  14580. el,
  14581. id: ++this.targetIndex,
  14582. childrenCount: 1,
  14583. listened: true
  14584. };
  14585. this.mode === modeType.event && this.initListen(target.el, true);
  14586. this.targets.push(target);
  14587. } else {
  14588. target.childrenCount++;
  14589. }
  14590. return this.targetIndex;
  14591. }
  14592. removeListenerTarget(el) {
  14593. this.targets.forEach((target, index) => {
  14594. if (target.el === el) {
  14595. target.childrenCount--;
  14596. if (!target.childrenCount) {
  14597. this.initListen(target.el, false);
  14598. this.targets.splice(index, 1);
  14599. target = null;
  14600. }
  14601. }
  14602. });
  14603. }
  14604. initListen(el, start) {
  14605. this.options.ListenEvents.forEach(
  14606. (evt) => (start ? on : off)(el, evt, this.lazyLoadHandler)
  14607. );
  14608. }
  14609. initEvent() {
  14610. this.Event = {
  14611. listeners: {
  14612. loading: [],
  14613. loaded: [],
  14614. error: []
  14615. }
  14616. };
  14617. this.$on = (event, func) => {
  14618. if (!this.Event.listeners[event])
  14619. this.Event.listeners[event] = [];
  14620. this.Event.listeners[event].push(func);
  14621. };
  14622. this.$once = (event, func) => {
  14623. const on2 = (...args) => {
  14624. this.$off(event, on2);
  14625. func.apply(this, args);
  14626. };
  14627. this.$on(event, on2);
  14628. };
  14629. this.$off = (event, func) => {
  14630. if (!func) {
  14631. if (!this.Event.listeners[event])
  14632. return;
  14633. this.Event.listeners[event].length = 0;
  14634. return;
  14635. }
  14636. remove(this.Event.listeners[event], func);
  14637. };
  14638. this.$emit = (event, context, inCache) => {
  14639. if (!this.Event.listeners[event])
  14640. return;
  14641. this.Event.listeners[event].forEach((func) => func(context, inCache));
  14642. };
  14643. }
  14644. lazyLoadHandler() {
  14645. const freeList = [];
  14646. this.listeners.forEach((listener) => {
  14647. if (!listener.el || !listener.el.parentNode) {
  14648. freeList.push(listener);
  14649. }
  14650. const catIn = listener.checkInView();
  14651. if (!catIn)
  14652. return;
  14653. listener.load();
  14654. });
  14655. freeList.forEach((item) => {
  14656. remove(this.listeners, item);
  14657. item.$destroy();
  14658. });
  14659. }
  14660. initIntersectionObserver() {
  14661. if (!hasIntersectionObserver) {
  14662. return;
  14663. }
  14664. this.observer = new IntersectionObserver(
  14665. this.observerHandler.bind(this),
  14666. this.options.observerOptions
  14667. );
  14668. if (this.listeners.length) {
  14669. this.listeners.forEach((listener) => {
  14670. this.observer.observe(listener.el);
  14671. });
  14672. }
  14673. }
  14674. observerHandler(entries) {
  14675. entries.forEach((entry) => {
  14676. if (entry.isIntersecting) {
  14677. this.listeners.forEach((listener) => {
  14678. if (listener.el === entry.target) {
  14679. if (listener.state.loaded)
  14680. return this.observer.unobserve(listener.el);
  14681. listener.load();
  14682. }
  14683. });
  14684. }
  14685. });
  14686. }
  14687. elRenderer(listener, state, cache) {
  14688. if (!listener.el)
  14689. return;
  14690. const { el, bindType } = listener;
  14691. let src;
  14692. switch (state) {
  14693. case "loading":
  14694. src = listener.loading;
  14695. break;
  14696. case "error":
  14697. src = listener.error;
  14698. break;
  14699. default:
  14700. ({ src } = listener);
  14701. break;
  14702. }
  14703. if (bindType) {
  14704. el.style[bindType] = 'url("' + src + '")';
  14705. } else if (el.getAttribute("src") !== src) {
  14706. el.setAttribute("src", src);
  14707. }
  14708. el.setAttribute("lazy", state);
  14709. this.$emit(state, listener, cache);
  14710. this.options.adapter[state] && this.options.adapter[state](listener, this.options);
  14711. if (this.options.dispatchEvent) {
  14712. const event = new CustomEvent(state, {
  14713. detail: listener
  14714. });
  14715. el.dispatchEvent(event);
  14716. }
  14717. }
  14718. valueFormatter(value) {
  14719. let src = value;
  14720. let { loading, error } = this.options;
  14721. if (isObject(value)) {
  14722. if (process.env.NODE_ENV !== "production" && !value.src && !this.options.silent) {
  14723. console.error("[@vant/lazyload] miss src with " + value);
  14724. }
  14725. ({ src } = value);
  14726. loading = value.loading || this.options.loading;
  14727. error = value.error || this.options.error;
  14728. }
  14729. return {
  14730. src,
  14731. loading,
  14732. error
  14733. };
  14734. }
  14735. };
  14736. }
  14737. var stdin_default$2 = (lazy) => ({
  14738. props: {
  14739. tag: {
  14740. type: String,
  14741. default: "div"
  14742. }
  14743. },
  14744. emits: ["show"],
  14745. render() {
  14746. return vue.h(
  14747. this.tag,
  14748. this.show && this.$slots.default ? this.$slots.default() : null
  14749. );
  14750. },
  14751. data() {
  14752. return {
  14753. el: null,
  14754. state: {
  14755. loaded: false
  14756. },
  14757. show: false
  14758. };
  14759. },
  14760. mounted() {
  14761. this.el = this.$el;
  14762. lazy.addLazyBox(this);
  14763. lazy.lazyLoadHandler();
  14764. },
  14765. beforeUnmount() {
  14766. lazy.removeComponent(this);
  14767. },
  14768. methods: {
  14769. checkInView() {
  14770. const rect = use.useRect(this.$el);
  14771. return use.inBrowser && rect.top < window.innerHeight * lazy.options.preLoad && rect.bottom > 0 && rect.left < window.innerWidth * lazy.options.preLoad && rect.right > 0;
  14772. },
  14773. load() {
  14774. this.show = true;
  14775. this.state.loaded = true;
  14776. this.$emit("show", this);
  14777. },
  14778. destroy() {
  14779. return this.$destroy;
  14780. }
  14781. }
  14782. });
  14783. const defaultOptions = {
  14784. selector: "img"
  14785. };
  14786. class LazyContainer {
  14787. constructor({ el, binding, vnode, lazy }) {
  14788. this.el = null;
  14789. this.vnode = vnode;
  14790. this.binding = binding;
  14791. this.options = {};
  14792. this.lazy = lazy;
  14793. this.queue = [];
  14794. this.update({ el, binding });
  14795. }
  14796. update({ el, binding }) {
  14797. this.el = el;
  14798. this.options = Object.assign({}, defaultOptions, binding.value);
  14799. const imgs = this.getImgs();
  14800. imgs.forEach((el2) => {
  14801. this.lazy.add(
  14802. el2,
  14803. Object.assign({}, this.binding, {
  14804. value: {
  14805. src: "dataset" in el2 ? el2.dataset.src : el2.getAttribute("data-src"),
  14806. error: ("dataset" in el2 ? el2.dataset.error : el2.getAttribute("data-error")) || this.options.error,
  14807. loading: ("dataset" in el2 ? el2.dataset.loading : el2.getAttribute("data-loading")) || this.options.loading
  14808. }
  14809. }),
  14810. this.vnode
  14811. );
  14812. });
  14813. }
  14814. getImgs() {
  14815. return Array.from(this.el.querySelectorAll(this.options.selector));
  14816. }
  14817. clear() {
  14818. const imgs = this.getImgs();
  14819. imgs.forEach((el) => this.lazy.remove(el));
  14820. this.vnode = null;
  14821. this.binding = null;
  14822. this.lazy = null;
  14823. }
  14824. }
  14825. class LazyContainerManager {
  14826. constructor({ lazy }) {
  14827. this.lazy = lazy;
  14828. this.queue = [];
  14829. }
  14830. bind(el, binding, vnode) {
  14831. const container = new LazyContainer({
  14832. el,
  14833. binding,
  14834. vnode,
  14835. lazy: this.lazy
  14836. });
  14837. this.queue.push(container);
  14838. }
  14839. update(el, binding, vnode) {
  14840. const container = this.queue.find((item) => item.el === el);
  14841. if (!container)
  14842. return;
  14843. container.update({ el, binding, vnode });
  14844. }
  14845. unbind(el) {
  14846. const container = this.queue.find((item) => item.el === el);
  14847. if (!container)
  14848. return;
  14849. container.clear();
  14850. remove(this.queue, container);
  14851. }
  14852. }
  14853. var stdin_default$1 = (lazyManager) => ({
  14854. props: {
  14855. src: [String, Object],
  14856. tag: {
  14857. type: String,
  14858. default: "img"
  14859. }
  14860. },
  14861. render() {
  14862. var _a, _b;
  14863. return vue.h(
  14864. this.tag,
  14865. {
  14866. src: this.renderSrc
  14867. },
  14868. (_b = (_a = this.$slots).default) == null ? void 0 : _b.call(_a)
  14869. );
  14870. },
  14871. data() {
  14872. return {
  14873. el: null,
  14874. options: {
  14875. src: "",
  14876. error: "",
  14877. loading: "",
  14878. attempt: lazyManager.options.attempt
  14879. },
  14880. state: {
  14881. loaded: false,
  14882. error: false,
  14883. attempt: 0
  14884. },
  14885. renderSrc: ""
  14886. };
  14887. },
  14888. watch: {
  14889. src() {
  14890. this.init();
  14891. lazyManager.addLazyBox(this);
  14892. lazyManager.lazyLoadHandler();
  14893. }
  14894. },
  14895. created() {
  14896. this.init();
  14897. this.renderSrc = this.options.loading;
  14898. },
  14899. mounted() {
  14900. this.el = this.$el;
  14901. lazyManager.addLazyBox(this);
  14902. lazyManager.lazyLoadHandler();
  14903. },
  14904. beforeUnmount() {
  14905. lazyManager.removeComponent(this);
  14906. },
  14907. methods: {
  14908. init() {
  14909. const { src, loading, error } = lazyManager.valueFormatter(this.src);
  14910. this.state.loaded = false;
  14911. this.options.src = src;
  14912. this.options.error = error;
  14913. this.options.loading = loading;
  14914. this.renderSrc = this.options.loading;
  14915. },
  14916. checkInView() {
  14917. const rect = use.useRect(this.$el);
  14918. return rect.top < window.innerHeight * lazyManager.options.preLoad && rect.bottom > 0 && rect.left < window.innerWidth * lazyManager.options.preLoad && rect.right > 0;
  14919. },
  14920. load(onFinish = noop) {
  14921. if (this.state.attempt > this.options.attempt - 1 && this.state.error) {
  14922. if (process.env.NODE_ENV !== "production" && !lazyManager.options.silent) {
  14923. console.log(
  14924. `[@vant/lazyload] ${this.options.src} tried too more than ${this.options.attempt} times`
  14925. );
  14926. }
  14927. onFinish();
  14928. return;
  14929. }
  14930. const { src } = this.options;
  14931. loadImageAsync(
  14932. { src },
  14933. ({ src: src2 }) => {
  14934. this.renderSrc = src2;
  14935. this.state.loaded = true;
  14936. },
  14937. () => {
  14938. this.state.attempt++;
  14939. this.renderSrc = this.options.error;
  14940. this.state.error = true;
  14941. }
  14942. );
  14943. }
  14944. }
  14945. });
  14946. const Lazyload = {
  14947. install(app, options = {}) {
  14948. const LazyClass = stdin_default$3();
  14949. const lazy = new LazyClass(options);
  14950. const lazyContainer = new LazyContainerManager({ lazy });
  14951. app.config.globalProperties.$Lazyload = lazy;
  14952. if (options.lazyComponent) {
  14953. app.component("LazyComponent", stdin_default$2(lazy));
  14954. }
  14955. if (options.lazyImage) {
  14956. app.component("LazyImage", stdin_default$1(lazy));
  14957. }
  14958. app.directive("lazy", {
  14959. beforeMount: lazy.add.bind(lazy),
  14960. updated: lazy.update.bind(lazy),
  14961. unmounted: lazy.remove.bind(lazy)
  14962. });
  14963. app.directive("lazy-container", {
  14964. beforeMount: lazyContainer.bind.bind(lazyContainer),
  14965. updated: lazyContainer.update.bind(lazyContainer),
  14966. unmounted: lazyContainer.unbind.bind(lazyContainer)
  14967. });
  14968. }
  14969. };
  14970. const version = "3.6.10";
  14971. function install(app) {
  14972. const components = [
  14973. ActionBar,
  14974. ActionBarButton,
  14975. ActionBarIcon,
  14976. ActionSheet,
  14977. AddressEdit,
  14978. AddressList,
  14979. Area,
  14980. Badge,
  14981. Button,
  14982. Calendar,
  14983. Card,
  14984. Cascader,
  14985. Cell,
  14986. CellGroup,
  14987. Checkbox,
  14988. CheckboxGroup,
  14989. Circle,
  14990. Col,
  14991. Collapse,
  14992. CollapseItem,
  14993. ConfigProvider,
  14994. ContactCard,
  14995. ContactEdit,
  14996. ContactList,
  14997. CountDown,
  14998. Coupon,
  14999. CouponCell,
  15000. CouponList,
  15001. DatetimePicker,
  15002. Dialog,
  15003. Divider,
  15004. DropdownItem,
  15005. DropdownMenu,
  15006. Empty,
  15007. Field,
  15008. Form,
  15009. Grid,
  15010. GridItem,
  15011. Icon,
  15012. Image$1,
  15013. ImagePreview,
  15014. IndexAnchor,
  15015. IndexBar,
  15016. List,
  15017. Loading,
  15018. Locale,
  15019. NavBar,
  15020. NoticeBar,
  15021. Notify,
  15022. NumberKeyboard,
  15023. Overlay,
  15024. Pagination,
  15025. PasswordInput,
  15026. Picker,
  15027. Popover,
  15028. Popup,
  15029. Progress,
  15030. PullRefresh,
  15031. Radio,
  15032. RadioGroup,
  15033. Rate,
  15034. Row,
  15035. Search,
  15036. ShareSheet,
  15037. Sidebar,
  15038. SidebarItem,
  15039. Skeleton,
  15040. Slider,
  15041. Space,
  15042. Step,
  15043. Stepper,
  15044. Steps,
  15045. Sticky,
  15046. SubmitBar,
  15047. Swipe,
  15048. SwipeCell,
  15049. SwipeItem,
  15050. Switch,
  15051. Tab,
  15052. Tabbar,
  15053. TabbarItem,
  15054. Tabs,
  15055. Tag,
  15056. Toast,
  15057. TreeSelect,
  15058. Uploader
  15059. ];
  15060. components.forEach((item) => {
  15061. if (item.install) {
  15062. app.use(item);
  15063. } else if (item.name) {
  15064. app.component(item.name, item);
  15065. }
  15066. });
  15067. }
  15068. var stdin_default = {
  15069. install,
  15070. version
  15071. };
  15072. exports.ActionBar = ActionBar;
  15073. exports.ActionBarButton = ActionBarButton;
  15074. exports.ActionBarIcon = ActionBarIcon;
  15075. exports.ActionSheet = ActionSheet;
  15076. exports.AddressEdit = AddressEdit;
  15077. exports.AddressList = AddressList;
  15078. exports.Area = Area;
  15079. exports.Badge = Badge;
  15080. exports.Button = Button;
  15081. exports.Calendar = Calendar;
  15082. exports.Card = Card;
  15083. exports.Cascader = Cascader;
  15084. exports.Cell = Cell;
  15085. exports.CellGroup = CellGroup;
  15086. exports.Checkbox = Checkbox;
  15087. exports.CheckboxGroup = CheckboxGroup;
  15088. exports.Circle = Circle;
  15089. exports.Col = Col;
  15090. exports.Collapse = Collapse;
  15091. exports.CollapseItem = CollapseItem;
  15092. exports.ConfigProvider = ConfigProvider;
  15093. exports.ContactCard = ContactCard;
  15094. exports.ContactEdit = ContactEdit;
  15095. exports.ContactList = ContactList;
  15096. exports.CountDown = CountDown;
  15097. exports.Coupon = Coupon;
  15098. exports.CouponCell = CouponCell;
  15099. exports.CouponList = CouponList;
  15100. exports.DatetimePicker = DatetimePicker;
  15101. exports.Dialog = Dialog;
  15102. exports.Divider = Divider;
  15103. exports.DropdownItem = DropdownItem;
  15104. exports.DropdownMenu = DropdownMenu;
  15105. exports.Empty = Empty;
  15106. exports.Field = Field;
  15107. exports.Form = Form;
  15108. exports.Grid = Grid;
  15109. exports.GridItem = GridItem;
  15110. exports.Icon = Icon;
  15111. exports.Image = Image$1;
  15112. exports.ImagePreview = ImagePreview;
  15113. exports.IndexAnchor = IndexAnchor;
  15114. exports.IndexBar = IndexBar;
  15115. exports.Lazyload = Lazyload;
  15116. exports.List = List;
  15117. exports.Loading = Loading;
  15118. exports.Locale = Locale;
  15119. exports.NavBar = NavBar;
  15120. exports.NoticeBar = NoticeBar;
  15121. exports.Notify = Notify;
  15122. exports.NumberKeyboard = NumberKeyboard;
  15123. exports.Overlay = Overlay;
  15124. exports.Pagination = Pagination;
  15125. exports.PasswordInput = PasswordInput;
  15126. exports.Picker = Picker;
  15127. exports.Popover = Popover;
  15128. exports.Popup = Popup;
  15129. exports.Progress = Progress;
  15130. exports.PullRefresh = PullRefresh;
  15131. exports.Radio = Radio;
  15132. exports.RadioGroup = RadioGroup;
  15133. exports.Rate = Rate;
  15134. exports.Row = Row;
  15135. exports.Search = Search;
  15136. exports.ShareSheet = ShareSheet;
  15137. exports.Sidebar = Sidebar;
  15138. exports.SidebarItem = SidebarItem;
  15139. exports.Skeleton = Skeleton;
  15140. exports.Slider = Slider;
  15141. exports.Space = Space;
  15142. exports.Step = Step;
  15143. exports.Stepper = Stepper;
  15144. exports.Steps = Steps;
  15145. exports.Sticky = Sticky;
  15146. exports.SubmitBar = SubmitBar;
  15147. exports.Swipe = Swipe;
  15148. exports.SwipeCell = SwipeCell;
  15149. exports.SwipeItem = SwipeItem;
  15150. exports.Switch = Switch;
  15151. exports.Tab = Tab;
  15152. exports.Tabbar = Tabbar;
  15153. exports.TabbarItem = TabbarItem;
  15154. exports.Tabs = Tabs;
  15155. exports.Tag = Tag;
  15156. exports.Toast = Toast;
  15157. exports.TreeSelect = TreeSelect;
  15158. exports.Uploader = Uploader;
  15159. exports.default = stdin_default;
  15160. exports.install = install;
  15161. exports.version = version;