vant.es.js 419 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200
  1. import { useWindowSize, useRect, useChildren, useParent, onMountedOrActivated, getScrollParent, useEventListener, raf, useScrollParent, usePageVisibility, doubleRaf, CUSTOM_FIELD_INJECTION_KEY, useCustomFieldValue, inBrowser as inBrowser$1, useToggle, cancelRaf, useCountDown, useClickAway } from "@vant/use";
  2. import { unref, ref, reactive, inject, watch, onMounted, nextTick, createVNode, defineComponent, getCurrentInstance, computed, onActivated, onDeactivated, onBeforeUnmount, provide, watchEffect, mergeProps, Transition, withDirectives, vShow, Teleport, Fragment, onBeforeUpdate, createTextVNode, onUnmounted, createApp, resolveDirective, withKeys, onUpdated, h } from "vue";
  3. import { offsetModifier, createPopper } from "@vant/popperjs";
  4. const isDef = (val) => val !== void 0 && val !== null;
  5. const isFunction = (val) => typeof val === "function";
  6. const isObject = (val) => val !== null && typeof val === "object";
  7. const isPromise = (val) => isObject(val) && isFunction(val.then) && isFunction(val.catch);
  8. const isDate = (val) => Object.prototype.toString.call(val) === "[object Date]" && !Number.isNaN(val.getTime());
  9. function isMobile(value) {
  10. value = value.replace(/[^-|\d]/g, "");
  11. return /^((\+86)|(86))?(1)\d{10}$/.test(value) || /^0[0-9-]{10,13}$/.test(value);
  12. }
  13. const isNumeric = (val) => typeof val === "number" || /^\d+(\.\d+)?$/.test(val);
  14. const isIOS$1 = () => inBrowser ? /ios|iphone|ipad|ipod/.test(navigator.userAgent.toLowerCase()) : false;
  15. function noop() {
  16. }
  17. const extend = Object.assign;
  18. const inBrowser = typeof window !== "undefined";
  19. function get(object, path) {
  20. const keys = path.split(".");
  21. let result = object;
  22. keys.forEach((key) => {
  23. var _a;
  24. result = isObject(result) ? (_a = result[key]) != null ? _a : "" : "";
  25. });
  26. return result;
  27. }
  28. function pick(obj, keys, ignoreUndefined) {
  29. return keys.reduce((ret, key) => {
  30. if (!ignoreUndefined || obj[key] !== void 0) {
  31. ret[key] = obj[key];
  32. }
  33. return ret;
  34. }, {});
  35. }
  36. const isSameValue = (newValue, oldValue) => JSON.stringify(newValue) === JSON.stringify(oldValue);
  37. const toArray = (item) => Array.isArray(item) ? item : [item];
  38. const unknownProp = null;
  39. const numericProp = [Number, String];
  40. const truthProp = {
  41. type: Boolean,
  42. default: true
  43. };
  44. const makeRequiredProp = (type) => ({
  45. type,
  46. required: true
  47. });
  48. const makeArrayProp = () => ({
  49. type: Array,
  50. default: () => []
  51. });
  52. const makeNumberProp = (defaultVal) => ({
  53. type: Number,
  54. default: defaultVal
  55. });
  56. const makeNumericProp = (defaultVal) => ({
  57. type: numericProp,
  58. default: defaultVal
  59. });
  60. const makeStringProp = (defaultVal) => ({
  61. type: String,
  62. default: defaultVal
  63. });
  64. function getScrollTop(el) {
  65. const top = "scrollTop" in el ? el.scrollTop : el.pageYOffset;
  66. return Math.max(top, 0);
  67. }
  68. function setScrollTop(el, value) {
  69. if ("scrollTop" in el) {
  70. el.scrollTop = value;
  71. } else {
  72. el.scrollTo(el.scrollX, value);
  73. }
  74. }
  75. function getRootScrollTop() {
  76. return window.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop || 0;
  77. }
  78. function setRootScrollTop(value) {
  79. setScrollTop(window, value);
  80. setScrollTop(document.body, value);
  81. }
  82. function getElementTop(el, scroller) {
  83. if (el === window) {
  84. return 0;
  85. }
  86. const scrollTop = scroller ? getScrollTop(scroller) : getRootScrollTop();
  87. return useRect(el).top + scrollTop;
  88. }
  89. const isIOS = isIOS$1();
  90. function resetScroll() {
  91. if (isIOS) {
  92. setRootScrollTop(getRootScrollTop());
  93. }
  94. }
  95. const stopPropagation = (event) => event.stopPropagation();
  96. function preventDefault(event, isStopPropagation) {
  97. if (typeof event.cancelable !== "boolean" || event.cancelable) {
  98. event.preventDefault();
  99. }
  100. if (isStopPropagation) {
  101. stopPropagation(event);
  102. }
  103. }
  104. function isHidden(elementRef) {
  105. const el = unref(elementRef);
  106. if (!el) {
  107. return false;
  108. }
  109. const style = window.getComputedStyle(el);
  110. const hidden = style.display === "none";
  111. const parentHidden = el.offsetParent === null && style.position !== "fixed";
  112. return hidden || parentHidden;
  113. }
  114. const { width: windowWidth, height: windowHeight } = useWindowSize();
  115. function addUnit(value) {
  116. if (isDef(value)) {
  117. return isNumeric(value) ? `${value}px` : String(value);
  118. }
  119. return void 0;
  120. }
  121. function getSizeStyle(originSize) {
  122. if (isDef(originSize)) {
  123. if (Array.isArray(originSize)) {
  124. return {
  125. width: addUnit(originSize[0]),
  126. height: addUnit(originSize[1])
  127. };
  128. }
  129. const size = addUnit(originSize);
  130. return {
  131. width: size,
  132. height: size
  133. };
  134. }
  135. }
  136. function getZIndexStyle(zIndex) {
  137. const style = {};
  138. if (zIndex !== void 0) {
  139. style.zIndex = +zIndex;
  140. }
  141. return style;
  142. }
  143. let rootFontSize;
  144. function getRootFontSize() {
  145. if (!rootFontSize) {
  146. const doc = document.documentElement;
  147. const fontSize = doc.style.fontSize || window.getComputedStyle(doc).fontSize;
  148. rootFontSize = parseFloat(fontSize);
  149. }
  150. return rootFontSize;
  151. }
  152. function convertRem(value) {
  153. value = value.replace(/rem/g, "");
  154. return +value * getRootFontSize();
  155. }
  156. function convertVw(value) {
  157. value = value.replace(/vw/g, "");
  158. return +value * windowWidth.value / 100;
  159. }
  160. function convertVh(value) {
  161. value = value.replace(/vh/g, "");
  162. return +value * windowHeight.value / 100;
  163. }
  164. function unitToPx(value) {
  165. if (typeof value === "number") {
  166. return value;
  167. }
  168. if (inBrowser) {
  169. if (value.includes("rem")) {
  170. return convertRem(value);
  171. }
  172. if (value.includes("vw")) {
  173. return convertVw(value);
  174. }
  175. if (value.includes("vh")) {
  176. return convertVh(value);
  177. }
  178. }
  179. return parseFloat(value);
  180. }
  181. const camelizeRE = /-(\w)/g;
  182. const camelize = (str) => str.replace(camelizeRE, (_, c) => c.toUpperCase());
  183. const kebabCase = (str) => str.replace(/([A-Z])/g, "-$1").toLowerCase().replace(/^-/, "");
  184. function padZero(num, targetLength = 2) {
  185. let str = num + "";
  186. while (str.length < targetLength) {
  187. str = "0" + str;
  188. }
  189. return str;
  190. }
  191. const clamp = (num, min, max) => Math.min(Math.max(num, min), max);
  192. function trimExtraChar(value, char, regExp) {
  193. const index = value.indexOf(char);
  194. if (index === -1) {
  195. return value;
  196. }
  197. if (char === "-" && index !== 0) {
  198. return value.slice(0, index);
  199. }
  200. return value.slice(0, index + 1) + value.slice(index).replace(regExp, "");
  201. }
  202. function formatNumber(value, allowDot = true, allowMinus = true) {
  203. if (allowDot) {
  204. value = trimExtraChar(value, ".", /\./g);
  205. } else {
  206. value = value.split(".")[0];
  207. }
  208. if (allowMinus) {
  209. value = trimExtraChar(value, "-", /-/g);
  210. } else {
  211. value = value.replace(/-/, "");
  212. }
  213. const regExp = allowDot ? /[^-0-9.]/g : /[^-0-9]/g;
  214. return value.replace(regExp, "");
  215. }
  216. function addNumber(num1, num2) {
  217. const cardinal = 10 ** 10;
  218. return Math.round((num1 + num2) * cardinal) / cardinal;
  219. }
  220. const { hasOwnProperty } = Object.prototype;
  221. function assignKey(to, from, key) {
  222. const val = from[key];
  223. if (!isDef(val)) {
  224. return;
  225. }
  226. if (!hasOwnProperty.call(to, key) || !isObject(val)) {
  227. to[key] = val;
  228. } else {
  229. to[key] = deepAssign(Object(to[key]), val);
  230. }
  231. }
  232. function deepAssign(to, from) {
  233. Object.keys(from).forEach((key) => {
  234. assignKey(to, from, key);
  235. });
  236. return to;
  237. }
  238. var stdin_default$1K = {
  239. name: "\u59D3\u540D",
  240. tel: "\u7535\u8BDD",
  241. save: "\u4FDD\u5B58",
  242. confirm: "\u786E\u8BA4",
  243. cancel: "\u53D6\u6D88",
  244. delete: "\u5220\u9664",
  245. loading: "\u52A0\u8F7D\u4E2D...",
  246. noCoupon: "\u6682\u65E0\u4F18\u60E0\u5238",
  247. nameEmpty: "\u8BF7\u586B\u5199\u59D3\u540D",
  248. addContact: "\u6DFB\u52A0\u8054\u7CFB\u4EBA",
  249. telInvalid: "\u8BF7\u586B\u5199\u6B63\u786E\u7684\u7535\u8BDD",
  250. vanCalendar: {
  251. end: "\u7ED3\u675F",
  252. start: "\u5F00\u59CB",
  253. title: "\u65E5\u671F\u9009\u62E9",
  254. weekdays: ["\u65E5", "\u4E00", "\u4E8C", "\u4E09", "\u56DB", "\u4E94", "\u516D"],
  255. monthTitle: (year, month) => `${year}\u5E74${month}\u6708`,
  256. rangePrompt: (maxRange) => `\u6700\u591A\u9009\u62E9 ${maxRange} \u5929`
  257. },
  258. vanCascader: {
  259. select: "\u8BF7\u9009\u62E9"
  260. },
  261. vanPagination: {
  262. prev: "\u4E0A\u4E00\u9875",
  263. next: "\u4E0B\u4E00\u9875"
  264. },
  265. vanPullRefresh: {
  266. pulling: "\u4E0B\u62C9\u5373\u53EF\u5237\u65B0...",
  267. loosing: "\u91CA\u653E\u5373\u53EF\u5237\u65B0..."
  268. },
  269. vanSubmitBar: {
  270. label: "\u5408\u8BA1:"
  271. },
  272. vanCoupon: {
  273. unlimited: "\u65E0\u95E8\u69DB",
  274. discount: (discount) => `${discount}\u6298`,
  275. condition: (condition) => `\u6EE1${condition}\u5143\u53EF\u7528`
  276. },
  277. vanCouponCell: {
  278. title: "\u4F18\u60E0\u5238",
  279. count: (count) => `${count}\u5F20\u53EF\u7528`
  280. },
  281. vanCouponList: {
  282. exchange: "\u5151\u6362",
  283. close: "\u4E0D\u4F7F\u7528",
  284. enable: "\u53EF\u7528",
  285. disabled: "\u4E0D\u53EF\u7528",
  286. placeholder: "\u8F93\u5165\u4F18\u60E0\u7801"
  287. },
  288. vanAddressEdit: {
  289. area: "\u5730\u533A",
  290. areaEmpty: "\u8BF7\u9009\u62E9\u5730\u533A",
  291. addressEmpty: "\u8BF7\u586B\u5199\u8BE6\u7EC6\u5730\u5740",
  292. addressDetail: "\u8BE6\u7EC6\u5730\u5740",
  293. defaultAddress: "\u8BBE\u4E3A\u9ED8\u8BA4\u6536\u8D27\u5730\u5740"
  294. },
  295. vanAddressList: {
  296. add: "\u65B0\u589E\u5730\u5740"
  297. }
  298. };
  299. const lang = ref("zh-CN");
  300. const messages = reactive({
  301. "zh-CN": stdin_default$1K
  302. });
  303. const Locale = {
  304. messages() {
  305. return messages[lang.value];
  306. },
  307. use(newLang, newMessages) {
  308. lang.value = newLang;
  309. this.add({ [newLang]: newMessages });
  310. },
  311. add(newMessages = {}) {
  312. deepAssign(messages, newMessages);
  313. }
  314. };
  315. var stdin_default$1J = Locale;
  316. function createTranslate(name2) {
  317. const prefix = camelize(name2) + ".";
  318. return (path, ...args) => {
  319. const messages2 = stdin_default$1J.messages();
  320. const message = get(messages2, prefix + path) || get(messages2, path);
  321. return isFunction(message) ? message(...args) : message;
  322. };
  323. }
  324. function genBem(name2, mods) {
  325. if (!mods) {
  326. return "";
  327. }
  328. if (typeof mods === "string") {
  329. return ` ${name2}--${mods}`;
  330. }
  331. if (Array.isArray(mods)) {
  332. return mods.reduce(
  333. (ret, item) => ret + genBem(name2, item),
  334. ""
  335. );
  336. }
  337. return Object.keys(mods).reduce(
  338. (ret, key) => ret + (mods[key] ? genBem(name2, key) : ""),
  339. ""
  340. );
  341. }
  342. function createBEM(name2) {
  343. return (el, mods) => {
  344. if (el && typeof el !== "string") {
  345. mods = el;
  346. el = "";
  347. }
  348. el = el ? `${name2}__${el}` : name2;
  349. return `${el}${genBem(el, mods)}`;
  350. };
  351. }
  352. function createNamespace(name2) {
  353. const prefixedName = `van-${name2}`;
  354. return [
  355. prefixedName,
  356. createBEM(prefixedName),
  357. createTranslate(prefixedName)
  358. ];
  359. }
  360. const BORDER = "van-hairline";
  361. const BORDER_TOP = `${BORDER}--top`;
  362. const BORDER_LEFT = `${BORDER}--left`;
  363. const BORDER_BOTTOM = `${BORDER}--bottom`;
  364. const BORDER_SURROUND = `${BORDER}--surround`;
  365. const BORDER_TOP_BOTTOM = `${BORDER}--top-bottom`;
  366. const BORDER_UNSET_TOP_BOTTOM = `${BORDER}-unset--top-bottom`;
  367. const HAPTICS_FEEDBACK = "van-haptics-feedback";
  368. const FORM_KEY = Symbol("van-form");
  369. const LONG_PRESS_START_TIME = 500;
  370. function callInterceptor(interceptor, {
  371. args = [],
  372. done,
  373. canceled
  374. }) {
  375. if (interceptor) {
  376. const returnVal = interceptor.apply(null, args);
  377. if (isPromise(returnVal)) {
  378. returnVal.then((value) => {
  379. if (value) {
  380. done();
  381. } else if (canceled) {
  382. canceled();
  383. }
  384. }).catch(noop);
  385. } else if (returnVal) {
  386. done();
  387. } else if (canceled) {
  388. canceled();
  389. }
  390. } else {
  391. done();
  392. }
  393. }
  394. function withInstall(options) {
  395. options.install = (app) => {
  396. const { name: name2 } = options;
  397. if (name2) {
  398. app.component(name2, options);
  399. app.component(camelize(`-${name2}`), options);
  400. }
  401. };
  402. return options;
  403. }
  404. const POPUP_TOGGLE_KEY = Symbol();
  405. function onPopupReopen(callback) {
  406. const popupToggleStatus = inject(POPUP_TOGGLE_KEY, null);
  407. if (popupToggleStatus) {
  408. watch(popupToggleStatus, (show) => {
  409. if (show) {
  410. callback();
  411. }
  412. });
  413. }
  414. }
  415. const useHeight = (element, withSafeArea) => {
  416. const height = ref();
  417. const setHeight = () => {
  418. height.value = useRect(element).height;
  419. };
  420. onMounted(() => {
  421. nextTick(setHeight);
  422. if (withSafeArea) {
  423. for (let i = 1; i <= 3; i++) {
  424. setTimeout(setHeight, 100 * i);
  425. }
  426. }
  427. });
  428. onPopupReopen(() => nextTick(setHeight));
  429. watch([windowWidth, windowHeight], setHeight);
  430. return height;
  431. };
  432. function usePlaceholder(contentRef, bem2) {
  433. const height = useHeight(contentRef, true);
  434. return (renderContent) => createVNode("div", {
  435. "class": bem2("placeholder"),
  436. "style": {
  437. height: height.value ? `${height.value}px` : void 0
  438. }
  439. }, [renderContent()]);
  440. }
  441. const [name$1B, bem$1w] = createNamespace("action-bar");
  442. const ACTION_BAR_KEY = Symbol(name$1B);
  443. const actionBarProps = {
  444. placeholder: Boolean,
  445. safeAreaInsetBottom: truthProp
  446. };
  447. var stdin_default$1I = defineComponent({
  448. name: name$1B,
  449. props: actionBarProps,
  450. setup(props, {
  451. slots
  452. }) {
  453. const root = ref();
  454. const renderPlaceholder = usePlaceholder(root, bem$1w);
  455. const {
  456. linkChildren
  457. } = useChildren(ACTION_BAR_KEY);
  458. linkChildren();
  459. const renderActionBar = () => {
  460. var _a;
  461. return createVNode("div", {
  462. "ref": root,
  463. "class": [bem$1w(), {
  464. "van-safe-area-bottom": props.safeAreaInsetBottom
  465. }]
  466. }, [(_a = slots.default) == null ? void 0 : _a.call(slots)]);
  467. };
  468. return () => {
  469. if (props.placeholder) {
  470. return renderPlaceholder(renderActionBar);
  471. }
  472. return renderActionBar();
  473. };
  474. }
  475. });
  476. const ActionBar = withInstall(stdin_default$1I);
  477. function useExpose(apis) {
  478. const instance2 = getCurrentInstance();
  479. if (instance2) {
  480. extend(instance2.proxy, apis);
  481. }
  482. }
  483. const routeProps = {
  484. to: [String, Object],
  485. url: String,
  486. replace: Boolean
  487. };
  488. function route({
  489. to,
  490. url,
  491. replace,
  492. $router: router
  493. }) {
  494. if (to && router) {
  495. router[replace ? "replace" : "push"](to);
  496. } else if (url) {
  497. replace ? location.replace(url) : location.href = url;
  498. }
  499. }
  500. function useRoute() {
  501. const vm = getCurrentInstance().proxy;
  502. return () => route(vm);
  503. }
  504. const [name$1A, bem$1v] = createNamespace("badge");
  505. const badgeProps = {
  506. dot: Boolean,
  507. max: numericProp,
  508. tag: makeStringProp("div"),
  509. color: String,
  510. offset: Array,
  511. content: numericProp,
  512. showZero: truthProp,
  513. position: makeStringProp("top-right")
  514. };
  515. var stdin_default$1H = defineComponent({
  516. name: name$1A,
  517. props: badgeProps,
  518. setup(props, {
  519. slots
  520. }) {
  521. const hasContent = () => {
  522. if (slots.content) {
  523. return true;
  524. }
  525. const {
  526. content,
  527. showZero
  528. } = props;
  529. return isDef(content) && content !== "" && (showZero || content !== 0 && content !== "0");
  530. };
  531. const renderContent = () => {
  532. const {
  533. dot,
  534. max,
  535. content
  536. } = props;
  537. if (!dot && hasContent()) {
  538. if (slots.content) {
  539. return slots.content();
  540. }
  541. if (isDef(max) && isNumeric(content) && +content > max) {
  542. return `${max}+`;
  543. }
  544. return content;
  545. }
  546. };
  547. const style = computed(() => {
  548. const style2 = {
  549. background: props.color
  550. };
  551. if (props.offset) {
  552. const [x, y] = props.offset;
  553. if (slots.default) {
  554. style2.top = addUnit(y);
  555. if (typeof x === "number") {
  556. style2.right = addUnit(-x);
  557. } else {
  558. style2.right = x.startsWith("-") ? x.replace("-", "") : `-${x}`;
  559. }
  560. } else {
  561. style2.marginTop = addUnit(y);
  562. style2.marginLeft = addUnit(x);
  563. }
  564. }
  565. return style2;
  566. });
  567. const renderBadge = () => {
  568. if (hasContent() || props.dot) {
  569. return createVNode("div", {
  570. "class": bem$1v([props.position, {
  571. dot: props.dot,
  572. fixed: !!slots.default
  573. }]),
  574. "style": style.value
  575. }, [renderContent()]);
  576. }
  577. };
  578. return () => {
  579. if (slots.default) {
  580. const {
  581. tag
  582. } = props;
  583. return createVNode(tag, {
  584. "class": bem$1v("wrapper")
  585. }, {
  586. default: () => [slots.default(), renderBadge()]
  587. });
  588. }
  589. return renderBadge();
  590. };
  591. }
  592. });
  593. const Badge = withInstall(stdin_default$1H);
  594. let globalZIndex = 2e3;
  595. const useGlobalZIndex = () => ++globalZIndex;
  596. const setGlobalZIndex = (val) => {
  597. globalZIndex = val;
  598. };
  599. const [name$1z, bem$1u] = createNamespace("config-provider");
  600. const CONFIG_PROVIDER_KEY = Symbol(name$1z);
  601. const configProviderProps = {
  602. tag: makeStringProp("div"),
  603. theme: makeStringProp("light"),
  604. zIndex: Number,
  605. themeVars: Object,
  606. themeVarsDark: Object,
  607. themeVarsLight: Object,
  608. iconPrefix: String
  609. };
  610. function mapThemeVarsToCSSVars(themeVars) {
  611. const cssVars = {};
  612. Object.keys(themeVars).forEach((key) => {
  613. cssVars[`--van-${kebabCase(key)}`] = themeVars[key];
  614. });
  615. return cssVars;
  616. }
  617. var stdin_default$1G = defineComponent({
  618. name: name$1z,
  619. props: configProviderProps,
  620. setup(props, {
  621. slots
  622. }) {
  623. const style = computed(() => mapThemeVarsToCSSVars(extend({}, props.themeVars, props.theme === "dark" ? props.themeVarsDark : props.themeVarsLight)));
  624. if (inBrowser) {
  625. const addTheme = () => {
  626. document.documentElement.classList.add(`van-theme-${props.theme}`);
  627. };
  628. const removeTheme = (theme = props.theme) => {
  629. document.documentElement.classList.remove(`van-theme-${theme}`);
  630. };
  631. watch(() => props.theme, (newVal, oldVal) => {
  632. if (oldVal) {
  633. removeTheme(oldVal);
  634. }
  635. addTheme();
  636. }, {
  637. immediate: true
  638. });
  639. onActivated(addTheme);
  640. onDeactivated(removeTheme);
  641. onBeforeUnmount(removeTheme);
  642. }
  643. provide(CONFIG_PROVIDER_KEY, props);
  644. watchEffect(() => {
  645. if (props.zIndex !== void 0) {
  646. setGlobalZIndex(props.zIndex);
  647. }
  648. });
  649. return () => createVNode(props.tag, {
  650. "class": bem$1u(),
  651. "style": style.value
  652. }, {
  653. default: () => {
  654. var _a;
  655. return [(_a = slots.default) == null ? void 0 : _a.call(slots)];
  656. }
  657. });
  658. }
  659. });
  660. const [name$1y, bem$1t] = createNamespace("icon");
  661. const isImage = (name2) => name2 == null ? void 0 : name2.includes("/");
  662. const iconProps = {
  663. dot: Boolean,
  664. tag: makeStringProp("i"),
  665. name: String,
  666. size: numericProp,
  667. badge: numericProp,
  668. color: String,
  669. badgeProps: Object,
  670. classPrefix: String
  671. };
  672. var stdin_default$1F = defineComponent({
  673. name: name$1y,
  674. props: iconProps,
  675. setup(props, {
  676. slots
  677. }) {
  678. const config = inject(CONFIG_PROVIDER_KEY, null);
  679. const classPrefix = computed(() => props.classPrefix || (config == null ? void 0 : config.iconPrefix) || bem$1t());
  680. return () => {
  681. const {
  682. tag,
  683. dot,
  684. name: name2,
  685. size,
  686. badge,
  687. color
  688. } = props;
  689. const isImageIcon = isImage(name2);
  690. return createVNode(Badge, mergeProps({
  691. "dot": dot,
  692. "tag": tag,
  693. "class": [classPrefix.value, isImageIcon ? "" : `${classPrefix.value}-${name2}`],
  694. "style": {
  695. color,
  696. fontSize: addUnit(size)
  697. },
  698. "content": badge
  699. }, props.badgeProps), {
  700. default: () => {
  701. var _a;
  702. return [(_a = slots.default) == null ? void 0 : _a.call(slots), isImageIcon && createVNode("img", {
  703. "class": bem$1t("image"),
  704. "src": name2
  705. }, null)];
  706. }
  707. });
  708. };
  709. }
  710. });
  711. const Icon = withInstall(stdin_default$1F);
  712. const [name$1x, bem$1s] = createNamespace("loading");
  713. const SpinIcon = Array(12).fill(null).map((_, index) => createVNode("i", {
  714. "class": bem$1s("line", String(index + 1))
  715. }, null));
  716. const CircularIcon = createVNode("svg", {
  717. "class": bem$1s("circular"),
  718. "viewBox": "25 25 50 50"
  719. }, [createVNode("circle", {
  720. "cx": "50",
  721. "cy": "50",
  722. "r": "20",
  723. "fill": "none"
  724. }, null)]);
  725. const loadingProps = {
  726. size: numericProp,
  727. type: makeStringProp("circular"),
  728. color: String,
  729. vertical: Boolean,
  730. textSize: numericProp,
  731. textColor: String
  732. };
  733. var stdin_default$1E = defineComponent({
  734. name: name$1x,
  735. props: loadingProps,
  736. setup(props, {
  737. slots
  738. }) {
  739. const spinnerStyle = computed(() => extend({
  740. color: props.color
  741. }, getSizeStyle(props.size)));
  742. const renderIcon = () => {
  743. const DefaultIcon = props.type === "spinner" ? SpinIcon : CircularIcon;
  744. return createVNode("span", {
  745. "class": bem$1s("spinner", props.type),
  746. "style": spinnerStyle.value
  747. }, [slots.icon ? slots.icon() : DefaultIcon]);
  748. };
  749. const renderText = () => {
  750. var _a;
  751. if (slots.default) {
  752. return createVNode("span", {
  753. "class": bem$1s("text"),
  754. "style": {
  755. fontSize: addUnit(props.textSize),
  756. color: (_a = props.textColor) != null ? _a : props.color
  757. }
  758. }, [slots.default()]);
  759. }
  760. };
  761. return () => {
  762. const {
  763. type,
  764. vertical
  765. } = props;
  766. return createVNode("div", {
  767. "class": bem$1s([type, {
  768. vertical
  769. }]),
  770. "aria-live": "polite",
  771. "aria-busy": true
  772. }, [renderIcon(), renderText()]);
  773. };
  774. }
  775. });
  776. const Loading = withInstall(stdin_default$1E);
  777. const [name$1w, bem$1r] = createNamespace("button");
  778. const buttonProps = extend({}, routeProps, {
  779. tag: makeStringProp("button"),
  780. text: String,
  781. icon: String,
  782. type: makeStringProp("default"),
  783. size: makeStringProp("normal"),
  784. color: String,
  785. block: Boolean,
  786. plain: Boolean,
  787. round: Boolean,
  788. square: Boolean,
  789. loading: Boolean,
  790. hairline: Boolean,
  791. disabled: Boolean,
  792. iconPrefix: String,
  793. nativeType: makeStringProp("button"),
  794. loadingSize: numericProp,
  795. loadingText: String,
  796. loadingType: String,
  797. iconPosition: makeStringProp("left")
  798. });
  799. var stdin_default$1D = defineComponent({
  800. name: name$1w,
  801. props: buttonProps,
  802. emits: ["click"],
  803. setup(props, {
  804. emit,
  805. slots
  806. }) {
  807. const route2 = useRoute();
  808. const renderLoadingIcon = () => {
  809. if (slots.loading) {
  810. return slots.loading();
  811. }
  812. return createVNode(Loading, {
  813. "size": props.loadingSize,
  814. "type": props.loadingType,
  815. "class": bem$1r("loading")
  816. }, null);
  817. };
  818. const renderIcon = () => {
  819. if (props.loading) {
  820. return renderLoadingIcon();
  821. }
  822. if (slots.icon) {
  823. return createVNode("div", {
  824. "class": bem$1r("icon")
  825. }, [slots.icon()]);
  826. }
  827. if (props.icon) {
  828. return createVNode(Icon, {
  829. "name": props.icon,
  830. "class": bem$1r("icon"),
  831. "classPrefix": props.iconPrefix
  832. }, null);
  833. }
  834. };
  835. const renderText = () => {
  836. let text;
  837. if (props.loading) {
  838. text = props.loadingText;
  839. } else {
  840. text = slots.default ? slots.default() : props.text;
  841. }
  842. if (text) {
  843. return createVNode("span", {
  844. "class": bem$1r("text")
  845. }, [text]);
  846. }
  847. };
  848. const getStyle = () => {
  849. const {
  850. color,
  851. plain
  852. } = props;
  853. if (color) {
  854. const style = {
  855. color: plain ? color : "white"
  856. };
  857. if (!plain) {
  858. style.background = color;
  859. }
  860. if (color.includes("gradient")) {
  861. style.border = 0;
  862. } else {
  863. style.borderColor = color;
  864. }
  865. return style;
  866. }
  867. };
  868. const onClick = (event) => {
  869. if (props.loading) {
  870. preventDefault(event);
  871. } else if (!props.disabled) {
  872. emit("click", event);
  873. route2();
  874. }
  875. };
  876. return () => {
  877. const {
  878. tag,
  879. type,
  880. size,
  881. block,
  882. round,
  883. plain,
  884. square,
  885. loading,
  886. disabled,
  887. hairline,
  888. nativeType,
  889. iconPosition
  890. } = props;
  891. const classes = [bem$1r([type, size, {
  892. plain,
  893. block,
  894. round,
  895. square,
  896. loading,
  897. disabled,
  898. hairline
  899. }]), {
  900. [BORDER_SURROUND]: hairline
  901. }];
  902. return createVNode(tag, {
  903. "type": nativeType,
  904. "class": classes,
  905. "style": getStyle(),
  906. "disabled": disabled,
  907. "onClick": onClick
  908. }, {
  909. default: () => [createVNode("div", {
  910. "class": bem$1r("content")
  911. }, [iconPosition === "left" && renderIcon(), renderText(), iconPosition === "right" && renderIcon()])]
  912. });
  913. };
  914. }
  915. });
  916. const Button = withInstall(stdin_default$1D);
  917. const [name$1v, bem$1q] = createNamespace("action-bar-button");
  918. const actionBarButtonProps = extend({}, routeProps, {
  919. type: String,
  920. text: String,
  921. icon: String,
  922. color: String,
  923. loading: Boolean,
  924. disabled: Boolean
  925. });
  926. var stdin_default$1C = defineComponent({
  927. name: name$1v,
  928. props: actionBarButtonProps,
  929. setup(props, {
  930. slots
  931. }) {
  932. const route2 = useRoute();
  933. const {
  934. parent,
  935. index
  936. } = useParent(ACTION_BAR_KEY);
  937. const isFirst = computed(() => {
  938. if (parent) {
  939. const prev = parent.children[index.value - 1];
  940. return !(prev && "isButton" in prev);
  941. }
  942. });
  943. const isLast = computed(() => {
  944. if (parent) {
  945. const next = parent.children[index.value + 1];
  946. return !(next && "isButton" in next);
  947. }
  948. });
  949. useExpose({
  950. isButton: true
  951. });
  952. return () => {
  953. const {
  954. type,
  955. icon,
  956. text,
  957. color,
  958. loading,
  959. disabled
  960. } = props;
  961. return createVNode(Button, {
  962. "class": bem$1q([type, {
  963. last: isLast.value,
  964. first: isFirst.value
  965. }]),
  966. "size": "large",
  967. "type": type,
  968. "icon": icon,
  969. "color": color,
  970. "loading": loading,
  971. "disabled": disabled,
  972. "onClick": route2
  973. }, {
  974. default: () => [slots.default ? slots.default() : text]
  975. });
  976. };
  977. }
  978. });
  979. const ActionBarButton = withInstall(stdin_default$1C);
  980. const [name$1u, bem$1p] = createNamespace("action-bar-icon");
  981. const actionBarIconProps = extend({}, routeProps, {
  982. dot: Boolean,
  983. text: String,
  984. icon: String,
  985. color: String,
  986. badge: numericProp,
  987. iconClass: unknownProp,
  988. badgeProps: Object,
  989. iconPrefix: String
  990. });
  991. var stdin_default$1B = defineComponent({
  992. name: name$1u,
  993. props: actionBarIconProps,
  994. setup(props, {
  995. slots
  996. }) {
  997. const route2 = useRoute();
  998. useParent(ACTION_BAR_KEY);
  999. const renderIcon = () => {
  1000. const {
  1001. dot,
  1002. badge,
  1003. icon,
  1004. color,
  1005. iconClass,
  1006. badgeProps: badgeProps2,
  1007. iconPrefix
  1008. } = props;
  1009. if (slots.icon) {
  1010. return createVNode(Badge, mergeProps({
  1011. "dot": dot,
  1012. "class": bem$1p("icon"),
  1013. "content": badge
  1014. }, badgeProps2), {
  1015. default: slots.icon
  1016. });
  1017. }
  1018. return createVNode(Icon, {
  1019. "tag": "div",
  1020. "dot": dot,
  1021. "name": icon,
  1022. "badge": badge,
  1023. "color": color,
  1024. "class": [bem$1p("icon"), iconClass],
  1025. "badgeProps": badgeProps2,
  1026. "classPrefix": iconPrefix
  1027. }, null);
  1028. };
  1029. return () => createVNode("div", {
  1030. "role": "button",
  1031. "class": bem$1p(),
  1032. "tabindex": 0,
  1033. "onClick": route2
  1034. }, [renderIcon(), slots.default ? slots.default() : props.text]);
  1035. }
  1036. });
  1037. const ActionBarIcon = withInstall(stdin_default$1B);
  1038. const popupSharedProps = {
  1039. show: Boolean,
  1040. zIndex: numericProp,
  1041. overlay: truthProp,
  1042. duration: numericProp,
  1043. teleport: [String, Object],
  1044. lockScroll: truthProp,
  1045. lazyRender: truthProp,
  1046. beforeClose: Function,
  1047. overlayStyle: Object,
  1048. overlayClass: unknownProp,
  1049. transitionAppear: Boolean,
  1050. closeOnClickOverlay: truthProp
  1051. };
  1052. const popupSharedPropKeys = Object.keys(
  1053. popupSharedProps
  1054. );
  1055. function getDirection(x, y) {
  1056. if (x > y) {
  1057. return "horizontal";
  1058. }
  1059. if (y > x) {
  1060. return "vertical";
  1061. }
  1062. return "";
  1063. }
  1064. function useTouch() {
  1065. const startX = ref(0);
  1066. const startY = ref(0);
  1067. const deltaX = ref(0);
  1068. const deltaY = ref(0);
  1069. const offsetX = ref(0);
  1070. const offsetY = ref(0);
  1071. const direction = ref("");
  1072. const isVertical = () => direction.value === "vertical";
  1073. const isHorizontal = () => direction.value === "horizontal";
  1074. const reset = () => {
  1075. deltaX.value = 0;
  1076. deltaY.value = 0;
  1077. offsetX.value = 0;
  1078. offsetY.value = 0;
  1079. direction.value = "";
  1080. };
  1081. const start = (event) => {
  1082. reset();
  1083. startX.value = event.touches[0].clientX;
  1084. startY.value = event.touches[0].clientY;
  1085. };
  1086. const move = (event) => {
  1087. const touch = event.touches[0];
  1088. deltaX.value = (touch.clientX < 0 ? 0 : touch.clientX) - startX.value;
  1089. deltaY.value = touch.clientY - startY.value;
  1090. offsetX.value = Math.abs(deltaX.value);
  1091. offsetY.value = Math.abs(deltaY.value);
  1092. const LOCK_DIRECTION_DISTANCE = 10;
  1093. if (!direction.value || offsetX.value < LOCK_DIRECTION_DISTANCE && offsetY.value < LOCK_DIRECTION_DISTANCE) {
  1094. direction.value = getDirection(offsetX.value, offsetY.value);
  1095. }
  1096. };
  1097. return {
  1098. move,
  1099. start,
  1100. reset,
  1101. startX,
  1102. startY,
  1103. deltaX,
  1104. deltaY,
  1105. offsetX,
  1106. offsetY,
  1107. direction,
  1108. isVertical,
  1109. isHorizontal
  1110. };
  1111. }
  1112. let totalLockCount = 0;
  1113. const BODY_LOCK_CLASS = "van-overflow-hidden";
  1114. function useLockScroll(rootRef, shouldLock) {
  1115. const touch = useTouch();
  1116. const DIRECTION_UP = "01";
  1117. const DIRECTION_DOWN = "10";
  1118. const onTouchMove = (event) => {
  1119. touch.move(event);
  1120. const direction = touch.deltaY.value > 0 ? DIRECTION_DOWN : DIRECTION_UP;
  1121. const el = getScrollParent(
  1122. event.target,
  1123. rootRef.value
  1124. );
  1125. const { scrollHeight, offsetHeight, scrollTop } = el;
  1126. let status = "11";
  1127. if (scrollTop === 0) {
  1128. status = offsetHeight >= scrollHeight ? "00" : "01";
  1129. } else if (scrollTop + offsetHeight >= scrollHeight) {
  1130. status = "10";
  1131. }
  1132. if (status !== "11" && touch.isVertical() && !(parseInt(status, 2) & parseInt(direction, 2))) {
  1133. preventDefault(event, true);
  1134. }
  1135. };
  1136. const lock = () => {
  1137. document.addEventListener("touchstart", touch.start);
  1138. document.addEventListener("touchmove", onTouchMove, { passive: false });
  1139. if (!totalLockCount) {
  1140. document.body.classList.add(BODY_LOCK_CLASS);
  1141. }
  1142. totalLockCount++;
  1143. };
  1144. const unlock = () => {
  1145. if (totalLockCount) {
  1146. document.removeEventListener("touchstart", touch.start);
  1147. document.removeEventListener("touchmove", onTouchMove);
  1148. totalLockCount--;
  1149. if (!totalLockCount) {
  1150. document.body.classList.remove(BODY_LOCK_CLASS);
  1151. }
  1152. }
  1153. };
  1154. const init = () => shouldLock() && lock();
  1155. const destroy = () => shouldLock() && unlock();
  1156. onMountedOrActivated(init);
  1157. onDeactivated(destroy);
  1158. onBeforeUnmount(destroy);
  1159. watch(shouldLock, (value) => {
  1160. value ? lock() : unlock();
  1161. });
  1162. }
  1163. function useLazyRender(show) {
  1164. const inited = ref(false);
  1165. watch(
  1166. show,
  1167. (value) => {
  1168. if (value) {
  1169. inited.value = value;
  1170. }
  1171. },
  1172. { immediate: true }
  1173. );
  1174. return (render) => () => inited.value ? render() : null;
  1175. }
  1176. const [name$1t, bem$1o] = createNamespace("overlay");
  1177. const overlayProps = {
  1178. show: Boolean,
  1179. zIndex: numericProp,
  1180. duration: numericProp,
  1181. className: unknownProp,
  1182. lockScroll: truthProp,
  1183. lazyRender: truthProp,
  1184. customStyle: Object
  1185. };
  1186. var stdin_default$1A = defineComponent({
  1187. name: name$1t,
  1188. props: overlayProps,
  1189. setup(props, {
  1190. slots
  1191. }) {
  1192. const root = ref();
  1193. const lazyRender = useLazyRender(() => props.show || !props.lazyRender);
  1194. const onTouchMove = (event) => {
  1195. if (props.lockScroll) {
  1196. preventDefault(event, true);
  1197. }
  1198. };
  1199. const renderOverlay = lazyRender(() => {
  1200. var _a;
  1201. const style = extend(getZIndexStyle(props.zIndex), props.customStyle);
  1202. if (isDef(props.duration)) {
  1203. style.animationDuration = `${props.duration}s`;
  1204. }
  1205. return withDirectives(createVNode("div", {
  1206. "ref": root,
  1207. "style": style,
  1208. "class": [bem$1o(), props.className]
  1209. }, [(_a = slots.default) == null ? void 0 : _a.call(slots)]), [[vShow, props.show]]);
  1210. });
  1211. useEventListener("touchmove", onTouchMove, {
  1212. target: root
  1213. });
  1214. return () => createVNode(Transition, {
  1215. "name": "van-fade",
  1216. "appear": true
  1217. }, {
  1218. default: renderOverlay
  1219. });
  1220. }
  1221. });
  1222. const Overlay = withInstall(stdin_default$1A);
  1223. const popupProps$2 = extend({}, popupSharedProps, {
  1224. round: Boolean,
  1225. position: makeStringProp("center"),
  1226. closeIcon: makeStringProp("cross"),
  1227. closeable: Boolean,
  1228. transition: String,
  1229. iconPrefix: String,
  1230. closeOnPopstate: Boolean,
  1231. closeIconPosition: makeStringProp("top-right"),
  1232. safeAreaInsetTop: Boolean,
  1233. safeAreaInsetBottom: Boolean
  1234. });
  1235. const [name$1s, bem$1n] = createNamespace("popup");
  1236. var stdin_default$1z = defineComponent({
  1237. name: name$1s,
  1238. inheritAttrs: false,
  1239. props: popupProps$2,
  1240. emits: ["open", "close", "opened", "closed", "keydown", "update:show", "clickOverlay", "clickCloseIcon"],
  1241. setup(props, {
  1242. emit,
  1243. attrs,
  1244. slots
  1245. }) {
  1246. let opened;
  1247. let shouldReopen;
  1248. const zIndex = ref();
  1249. const popupRef = ref();
  1250. const lazyRender = useLazyRender(() => props.show || !props.lazyRender);
  1251. const style = computed(() => {
  1252. const style2 = {
  1253. zIndex: zIndex.value
  1254. };
  1255. if (isDef(props.duration)) {
  1256. const key = props.position === "center" ? "animationDuration" : "transitionDuration";
  1257. style2[key] = `${props.duration}s`;
  1258. }
  1259. return style2;
  1260. });
  1261. const open = () => {
  1262. if (!opened) {
  1263. opened = true;
  1264. zIndex.value = props.zIndex !== void 0 ? +props.zIndex : useGlobalZIndex();
  1265. emit("open");
  1266. }
  1267. };
  1268. const close = () => {
  1269. if (opened) {
  1270. callInterceptor(props.beforeClose, {
  1271. done() {
  1272. opened = false;
  1273. emit("close");
  1274. emit("update:show", false);
  1275. }
  1276. });
  1277. }
  1278. };
  1279. const onClickOverlay = (event) => {
  1280. emit("clickOverlay", event);
  1281. if (props.closeOnClickOverlay) {
  1282. close();
  1283. }
  1284. };
  1285. const renderOverlay = () => {
  1286. if (props.overlay) {
  1287. return createVNode(Overlay, {
  1288. "show": props.show,
  1289. "class": props.overlayClass,
  1290. "zIndex": zIndex.value,
  1291. "duration": props.duration,
  1292. "customStyle": props.overlayStyle,
  1293. "role": props.closeOnClickOverlay ? "button" : void 0,
  1294. "tabindex": props.closeOnClickOverlay ? 0 : void 0,
  1295. "onClick": onClickOverlay
  1296. }, {
  1297. default: slots["overlay-content"]
  1298. });
  1299. }
  1300. };
  1301. const onClickCloseIcon = (event) => {
  1302. emit("clickCloseIcon", event);
  1303. close();
  1304. };
  1305. const renderCloseIcon = () => {
  1306. if (props.closeable) {
  1307. return createVNode(Icon, {
  1308. "role": "button",
  1309. "tabindex": 0,
  1310. "name": props.closeIcon,
  1311. "class": [bem$1n("close-icon", props.closeIconPosition), HAPTICS_FEEDBACK],
  1312. "classPrefix": props.iconPrefix,
  1313. "onClick": onClickCloseIcon
  1314. }, null);
  1315. }
  1316. };
  1317. const onOpened = () => emit("opened");
  1318. const onClosed = () => emit("closed");
  1319. const onKeydown = (event) => emit("keydown", event);
  1320. const renderPopup = lazyRender(() => {
  1321. var _a;
  1322. const {
  1323. round,
  1324. position,
  1325. safeAreaInsetTop,
  1326. safeAreaInsetBottom
  1327. } = props;
  1328. return withDirectives(createVNode("div", mergeProps({
  1329. "ref": popupRef,
  1330. "style": style.value,
  1331. "role": "dialog",
  1332. "tabindex": 0,
  1333. "class": [bem$1n({
  1334. round,
  1335. [position]: position
  1336. }), {
  1337. "van-safe-area-top": safeAreaInsetTop,
  1338. "van-safe-area-bottom": safeAreaInsetBottom
  1339. }],
  1340. "onKeydown": onKeydown
  1341. }, attrs), [(_a = slots.default) == null ? void 0 : _a.call(slots), renderCloseIcon()]), [[vShow, props.show]]);
  1342. });
  1343. const renderTransition = () => {
  1344. const {
  1345. position,
  1346. transition,
  1347. transitionAppear
  1348. } = props;
  1349. const name2 = position === "center" ? "van-fade" : `van-popup-slide-${position}`;
  1350. return createVNode(Transition, {
  1351. "name": transition || name2,
  1352. "appear": transitionAppear,
  1353. "onAfterEnter": onOpened,
  1354. "onAfterLeave": onClosed
  1355. }, {
  1356. default: renderPopup
  1357. });
  1358. };
  1359. watch(() => props.show, (show) => {
  1360. if (show && !opened) {
  1361. open();
  1362. if (attrs.tabindex === 0) {
  1363. nextTick(() => {
  1364. var _a;
  1365. (_a = popupRef.value) == null ? void 0 : _a.focus();
  1366. });
  1367. }
  1368. }
  1369. if (!show && opened) {
  1370. opened = false;
  1371. emit("close");
  1372. }
  1373. });
  1374. useExpose({
  1375. popupRef
  1376. });
  1377. useLockScroll(popupRef, () => props.show && props.lockScroll);
  1378. useEventListener("popstate", () => {
  1379. if (props.closeOnPopstate) {
  1380. close();
  1381. shouldReopen = false;
  1382. }
  1383. });
  1384. onMounted(() => {
  1385. if (props.show) {
  1386. open();
  1387. }
  1388. });
  1389. onActivated(() => {
  1390. if (shouldReopen) {
  1391. emit("update:show", true);
  1392. shouldReopen = false;
  1393. }
  1394. });
  1395. onDeactivated(() => {
  1396. if (props.show && props.teleport) {
  1397. close();
  1398. shouldReopen = true;
  1399. }
  1400. });
  1401. provide(POPUP_TOGGLE_KEY, () => props.show);
  1402. return () => {
  1403. if (props.teleport) {
  1404. return createVNode(Teleport, {
  1405. "to": props.teleport
  1406. }, {
  1407. default: () => [renderOverlay(), renderTransition()]
  1408. });
  1409. }
  1410. return createVNode(Fragment, null, [renderOverlay(), renderTransition()]);
  1411. };
  1412. }
  1413. });
  1414. const Popup = withInstall(stdin_default$1z);
  1415. const [name$1r, bem$1m] = createNamespace("action-sheet");
  1416. const actionSheetProps = extend({}, popupSharedProps, {
  1417. title: String,
  1418. round: truthProp,
  1419. actions: makeArrayProp(),
  1420. closeIcon: makeStringProp("cross"),
  1421. closeable: truthProp,
  1422. cancelText: String,
  1423. description: String,
  1424. closeOnPopstate: truthProp,
  1425. closeOnClickAction: Boolean,
  1426. safeAreaInsetBottom: truthProp
  1427. });
  1428. const popupInheritKeys$2 = [...popupSharedPropKeys, "round", "closeOnPopstate", "safeAreaInsetBottom"];
  1429. var stdin_default$1y = defineComponent({
  1430. name: name$1r,
  1431. props: actionSheetProps,
  1432. emits: ["select", "cancel", "update:show"],
  1433. setup(props, {
  1434. slots,
  1435. emit
  1436. }) {
  1437. const updateShow = (show) => emit("update:show", show);
  1438. const onCancel = () => {
  1439. updateShow(false);
  1440. emit("cancel");
  1441. };
  1442. const renderHeader = () => {
  1443. if (props.title) {
  1444. return createVNode("div", {
  1445. "class": bem$1m("header")
  1446. }, [props.title, props.closeable && createVNode(Icon, {
  1447. "name": props.closeIcon,
  1448. "class": [bem$1m("close"), HAPTICS_FEEDBACK],
  1449. "onClick": onCancel
  1450. }, null)]);
  1451. }
  1452. };
  1453. const renderCancel = () => {
  1454. if (slots.cancel || props.cancelText) {
  1455. return [createVNode("div", {
  1456. "class": bem$1m("gap")
  1457. }, null), createVNode("button", {
  1458. "type": "button",
  1459. "class": bem$1m("cancel"),
  1460. "onClick": onCancel
  1461. }, [slots.cancel ? slots.cancel() : props.cancelText])];
  1462. }
  1463. };
  1464. const renderActionContent = (action, index) => {
  1465. if (action.loading) {
  1466. return createVNode(Loading, {
  1467. "class": bem$1m("loading-icon")
  1468. }, null);
  1469. }
  1470. if (slots.action) {
  1471. return slots.action({
  1472. action,
  1473. index
  1474. });
  1475. }
  1476. return [createVNode("span", {
  1477. "class": bem$1m("name")
  1478. }, [action.name]), action.subname && createVNode("div", {
  1479. "class": bem$1m("subname")
  1480. }, [action.subname])];
  1481. };
  1482. const renderAction = (action, index) => {
  1483. const {
  1484. color,
  1485. loading,
  1486. callback,
  1487. disabled,
  1488. className
  1489. } = action;
  1490. const onClick = () => {
  1491. if (disabled || loading) {
  1492. return;
  1493. }
  1494. if (callback) {
  1495. callback(action);
  1496. }
  1497. if (props.closeOnClickAction) {
  1498. updateShow(false);
  1499. }
  1500. nextTick(() => emit("select", action, index));
  1501. };
  1502. return createVNode("button", {
  1503. "type": "button",
  1504. "style": {
  1505. color
  1506. },
  1507. "class": [bem$1m("item", {
  1508. loading,
  1509. disabled
  1510. }), className],
  1511. "onClick": onClick
  1512. }, [renderActionContent(action, index)]);
  1513. };
  1514. const renderDescription = () => {
  1515. if (props.description || slots.description) {
  1516. const content = slots.description ? slots.description() : props.description;
  1517. return createVNode("div", {
  1518. "class": bem$1m("description")
  1519. }, [content]);
  1520. }
  1521. };
  1522. return () => createVNode(Popup, mergeProps({
  1523. "class": bem$1m(),
  1524. "position": "bottom",
  1525. "onUpdate:show": updateShow
  1526. }, pick(props, popupInheritKeys$2)), {
  1527. default: () => {
  1528. var _a;
  1529. return [renderHeader(), renderDescription(), createVNode("div", {
  1530. "class": bem$1m("content")
  1531. }, [props.actions.map(renderAction), (_a = slots.default) == null ? void 0 : _a.call(slots)]), renderCancel()];
  1532. }
  1533. });
  1534. }
  1535. });
  1536. const ActionSheet = withInstall(stdin_default$1y);
  1537. const [name$1q, bem$1l, t$j] = createNamespace("picker");
  1538. const getFirstEnabledOption = (options) => options.find((option) => !option.disabled) || options[0];
  1539. function getColumnsType(columns, fields) {
  1540. const firstColumn = columns[0];
  1541. if (firstColumn) {
  1542. if (Array.isArray(firstColumn)) {
  1543. return "multiple";
  1544. }
  1545. if (fields.children in firstColumn) {
  1546. return "cascade";
  1547. }
  1548. }
  1549. return "default";
  1550. }
  1551. function findIndexOfEnabledOption(options, index) {
  1552. index = clamp(index, 0, options.length);
  1553. for (let i = index; i < options.length; i++) {
  1554. if (!options[i].disabled)
  1555. return i;
  1556. }
  1557. for (let i = index - 1; i >= 0; i--) {
  1558. if (!options[i].disabled)
  1559. return i;
  1560. }
  1561. return 0;
  1562. }
  1563. const isOptionExist = (options, value, fields) => value !== void 0 && !!options.find((option) => option[fields.value] === value);
  1564. function findOptionByValue(options, value, fields) {
  1565. const index = options.findIndex((option) => option[fields.value] === value);
  1566. const enabledIndex = findIndexOfEnabledOption(options, index);
  1567. return options[enabledIndex];
  1568. }
  1569. function formatCascadeColumns(columns, fields, selectedValues) {
  1570. const formatted = [];
  1571. let cursor = {
  1572. [fields.children]: columns
  1573. };
  1574. let columnIndex = 0;
  1575. while (cursor && cursor[fields.children]) {
  1576. const options = cursor[fields.children];
  1577. const value = selectedValues.value[columnIndex];
  1578. cursor = isDef(value) ? findOptionByValue(options, value, fields) : void 0;
  1579. if (!cursor && options.length) {
  1580. const firstValue = getFirstEnabledOption(options)[fields.value];
  1581. cursor = findOptionByValue(options, firstValue, fields);
  1582. }
  1583. columnIndex++;
  1584. formatted.push(options);
  1585. }
  1586. return formatted;
  1587. }
  1588. function getElementTranslateY(element) {
  1589. const { transform } = window.getComputedStyle(element);
  1590. const translateY = transform.slice(7, transform.length - 1).split(", ")[5];
  1591. return Number(translateY);
  1592. }
  1593. function assignDefaultFields(fields) {
  1594. return extend(
  1595. {
  1596. text: "text",
  1597. value: "value",
  1598. children: "children"
  1599. },
  1600. fields
  1601. );
  1602. }
  1603. const DEFAULT_DURATION = 200;
  1604. const MOMENTUM_TIME = 300;
  1605. const MOMENTUM_DISTANCE = 15;
  1606. const [name$1p, bem$1k] = createNamespace("picker-column");
  1607. const PICKER_KEY = Symbol(name$1p);
  1608. var stdin_default$1x = defineComponent({
  1609. name: name$1p,
  1610. props: {
  1611. value: numericProp,
  1612. fields: makeRequiredProp(Object),
  1613. options: makeArrayProp(),
  1614. readonly: Boolean,
  1615. allowHtml: Boolean,
  1616. optionHeight: makeRequiredProp(Number),
  1617. swipeDuration: makeRequiredProp(numericProp),
  1618. visibleOptionNum: makeRequiredProp(numericProp)
  1619. },
  1620. emits: ["change", "clickOption"],
  1621. setup(props, {
  1622. emit,
  1623. slots
  1624. }) {
  1625. let moving;
  1626. let startOffset;
  1627. let touchStartTime;
  1628. let momentumOffset;
  1629. let transitionEndTrigger;
  1630. const root = ref();
  1631. const wrapper = ref();
  1632. const currentOffset = ref(0);
  1633. const currentDuration = ref(0);
  1634. const touch = useTouch();
  1635. const count = () => props.options.length;
  1636. const baseOffset = () => props.optionHeight * (+props.visibleOptionNum - 1) / 2;
  1637. const updateValueByIndex = (index) => {
  1638. const enabledIndex = findIndexOfEnabledOption(props.options, index);
  1639. const offset = -enabledIndex * props.optionHeight;
  1640. const trigger = () => {
  1641. const value = props.options[enabledIndex][props.fields.value];
  1642. if (value !== props.value) {
  1643. emit("change", value);
  1644. }
  1645. };
  1646. if (moving && offset !== currentOffset.value) {
  1647. transitionEndTrigger = trigger;
  1648. } else {
  1649. trigger();
  1650. }
  1651. currentOffset.value = offset;
  1652. };
  1653. const isReadonly = () => props.readonly || !props.options.length;
  1654. const onClickOption = (index) => {
  1655. if (moving || isReadonly()) {
  1656. return;
  1657. }
  1658. transitionEndTrigger = null;
  1659. currentDuration.value = DEFAULT_DURATION;
  1660. updateValueByIndex(index);
  1661. emit("clickOption", props.options[index]);
  1662. };
  1663. const getIndexByOffset = (offset) => clamp(Math.round(-offset / props.optionHeight), 0, count() - 1);
  1664. const momentum = (distance, duration) => {
  1665. const speed = Math.abs(distance / duration);
  1666. distance = currentOffset.value + speed / 3e-3 * (distance < 0 ? -1 : 1);
  1667. const index = getIndexByOffset(distance);
  1668. currentDuration.value = +props.swipeDuration;
  1669. updateValueByIndex(index);
  1670. };
  1671. const stopMomentum = () => {
  1672. moving = false;
  1673. currentDuration.value = 0;
  1674. if (transitionEndTrigger) {
  1675. transitionEndTrigger();
  1676. transitionEndTrigger = null;
  1677. }
  1678. };
  1679. const onTouchStart = (event) => {
  1680. if (isReadonly()) {
  1681. return;
  1682. }
  1683. touch.start(event);
  1684. if (moving) {
  1685. const translateY = getElementTranslateY(wrapper.value);
  1686. currentOffset.value = Math.min(0, translateY - baseOffset());
  1687. }
  1688. currentDuration.value = 0;
  1689. startOffset = currentOffset.value;
  1690. touchStartTime = Date.now();
  1691. momentumOffset = startOffset;
  1692. transitionEndTrigger = null;
  1693. };
  1694. const onTouchMove = (event) => {
  1695. if (isReadonly()) {
  1696. return;
  1697. }
  1698. touch.move(event);
  1699. if (touch.isVertical()) {
  1700. moving = true;
  1701. preventDefault(event, true);
  1702. }
  1703. currentOffset.value = clamp(startOffset + touch.deltaY.value, -(count() * props.optionHeight), props.optionHeight);
  1704. const now = Date.now();
  1705. if (now - touchStartTime > MOMENTUM_TIME) {
  1706. touchStartTime = now;
  1707. momentumOffset = currentOffset.value;
  1708. }
  1709. };
  1710. const onTouchEnd = () => {
  1711. if (isReadonly()) {
  1712. return;
  1713. }
  1714. const distance = currentOffset.value - momentumOffset;
  1715. const duration = Date.now() - touchStartTime;
  1716. const startMomentum = duration < MOMENTUM_TIME && Math.abs(distance) > MOMENTUM_DISTANCE;
  1717. if (startMomentum) {
  1718. momentum(distance, duration);
  1719. return;
  1720. }
  1721. const index = getIndexByOffset(currentOffset.value);
  1722. currentDuration.value = DEFAULT_DURATION;
  1723. updateValueByIndex(index);
  1724. setTimeout(() => {
  1725. moving = false;
  1726. }, 0);
  1727. };
  1728. const renderOptions = () => {
  1729. const optionStyle = {
  1730. height: `${props.optionHeight}px`
  1731. };
  1732. return props.options.map((option, index) => {
  1733. const text = option[props.fields.text];
  1734. const {
  1735. disabled
  1736. } = option;
  1737. const value = option[props.fields.value];
  1738. const data = {
  1739. role: "button",
  1740. style: optionStyle,
  1741. tabindex: disabled ? -1 : 0,
  1742. class: [bem$1k("item", {
  1743. disabled,
  1744. selected: value === props.value
  1745. }), option.className],
  1746. onClick: () => onClickOption(index)
  1747. };
  1748. const childData = {
  1749. class: "van-ellipsis",
  1750. [props.allowHtml ? "innerHTML" : "textContent"]: text
  1751. };
  1752. return createVNode("li", data, [slots.option ? slots.option(option) : createVNode("div", childData, null)]);
  1753. });
  1754. };
  1755. useParent(PICKER_KEY);
  1756. useExpose({
  1757. stopMomentum
  1758. });
  1759. watchEffect(() => {
  1760. const index = props.options.findIndex((option) => option[props.fields.value] === props.value);
  1761. const enabledIndex = findIndexOfEnabledOption(props.options, index);
  1762. const offset = -enabledIndex * props.optionHeight;
  1763. currentOffset.value = offset;
  1764. });
  1765. useEventListener("touchmove", onTouchMove, {
  1766. target: root
  1767. });
  1768. return () => createVNode("div", {
  1769. "ref": root,
  1770. "class": bem$1k(),
  1771. "onTouchstartPassive": onTouchStart,
  1772. "onTouchend": onTouchEnd,
  1773. "onTouchcancel": onTouchEnd
  1774. }, [createVNode("ul", {
  1775. "ref": wrapper,
  1776. "style": {
  1777. transform: `translate3d(0, ${currentOffset.value + baseOffset()}px, 0)`,
  1778. transitionDuration: `${currentDuration.value}ms`,
  1779. transitionProperty: currentDuration.value ? "all" : "none"
  1780. },
  1781. "class": bem$1k("wrapper"),
  1782. "onTransitionend": stopMomentum
  1783. }, [renderOptions()])]);
  1784. }
  1785. });
  1786. const [name$1o] = createNamespace("picker-toolbar");
  1787. const pickerToolbarProps = {
  1788. title: String,
  1789. cancelButtonText: String,
  1790. confirmButtonText: String
  1791. };
  1792. const pickerToolbarSlots = ["cancel", "confirm", "title", "toolbar"];
  1793. const pickerToolbarPropKeys = Object.keys(pickerToolbarProps);
  1794. var stdin_default$1w = defineComponent({
  1795. name: name$1o,
  1796. props: pickerToolbarProps,
  1797. emits: ["confirm", "cancel"],
  1798. setup(props, {
  1799. emit,
  1800. slots
  1801. }) {
  1802. const renderTitle = () => {
  1803. if (slots.title) {
  1804. return slots.title();
  1805. }
  1806. if (props.title) {
  1807. return createVNode("div", {
  1808. "class": [bem$1l("title"), "van-ellipsis"]
  1809. }, [props.title]);
  1810. }
  1811. };
  1812. const onCancel = () => emit("cancel");
  1813. const onConfirm = () => emit("confirm");
  1814. const renderCancel = () => {
  1815. const text = props.cancelButtonText || t$j("cancel");
  1816. return createVNode("button", {
  1817. "type": "button",
  1818. "class": [bem$1l("cancel"), HAPTICS_FEEDBACK],
  1819. "onClick": onCancel
  1820. }, [slots.cancel ? slots.cancel() : text]);
  1821. };
  1822. const renderConfirm = () => {
  1823. const text = props.confirmButtonText || t$j("confirm");
  1824. return createVNode("button", {
  1825. "type": "button",
  1826. "class": [bem$1l("confirm"), HAPTICS_FEEDBACK],
  1827. "onClick": onConfirm
  1828. }, [slots.confirm ? slots.confirm() : text]);
  1829. };
  1830. return () => createVNode("div", {
  1831. "class": bem$1l("toolbar")
  1832. }, [slots.toolbar ? slots.toolbar() : [renderCancel(), renderTitle(), renderConfirm()]]);
  1833. }
  1834. });
  1835. function scrollLeftTo(scroller, to, duration) {
  1836. let count = 0;
  1837. const from = scroller.scrollLeft;
  1838. const frames = duration === 0 ? 1 : Math.round(duration * 1e3 / 16);
  1839. function animate() {
  1840. scroller.scrollLeft += (to - from) / frames;
  1841. if (++count < frames) {
  1842. raf(animate);
  1843. }
  1844. }
  1845. animate();
  1846. }
  1847. function scrollTopTo(scroller, to, duration, callback) {
  1848. let current2 = getScrollTop(scroller);
  1849. const isDown = current2 < to;
  1850. const frames = duration === 0 ? 1 : Math.round(duration * 1e3 / 16);
  1851. const step = (to - current2) / frames;
  1852. function animate() {
  1853. current2 += step;
  1854. if (isDown && current2 > to || !isDown && current2 < to) {
  1855. current2 = to;
  1856. }
  1857. setScrollTop(scroller, current2);
  1858. if (isDown && current2 < to || !isDown && current2 > to) {
  1859. raf(animate);
  1860. } else if (callback) {
  1861. raf(callback);
  1862. }
  1863. }
  1864. animate();
  1865. }
  1866. let current = 0;
  1867. function useId() {
  1868. const vm = getCurrentInstance();
  1869. const { name: name2 = "unknown" } = (vm == null ? void 0 : vm.type) || {};
  1870. if (process.env.NODE_ENV === "test") {
  1871. return name2;
  1872. }
  1873. return `${name2}-${++current}`;
  1874. }
  1875. function useRefs() {
  1876. const refs = ref([]);
  1877. const cache = [];
  1878. onBeforeUpdate(() => {
  1879. refs.value = [];
  1880. });
  1881. const setRefs = (index) => {
  1882. if (!cache[index]) {
  1883. cache[index] = (el) => {
  1884. refs.value[index] = el;
  1885. };
  1886. }
  1887. return cache[index];
  1888. };
  1889. return [refs, setRefs];
  1890. }
  1891. function useVisibilityChange(target, onChange) {
  1892. if (!inBrowser || !window.IntersectionObserver) {
  1893. return;
  1894. }
  1895. const observer = new IntersectionObserver(
  1896. (entries) => {
  1897. onChange(entries[0].intersectionRatio > 0);
  1898. },
  1899. { root: document.body }
  1900. );
  1901. const observe = () => {
  1902. if (target.value) {
  1903. observer.observe(target.value);
  1904. }
  1905. };
  1906. const unobserve = () => {
  1907. if (target.value) {
  1908. observer.unobserve(target.value);
  1909. }
  1910. };
  1911. onDeactivated(unobserve);
  1912. onBeforeUnmount(unobserve);
  1913. onMountedOrActivated(observe);
  1914. }
  1915. const [name$1n, bem$1j] = createNamespace("sticky");
  1916. const stickyProps = {
  1917. zIndex: numericProp,
  1918. position: makeStringProp("top"),
  1919. container: Object,
  1920. offsetTop: makeNumericProp(0),
  1921. offsetBottom: makeNumericProp(0)
  1922. };
  1923. var stdin_default$1v = defineComponent({
  1924. name: name$1n,
  1925. props: stickyProps,
  1926. emits: ["scroll", "change"],
  1927. setup(props, {
  1928. emit,
  1929. slots
  1930. }) {
  1931. const root = ref();
  1932. const scrollParent = useScrollParent(root);
  1933. const state = reactive({
  1934. fixed: false,
  1935. width: 0,
  1936. height: 0,
  1937. transform: 0
  1938. });
  1939. const offset = computed(() => unitToPx(props.position === "top" ? props.offsetTop : props.offsetBottom));
  1940. const rootStyle = computed(() => {
  1941. const {
  1942. fixed,
  1943. height,
  1944. width
  1945. } = state;
  1946. if (fixed) {
  1947. return {
  1948. width: `${width}px`,
  1949. height: `${height}px`
  1950. };
  1951. }
  1952. });
  1953. const stickyStyle = computed(() => {
  1954. if (!state.fixed) {
  1955. return;
  1956. }
  1957. const style = extend(getZIndexStyle(props.zIndex), {
  1958. width: `${state.width}px`,
  1959. height: `${state.height}px`,
  1960. [props.position]: `${offset.value}px`
  1961. });
  1962. if (state.transform) {
  1963. style.transform = `translate3d(0, ${state.transform}px, 0)`;
  1964. }
  1965. return style;
  1966. });
  1967. const emitScroll = (scrollTop) => emit("scroll", {
  1968. scrollTop,
  1969. isFixed: state.fixed
  1970. });
  1971. const onScroll = () => {
  1972. if (!root.value || isHidden(root)) {
  1973. return;
  1974. }
  1975. const {
  1976. container,
  1977. position
  1978. } = props;
  1979. const rootRect = useRect(root);
  1980. const scrollTop = getScrollTop(window);
  1981. state.width = rootRect.width;
  1982. state.height = rootRect.height;
  1983. if (position === "top") {
  1984. if (container) {
  1985. const containerRect = useRect(container);
  1986. const difference = containerRect.bottom - offset.value - state.height;
  1987. state.fixed = offset.value > rootRect.top && containerRect.bottom > 0;
  1988. state.transform = difference < 0 ? difference : 0;
  1989. } else {
  1990. state.fixed = offset.value > rootRect.top;
  1991. }
  1992. } else {
  1993. const {
  1994. clientHeight
  1995. } = document.documentElement;
  1996. if (container) {
  1997. const containerRect = useRect(container);
  1998. const difference = clientHeight - containerRect.top - offset.value - state.height;
  1999. state.fixed = clientHeight - offset.value < rootRect.bottom && clientHeight > containerRect.top;
  2000. state.transform = difference < 0 ? -difference : 0;
  2001. } else {
  2002. state.fixed = clientHeight - offset.value < rootRect.bottom;
  2003. }
  2004. }
  2005. emitScroll(scrollTop);
  2006. };
  2007. watch(() => state.fixed, (value) => emit("change", value));
  2008. useEventListener("scroll", onScroll, {
  2009. target: scrollParent,
  2010. passive: true
  2011. });
  2012. useVisibilityChange(root, onScroll);
  2013. return () => {
  2014. var _a;
  2015. return createVNode("div", {
  2016. "ref": root,
  2017. "style": rootStyle.value
  2018. }, [createVNode("div", {
  2019. "class": bem$1j({
  2020. fixed: state.fixed
  2021. }),
  2022. "style": stickyStyle.value
  2023. }, [(_a = slots.default) == null ? void 0 : _a.call(slots)])]);
  2024. };
  2025. }
  2026. });
  2027. const Sticky = withInstall(stdin_default$1v);
  2028. const [name$1m, bem$1i] = createNamespace("tab");
  2029. var stdin_default$1u = defineComponent({
  2030. name: name$1m,
  2031. props: {
  2032. id: String,
  2033. dot: Boolean,
  2034. type: String,
  2035. color: String,
  2036. title: String,
  2037. badge: numericProp,
  2038. shrink: Boolean,
  2039. isActive: Boolean,
  2040. disabled: Boolean,
  2041. controls: String,
  2042. scrollable: Boolean,
  2043. activeColor: String,
  2044. inactiveColor: String,
  2045. showZeroBadge: truthProp
  2046. },
  2047. setup(props, {
  2048. slots
  2049. }) {
  2050. const style = computed(() => {
  2051. const style2 = {};
  2052. const {
  2053. type,
  2054. color,
  2055. disabled,
  2056. isActive,
  2057. activeColor,
  2058. inactiveColor
  2059. } = props;
  2060. const isCard = type === "card";
  2061. if (color && isCard) {
  2062. style2.borderColor = color;
  2063. if (!disabled) {
  2064. if (isActive) {
  2065. style2.backgroundColor = color;
  2066. } else {
  2067. style2.color = color;
  2068. }
  2069. }
  2070. }
  2071. const titleColor = isActive ? activeColor : inactiveColor;
  2072. if (titleColor) {
  2073. style2.color = titleColor;
  2074. }
  2075. return style2;
  2076. });
  2077. const renderText = () => {
  2078. const Text2 = createVNode("span", {
  2079. "class": bem$1i("text", {
  2080. ellipsis: !props.scrollable
  2081. })
  2082. }, [slots.title ? slots.title() : props.title]);
  2083. if (props.dot || isDef(props.badge) && props.badge !== "") {
  2084. return createVNode(Badge, {
  2085. "dot": props.dot,
  2086. "content": props.badge,
  2087. "showZero": props.showZeroBadge
  2088. }, {
  2089. default: () => [Text2]
  2090. });
  2091. }
  2092. return Text2;
  2093. };
  2094. return () => createVNode("div", {
  2095. "id": props.id,
  2096. "role": "tab",
  2097. "class": [bem$1i([props.type, {
  2098. grow: props.scrollable && !props.shrink,
  2099. shrink: props.shrink,
  2100. active: props.isActive,
  2101. disabled: props.disabled
  2102. }])],
  2103. "style": style.value,
  2104. "tabindex": props.disabled ? void 0 : props.isActive ? 0 : -1,
  2105. "aria-selected": props.isActive,
  2106. "aria-disabled": props.disabled || void 0,
  2107. "aria-controls": props.controls
  2108. }, [renderText()]);
  2109. }
  2110. });
  2111. const [name$1l, bem$1h] = createNamespace("swipe");
  2112. const swipeProps = {
  2113. loop: truthProp,
  2114. width: numericProp,
  2115. height: numericProp,
  2116. vertical: Boolean,
  2117. autoplay: makeNumericProp(0),
  2118. duration: makeNumericProp(500),
  2119. touchable: truthProp,
  2120. lazyRender: Boolean,
  2121. initialSwipe: makeNumericProp(0),
  2122. indicatorColor: String,
  2123. showIndicators: truthProp,
  2124. stopPropagation: truthProp
  2125. };
  2126. const SWIPE_KEY = Symbol(name$1l);
  2127. var stdin_default$1t = defineComponent({
  2128. name: name$1l,
  2129. props: swipeProps,
  2130. emits: ["change"],
  2131. setup(props, {
  2132. emit,
  2133. slots
  2134. }) {
  2135. const root = ref();
  2136. const track = ref();
  2137. const state = reactive({
  2138. rect: null,
  2139. width: 0,
  2140. height: 0,
  2141. offset: 0,
  2142. active: 0,
  2143. swiping: false
  2144. });
  2145. const touch = useTouch();
  2146. const {
  2147. children,
  2148. linkChildren
  2149. } = useChildren(SWIPE_KEY);
  2150. const count = computed(() => children.length);
  2151. const size = computed(() => state[props.vertical ? "height" : "width"]);
  2152. const delta = computed(() => props.vertical ? touch.deltaY.value : touch.deltaX.value);
  2153. const minOffset = computed(() => {
  2154. if (state.rect) {
  2155. const base = props.vertical ? state.rect.height : state.rect.width;
  2156. return base - size.value * count.value;
  2157. }
  2158. return 0;
  2159. });
  2160. const maxCount = computed(() => size.value ? Math.ceil(Math.abs(minOffset.value) / size.value) : count.value);
  2161. const trackSize = computed(() => count.value * size.value);
  2162. const activeIndicator = computed(() => (state.active + count.value) % count.value);
  2163. const isCorrectDirection = computed(() => {
  2164. const expect = props.vertical ? "vertical" : "horizontal";
  2165. return touch.direction.value === expect;
  2166. });
  2167. const trackStyle = computed(() => {
  2168. const style = {
  2169. transitionDuration: `${state.swiping ? 0 : props.duration}ms`,
  2170. transform: `translate${props.vertical ? "Y" : "X"}(${state.offset}px)`
  2171. };
  2172. if (size.value) {
  2173. const mainAxis = props.vertical ? "height" : "width";
  2174. const crossAxis = props.vertical ? "width" : "height";
  2175. style[mainAxis] = `${trackSize.value}px`;
  2176. style[crossAxis] = props[crossAxis] ? `${props[crossAxis]}px` : "";
  2177. }
  2178. return style;
  2179. });
  2180. const getTargetActive = (pace) => {
  2181. const {
  2182. active
  2183. } = state;
  2184. if (pace) {
  2185. if (props.loop) {
  2186. return clamp(active + pace, -1, count.value);
  2187. }
  2188. return clamp(active + pace, 0, maxCount.value);
  2189. }
  2190. return active;
  2191. };
  2192. const getTargetOffset = (targetActive, offset = 0) => {
  2193. let currentPosition = targetActive * size.value;
  2194. if (!props.loop) {
  2195. currentPosition = Math.min(currentPosition, -minOffset.value);
  2196. }
  2197. let targetOffset = offset - currentPosition;
  2198. if (!props.loop) {
  2199. targetOffset = clamp(targetOffset, minOffset.value, 0);
  2200. }
  2201. return targetOffset;
  2202. };
  2203. const move = ({
  2204. pace = 0,
  2205. offset = 0,
  2206. emitChange
  2207. }) => {
  2208. if (count.value <= 1) {
  2209. return;
  2210. }
  2211. const {
  2212. active
  2213. } = state;
  2214. const targetActive = getTargetActive(pace);
  2215. const targetOffset = getTargetOffset(targetActive, offset);
  2216. if (props.loop) {
  2217. if (children[0] && targetOffset !== minOffset.value) {
  2218. const outRightBound = targetOffset < minOffset.value;
  2219. children[0].setOffset(outRightBound ? trackSize.value : 0);
  2220. }
  2221. if (children[count.value - 1] && targetOffset !== 0) {
  2222. const outLeftBound = targetOffset > 0;
  2223. children[count.value - 1].setOffset(outLeftBound ? -trackSize.value : 0);
  2224. }
  2225. }
  2226. state.active = targetActive;
  2227. state.offset = targetOffset;
  2228. if (emitChange && targetActive !== active) {
  2229. emit("change", activeIndicator.value);
  2230. }
  2231. };
  2232. const correctPosition = () => {
  2233. state.swiping = true;
  2234. if (state.active <= -1) {
  2235. move({
  2236. pace: count.value
  2237. });
  2238. } else if (state.active >= count.value) {
  2239. move({
  2240. pace: -count.value
  2241. });
  2242. }
  2243. };
  2244. const prev = () => {
  2245. correctPosition();
  2246. touch.reset();
  2247. doubleRaf(() => {
  2248. state.swiping = false;
  2249. move({
  2250. pace: -1,
  2251. emitChange: true
  2252. });
  2253. });
  2254. };
  2255. const next = () => {
  2256. correctPosition();
  2257. touch.reset();
  2258. doubleRaf(() => {
  2259. state.swiping = false;
  2260. move({
  2261. pace: 1,
  2262. emitChange: true
  2263. });
  2264. });
  2265. };
  2266. let autoplayTimer;
  2267. const stopAutoplay = () => clearTimeout(autoplayTimer);
  2268. const autoplay = () => {
  2269. stopAutoplay();
  2270. if (props.autoplay > 0 && count.value > 1) {
  2271. autoplayTimer = setTimeout(() => {
  2272. next();
  2273. autoplay();
  2274. }, +props.autoplay);
  2275. }
  2276. };
  2277. const initialize = (active = +props.initialSwipe) => {
  2278. if (!root.value) {
  2279. return;
  2280. }
  2281. const cb = () => {
  2282. var _a, _b;
  2283. if (!isHidden(root)) {
  2284. const rect = {
  2285. width: root.value.offsetWidth,
  2286. height: root.value.offsetHeight
  2287. };
  2288. state.rect = rect;
  2289. state.width = +((_a = props.width) != null ? _a : rect.width);
  2290. state.height = +((_b = props.height) != null ? _b : rect.height);
  2291. }
  2292. if (count.value) {
  2293. active = Math.min(count.value - 1, active);
  2294. }
  2295. state.active = active;
  2296. state.swiping = true;
  2297. state.offset = getTargetOffset(active);
  2298. children.forEach((swipe) => {
  2299. swipe.setOffset(0);
  2300. });
  2301. autoplay();
  2302. };
  2303. if (isHidden(root)) {
  2304. nextTick().then(cb);
  2305. } else {
  2306. cb();
  2307. }
  2308. };
  2309. const resize = () => initialize(state.active);
  2310. let touchStartTime;
  2311. const onTouchStart = (event) => {
  2312. if (!props.touchable)
  2313. return;
  2314. touch.start(event);
  2315. touchStartTime = Date.now();
  2316. stopAutoplay();
  2317. correctPosition();
  2318. };
  2319. const onTouchMove = (event) => {
  2320. if (props.touchable && state.swiping) {
  2321. touch.move(event);
  2322. if (isCorrectDirection.value) {
  2323. const isEdgeTouch = !props.loop && (state.active === 0 && delta.value > 0 || state.active === count.value - 1 && delta.value < 0);
  2324. if (!isEdgeTouch) {
  2325. preventDefault(event, props.stopPropagation);
  2326. move({
  2327. offset: delta.value
  2328. });
  2329. }
  2330. }
  2331. }
  2332. };
  2333. const onTouchEnd = () => {
  2334. if (!props.touchable || !state.swiping) {
  2335. return;
  2336. }
  2337. const duration = Date.now() - touchStartTime;
  2338. const speed = delta.value / duration;
  2339. const shouldSwipe = Math.abs(speed) > 0.25 || Math.abs(delta.value) > size.value / 2;
  2340. if (shouldSwipe && isCorrectDirection.value) {
  2341. const offset = props.vertical ? touch.offsetY.value : touch.offsetX.value;
  2342. let pace = 0;
  2343. if (props.loop) {
  2344. pace = offset > 0 ? delta.value > 0 ? -1 : 1 : 0;
  2345. } else {
  2346. pace = -Math[delta.value > 0 ? "ceil" : "floor"](delta.value / size.value);
  2347. }
  2348. move({
  2349. pace,
  2350. emitChange: true
  2351. });
  2352. } else if (delta.value) {
  2353. move({
  2354. pace: 0
  2355. });
  2356. }
  2357. state.swiping = false;
  2358. autoplay();
  2359. };
  2360. const swipeTo = (index, options = {}) => {
  2361. correctPosition();
  2362. touch.reset();
  2363. doubleRaf(() => {
  2364. let targetIndex;
  2365. if (props.loop && index === count.value) {
  2366. targetIndex = state.active === 0 ? 0 : index;
  2367. } else {
  2368. targetIndex = index % count.value;
  2369. }
  2370. if (options.immediate) {
  2371. doubleRaf(() => {
  2372. state.swiping = false;
  2373. });
  2374. } else {
  2375. state.swiping = false;
  2376. }
  2377. move({
  2378. pace: targetIndex - state.active,
  2379. emitChange: true
  2380. });
  2381. });
  2382. };
  2383. const renderDot = (_, index) => {
  2384. const active = index === activeIndicator.value;
  2385. const style = active ? {
  2386. backgroundColor: props.indicatorColor
  2387. } : void 0;
  2388. return createVNode("i", {
  2389. "style": style,
  2390. "class": bem$1h("indicator", {
  2391. active
  2392. })
  2393. }, null);
  2394. };
  2395. const renderIndicator = () => {
  2396. if (slots.indicator) {
  2397. return slots.indicator({
  2398. active: activeIndicator.value,
  2399. total: count.value
  2400. });
  2401. }
  2402. if (props.showIndicators && count.value > 1) {
  2403. return createVNode("div", {
  2404. "class": bem$1h("indicators", {
  2405. vertical: props.vertical
  2406. })
  2407. }, [Array(count.value).fill("").map(renderDot)]);
  2408. }
  2409. };
  2410. useExpose({
  2411. prev,
  2412. next,
  2413. state,
  2414. resize,
  2415. swipeTo
  2416. });
  2417. linkChildren({
  2418. size,
  2419. props,
  2420. count,
  2421. activeIndicator
  2422. });
  2423. watch(() => props.initialSwipe, (value) => initialize(+value));
  2424. watch(count, () => initialize(state.active));
  2425. watch(() => props.autoplay, autoplay);
  2426. watch([windowWidth, windowHeight], resize);
  2427. watch(usePageVisibility(), (visible) => {
  2428. if (visible === "visible") {
  2429. autoplay();
  2430. } else {
  2431. stopAutoplay();
  2432. }
  2433. });
  2434. onMounted(initialize);
  2435. onActivated(() => initialize(state.active));
  2436. onPopupReopen(() => initialize(state.active));
  2437. onDeactivated(stopAutoplay);
  2438. onBeforeUnmount(stopAutoplay);
  2439. useEventListener("touchmove", onTouchMove, {
  2440. target: track
  2441. });
  2442. return () => {
  2443. var _a;
  2444. return createVNode("div", {
  2445. "ref": root,
  2446. "class": bem$1h()
  2447. }, [createVNode("div", {
  2448. "ref": track,
  2449. "style": trackStyle.value,
  2450. "class": bem$1h("track", {
  2451. vertical: props.vertical
  2452. }),
  2453. "onTouchstartPassive": onTouchStart,
  2454. "onTouchend": onTouchEnd,
  2455. "onTouchcancel": onTouchEnd
  2456. }, [(_a = slots.default) == null ? void 0 : _a.call(slots)]), renderIndicator()]);
  2457. };
  2458. }
  2459. });
  2460. const Swipe = withInstall(stdin_default$1t);
  2461. const [name$1k, bem$1g] = createNamespace("tabs");
  2462. var stdin_default$1s = defineComponent({
  2463. name: name$1k,
  2464. props: {
  2465. count: makeRequiredProp(Number),
  2466. inited: Boolean,
  2467. animated: Boolean,
  2468. duration: makeRequiredProp(numericProp),
  2469. swipeable: Boolean,
  2470. lazyRender: Boolean,
  2471. currentIndex: makeRequiredProp(Number)
  2472. },
  2473. emits: ["change"],
  2474. setup(props, {
  2475. emit,
  2476. slots
  2477. }) {
  2478. const swipeRef = ref();
  2479. const onChange = (index) => emit("change", index);
  2480. const renderChildren = () => {
  2481. var _a;
  2482. const Content = (_a = slots.default) == null ? void 0 : _a.call(slots);
  2483. if (props.animated || props.swipeable) {
  2484. return createVNode(Swipe, {
  2485. "ref": swipeRef,
  2486. "loop": false,
  2487. "class": bem$1g("track"),
  2488. "duration": +props.duration * 1e3,
  2489. "touchable": props.swipeable,
  2490. "lazyRender": props.lazyRender,
  2491. "showIndicators": false,
  2492. "onChange": onChange
  2493. }, {
  2494. default: () => [Content]
  2495. });
  2496. }
  2497. return Content;
  2498. };
  2499. const swipeToCurrentTab = (index) => {
  2500. const swipe = swipeRef.value;
  2501. if (swipe && swipe.state.active !== index) {
  2502. swipe.swipeTo(index, {
  2503. immediate: !props.inited
  2504. });
  2505. }
  2506. };
  2507. watch(() => props.currentIndex, swipeToCurrentTab);
  2508. onMounted(() => {
  2509. swipeToCurrentTab(props.currentIndex);
  2510. });
  2511. useExpose({
  2512. swipeRef
  2513. });
  2514. return () => createVNode("div", {
  2515. "class": bem$1g("content", {
  2516. animated: props.animated || props.swipeable
  2517. })
  2518. }, [renderChildren()]);
  2519. }
  2520. });
  2521. const [name$1j, bem$1f] = createNamespace("tabs");
  2522. const tabsProps = {
  2523. type: makeStringProp("line"),
  2524. color: String,
  2525. border: Boolean,
  2526. sticky: Boolean,
  2527. shrink: Boolean,
  2528. active: makeNumericProp(0),
  2529. duration: makeNumericProp(0.3),
  2530. animated: Boolean,
  2531. ellipsis: truthProp,
  2532. swipeable: Boolean,
  2533. scrollspy: Boolean,
  2534. offsetTop: makeNumericProp(0),
  2535. background: String,
  2536. lazyRender: truthProp,
  2537. lineWidth: numericProp,
  2538. lineHeight: numericProp,
  2539. beforeChange: Function,
  2540. swipeThreshold: makeNumericProp(5),
  2541. titleActiveColor: String,
  2542. titleInactiveColor: String
  2543. };
  2544. const TABS_KEY = Symbol(name$1j);
  2545. var stdin_default$1r = defineComponent({
  2546. name: name$1j,
  2547. props: tabsProps,
  2548. emits: ["change", "scroll", "rendered", "clickTab", "update:active"],
  2549. setup(props, {
  2550. emit,
  2551. slots
  2552. }) {
  2553. let tabHeight;
  2554. let lockScroll;
  2555. let stickyFixed;
  2556. const root = ref();
  2557. const navRef = ref();
  2558. const wrapRef = ref();
  2559. const contentRef = ref();
  2560. const id = useId();
  2561. const scroller = useScrollParent(root);
  2562. const [titleRefs, setTitleRefs] = useRefs();
  2563. const {
  2564. children,
  2565. linkChildren
  2566. } = useChildren(TABS_KEY);
  2567. const state = reactive({
  2568. inited: false,
  2569. position: "",
  2570. lineStyle: {},
  2571. currentIndex: -1
  2572. });
  2573. const scrollable = computed(() => children.length > props.swipeThreshold || !props.ellipsis || props.shrink);
  2574. const navStyle = computed(() => ({
  2575. borderColor: props.color,
  2576. background: props.background
  2577. }));
  2578. const getTabName = (tab, index) => {
  2579. var _a;
  2580. return (_a = tab.name) != null ? _a : index;
  2581. };
  2582. const currentName = computed(() => {
  2583. const activeTab = children[state.currentIndex];
  2584. if (activeTab) {
  2585. return getTabName(activeTab, state.currentIndex);
  2586. }
  2587. });
  2588. const offsetTopPx = computed(() => unitToPx(props.offsetTop));
  2589. const scrollOffset = computed(() => {
  2590. if (props.sticky) {
  2591. return offsetTopPx.value + tabHeight;
  2592. }
  2593. return 0;
  2594. });
  2595. const scrollIntoView = (immediate) => {
  2596. const nav = navRef.value;
  2597. const titles = titleRefs.value;
  2598. if (!scrollable.value || !nav || !titles || !titles[state.currentIndex]) {
  2599. return;
  2600. }
  2601. const title = titles[state.currentIndex].$el;
  2602. const to = title.offsetLeft - (nav.offsetWidth - title.offsetWidth) / 2;
  2603. scrollLeftTo(nav, to, immediate ? 0 : +props.duration);
  2604. };
  2605. const setLine = () => {
  2606. const shouldAnimate = state.inited;
  2607. nextTick(() => {
  2608. const titles = titleRefs.value;
  2609. if (!titles || !titles[state.currentIndex] || props.type !== "line" || isHidden(root.value)) {
  2610. return;
  2611. }
  2612. const title = titles[state.currentIndex].$el;
  2613. const {
  2614. lineWidth,
  2615. lineHeight
  2616. } = props;
  2617. const left = title.offsetLeft + title.offsetWidth / 2;
  2618. const lineStyle = {
  2619. width: addUnit(lineWidth),
  2620. backgroundColor: props.color,
  2621. transform: `translateX(${left}px) translateX(-50%)`
  2622. };
  2623. if (shouldAnimate) {
  2624. lineStyle.transitionDuration = `${props.duration}s`;
  2625. }
  2626. if (isDef(lineHeight)) {
  2627. const height = addUnit(lineHeight);
  2628. lineStyle.height = height;
  2629. lineStyle.borderRadius = height;
  2630. }
  2631. state.lineStyle = lineStyle;
  2632. });
  2633. };
  2634. const findAvailableTab = (index) => {
  2635. const diff = index < state.currentIndex ? -1 : 1;
  2636. while (index >= 0 && index < children.length) {
  2637. if (!children[index].disabled) {
  2638. return index;
  2639. }
  2640. index += diff;
  2641. }
  2642. };
  2643. const setCurrentIndex = (currentIndex, skipScrollIntoView) => {
  2644. const newIndex = findAvailableTab(currentIndex);
  2645. if (!isDef(newIndex)) {
  2646. return;
  2647. }
  2648. const newTab = children[newIndex];
  2649. const newName = getTabName(newTab, newIndex);
  2650. const shouldEmitChange = state.currentIndex !== null;
  2651. if (state.currentIndex !== newIndex) {
  2652. state.currentIndex = newIndex;
  2653. if (!skipScrollIntoView) {
  2654. scrollIntoView();
  2655. }
  2656. setLine();
  2657. }
  2658. if (newName !== props.active) {
  2659. emit("update:active", newName);
  2660. if (shouldEmitChange) {
  2661. emit("change", newName, newTab.title);
  2662. }
  2663. }
  2664. if (stickyFixed && !props.scrollspy) {
  2665. setRootScrollTop(Math.ceil(getElementTop(root.value) - offsetTopPx.value));
  2666. }
  2667. };
  2668. const setCurrentIndexByName = (name2, skipScrollIntoView) => {
  2669. const matched = children.find((tab, index2) => getTabName(tab, index2) === name2);
  2670. const index = matched ? children.indexOf(matched) : 0;
  2671. setCurrentIndex(index, skipScrollIntoView);
  2672. };
  2673. const scrollToCurrentContent = (immediate = false) => {
  2674. if (props.scrollspy) {
  2675. const target = children[state.currentIndex].$el;
  2676. if (target && scroller.value) {
  2677. const to = getElementTop(target, scroller.value) - scrollOffset.value;
  2678. lockScroll = true;
  2679. scrollTopTo(scroller.value, to, immediate ? 0 : +props.duration, () => {
  2680. lockScroll = false;
  2681. });
  2682. }
  2683. }
  2684. };
  2685. const onClickTab = (item, index, event) => {
  2686. const {
  2687. title,
  2688. disabled
  2689. } = children[index];
  2690. const name2 = getTabName(children[index], index);
  2691. if (!disabled) {
  2692. callInterceptor(props.beforeChange, {
  2693. args: [name2],
  2694. done: () => {
  2695. setCurrentIndex(index);
  2696. scrollToCurrentContent();
  2697. }
  2698. });
  2699. route(item);
  2700. }
  2701. emit("clickTab", {
  2702. name: name2,
  2703. title,
  2704. event,
  2705. disabled
  2706. });
  2707. };
  2708. const onStickyScroll = (params) => {
  2709. stickyFixed = params.isFixed;
  2710. emit("scroll", params);
  2711. };
  2712. const scrollTo = (name2) => {
  2713. nextTick(() => {
  2714. setCurrentIndexByName(name2);
  2715. scrollToCurrentContent(true);
  2716. });
  2717. };
  2718. const getCurrentIndexOnScroll = () => {
  2719. for (let index = 0; index < children.length; index++) {
  2720. const {
  2721. top
  2722. } = useRect(children[index].$el);
  2723. if (top > scrollOffset.value) {
  2724. return index === 0 ? 0 : index - 1;
  2725. }
  2726. }
  2727. return children.length - 1;
  2728. };
  2729. const onScroll = () => {
  2730. if (props.scrollspy && !lockScroll) {
  2731. const index = getCurrentIndexOnScroll();
  2732. setCurrentIndex(index);
  2733. }
  2734. };
  2735. const renderNav = () => children.map((item, index) => createVNode(stdin_default$1u, mergeProps({
  2736. "key": item.id,
  2737. "id": `${id}-${index}`,
  2738. "ref": setTitleRefs(index),
  2739. "type": props.type,
  2740. "color": props.color,
  2741. "style": item.titleStyle,
  2742. "class": item.titleClass,
  2743. "shrink": props.shrink,
  2744. "isActive": index === state.currentIndex,
  2745. "controls": item.id,
  2746. "scrollable": scrollable.value,
  2747. "activeColor": props.titleActiveColor,
  2748. "inactiveColor": props.titleInactiveColor,
  2749. "onClick": (event) => onClickTab(item, index, event)
  2750. }, pick(item, ["dot", "badge", "title", "disabled", "showZeroBadge"])), {
  2751. title: item.$slots.title
  2752. }));
  2753. const renderLine = () => {
  2754. if (props.type === "line" && children.length) {
  2755. return createVNode("div", {
  2756. "class": bem$1f("line"),
  2757. "style": state.lineStyle
  2758. }, null);
  2759. }
  2760. };
  2761. const renderHeader = () => {
  2762. var _a, _b, _c;
  2763. const {
  2764. type,
  2765. border,
  2766. sticky
  2767. } = props;
  2768. const Header = [createVNode("div", {
  2769. "ref": sticky ? void 0 : wrapRef,
  2770. "class": [bem$1f("wrap"), {
  2771. [BORDER_TOP_BOTTOM]: type === "line" && border
  2772. }]
  2773. }, [createVNode("div", {
  2774. "ref": navRef,
  2775. "role": "tablist",
  2776. "class": bem$1f("nav", [type, {
  2777. shrink: props.shrink,
  2778. complete: scrollable.value
  2779. }]),
  2780. "style": navStyle.value,
  2781. "aria-orientation": "horizontal"
  2782. }, [(_a = slots["nav-left"]) == null ? void 0 : _a.call(slots), renderNav(), renderLine(), (_b = slots["nav-right"]) == null ? void 0 : _b.call(slots)])]), (_c = slots["nav-bottom"]) == null ? void 0 : _c.call(slots)];
  2783. if (sticky) {
  2784. return createVNode("div", {
  2785. "ref": wrapRef
  2786. }, [Header]);
  2787. }
  2788. return Header;
  2789. };
  2790. watch([() => props.color, windowWidth], setLine);
  2791. watch(() => props.active, (value) => {
  2792. if (value !== currentName.value) {
  2793. setCurrentIndexByName(value);
  2794. }
  2795. });
  2796. watch(() => children.length, () => {
  2797. if (state.inited) {
  2798. setCurrentIndexByName(props.active);
  2799. setLine();
  2800. nextTick(() => {
  2801. scrollIntoView(true);
  2802. });
  2803. }
  2804. });
  2805. const init = () => {
  2806. setCurrentIndexByName(props.active, true);
  2807. nextTick(() => {
  2808. state.inited = true;
  2809. if (wrapRef.value) {
  2810. tabHeight = useRect(wrapRef.value).height;
  2811. }
  2812. scrollIntoView(true);
  2813. });
  2814. };
  2815. const onRendered = (name2, title) => emit("rendered", name2, title);
  2816. const resize = () => {
  2817. setLine();
  2818. nextTick(() => {
  2819. var _a, _b;
  2820. return (_b = (_a = contentRef.value) == null ? void 0 : _a.swipeRef.value) == null ? void 0 : _b.resize();
  2821. });
  2822. };
  2823. useExpose({
  2824. resize,
  2825. scrollTo
  2826. });
  2827. onActivated(setLine);
  2828. onPopupReopen(setLine);
  2829. onMountedOrActivated(init);
  2830. useEventListener("scroll", onScroll, {
  2831. target: scroller,
  2832. passive: true
  2833. });
  2834. linkChildren({
  2835. id,
  2836. props,
  2837. setLine,
  2838. onRendered,
  2839. currentName,
  2840. scrollIntoView
  2841. });
  2842. return () => createVNode("div", {
  2843. "ref": root,
  2844. "class": bem$1f([props.type])
  2845. }, [props.sticky ? createVNode(Sticky, {
  2846. "container": root.value,
  2847. "offsetTop": offsetTopPx.value,
  2848. "onScroll": onStickyScroll
  2849. }, {
  2850. default: () => [renderHeader()]
  2851. }) : renderHeader(), createVNode(stdin_default$1s, {
  2852. "ref": contentRef,
  2853. "count": children.length,
  2854. "inited": state.inited,
  2855. "animated": props.animated,
  2856. "duration": props.duration,
  2857. "swipeable": props.swipeable,
  2858. "lazyRender": props.lazyRender,
  2859. "currentIndex": state.currentIndex,
  2860. "onChange": setCurrentIndex
  2861. }, {
  2862. default: () => {
  2863. var _a;
  2864. return [(_a = slots.default) == null ? void 0 : _a.call(slots)];
  2865. }
  2866. })]);
  2867. }
  2868. });
  2869. const TAB_STATUS_KEY = Symbol();
  2870. const useTabStatus = () => inject(TAB_STATUS_KEY, null);
  2871. const [name$1i, bem$1e] = createNamespace("swipe-item");
  2872. var stdin_default$1q = defineComponent({
  2873. name: name$1i,
  2874. setup(props, {
  2875. slots
  2876. }) {
  2877. let rendered;
  2878. const state = reactive({
  2879. offset: 0,
  2880. inited: false,
  2881. mounted: false
  2882. });
  2883. const {
  2884. parent,
  2885. index
  2886. } = useParent(SWIPE_KEY);
  2887. if (!parent) {
  2888. if (process.env.NODE_ENV !== "production") {
  2889. console.error("[Vant] <SwipeItem> must be a child component of <Swipe>.");
  2890. }
  2891. return;
  2892. }
  2893. const style = computed(() => {
  2894. const style2 = {};
  2895. const {
  2896. vertical
  2897. } = parent.props;
  2898. if (parent.size.value) {
  2899. style2[vertical ? "height" : "width"] = `${parent.size.value}px`;
  2900. }
  2901. if (state.offset) {
  2902. style2.transform = `translate${vertical ? "Y" : "X"}(${state.offset}px)`;
  2903. }
  2904. return style2;
  2905. });
  2906. const shouldRender = computed(() => {
  2907. const {
  2908. loop,
  2909. lazyRender
  2910. } = parent.props;
  2911. if (!lazyRender || rendered) {
  2912. return true;
  2913. }
  2914. if (!state.mounted) {
  2915. return false;
  2916. }
  2917. const active = parent.activeIndicator.value;
  2918. const maxActive = parent.count.value - 1;
  2919. const prevActive = active === 0 && loop ? maxActive : active - 1;
  2920. const nextActive = active === maxActive && loop ? 0 : active + 1;
  2921. rendered = index.value === active || index.value === prevActive || index.value === nextActive;
  2922. return rendered;
  2923. });
  2924. const setOffset = (offset) => {
  2925. state.offset = offset;
  2926. };
  2927. onMounted(() => {
  2928. nextTick(() => {
  2929. state.mounted = true;
  2930. });
  2931. });
  2932. useExpose({
  2933. setOffset
  2934. });
  2935. return () => {
  2936. var _a;
  2937. return createVNode("div", {
  2938. "class": bem$1e(),
  2939. "style": style.value
  2940. }, [shouldRender.value ? (_a = slots.default) == null ? void 0 : _a.call(slots) : null]);
  2941. };
  2942. }
  2943. });
  2944. const SwipeItem = withInstall(stdin_default$1q);
  2945. const [name$1h, bem$1d] = createNamespace("tab");
  2946. const tabProps = extend({}, routeProps, {
  2947. dot: Boolean,
  2948. name: numericProp,
  2949. badge: numericProp,
  2950. title: String,
  2951. disabled: Boolean,
  2952. titleClass: unknownProp,
  2953. titleStyle: [String, Object],
  2954. showZeroBadge: truthProp
  2955. });
  2956. var stdin_default$1p = defineComponent({
  2957. name: name$1h,
  2958. props: tabProps,
  2959. setup(props, {
  2960. slots
  2961. }) {
  2962. const id = useId();
  2963. const inited = ref(false);
  2964. const {
  2965. parent,
  2966. index
  2967. } = useParent(TABS_KEY);
  2968. if (!parent) {
  2969. if (process.env.NODE_ENV !== "production") {
  2970. console.error("[Vant] <Tab> must be a child component of <Tabs>.");
  2971. }
  2972. return;
  2973. }
  2974. const getName = () => {
  2975. var _a;
  2976. return (_a = props.name) != null ? _a : index.value;
  2977. };
  2978. const init = () => {
  2979. inited.value = true;
  2980. if (parent.props.lazyRender) {
  2981. nextTick(() => {
  2982. parent.onRendered(getName(), props.title);
  2983. });
  2984. }
  2985. };
  2986. const active = computed(() => {
  2987. const isActive = getName() === parent.currentName.value;
  2988. if (isActive && !inited.value) {
  2989. init();
  2990. }
  2991. return isActive;
  2992. });
  2993. const hasInactiveClass = ref(!active.value);
  2994. watch(active, (val) => {
  2995. if (val) {
  2996. hasInactiveClass.value = false;
  2997. } else {
  2998. doubleRaf(() => {
  2999. hasInactiveClass.value = true;
  3000. });
  3001. }
  3002. });
  3003. watch(() => props.title, () => {
  3004. parent.setLine();
  3005. parent.scrollIntoView();
  3006. });
  3007. provide(TAB_STATUS_KEY, active);
  3008. return () => {
  3009. var _a;
  3010. const label = `${parent.id}-${index.value}`;
  3011. const {
  3012. animated,
  3013. swipeable,
  3014. scrollspy,
  3015. lazyRender
  3016. } = parent.props;
  3017. if (!slots.default && !animated) {
  3018. return;
  3019. }
  3020. const show = scrollspy || active.value;
  3021. if (animated || swipeable) {
  3022. return createVNode(SwipeItem, {
  3023. "id": id,
  3024. "role": "tabpanel",
  3025. "class": bem$1d("panel-wrapper", {
  3026. inactive: hasInactiveClass.value
  3027. }),
  3028. "tabindex": active.value ? 0 : -1,
  3029. "aria-hidden": !active.value,
  3030. "aria-labelledby": label
  3031. }, {
  3032. default: () => {
  3033. var _a2;
  3034. return [createVNode("div", {
  3035. "class": bem$1d("panel")
  3036. }, [(_a2 = slots.default) == null ? void 0 : _a2.call(slots)])];
  3037. }
  3038. });
  3039. }
  3040. const shouldRender = inited.value || scrollspy || !lazyRender;
  3041. const Content = shouldRender ? (_a = slots.default) == null ? void 0 : _a.call(slots) : null;
  3042. useExpose({
  3043. id
  3044. });
  3045. return withDirectives(createVNode("div", {
  3046. "id": id,
  3047. "role": "tabpanel",
  3048. "class": bem$1d("panel"),
  3049. "tabindex": show ? 0 : -1,
  3050. "aria-labelledby": label
  3051. }, [Content]), [[vShow, show]]);
  3052. };
  3053. }
  3054. });
  3055. const Tab = withInstall(stdin_default$1p);
  3056. const Tabs = withInstall(stdin_default$1r);
  3057. const [name$1g, bem$1c] = createNamespace("picker-group");
  3058. const PICKER_GROUP_KEY = Symbol(name$1g);
  3059. const pickerGroupProps = extend({
  3060. tabs: makeArrayProp()
  3061. }, pickerToolbarProps);
  3062. var stdin_default$1o = defineComponent({
  3063. name: name$1g,
  3064. props: pickerGroupProps,
  3065. emits: ["confirm", "cancel"],
  3066. setup(props, {
  3067. emit,
  3068. slots
  3069. }) {
  3070. const {
  3071. children,
  3072. linkChildren
  3073. } = useChildren(PICKER_GROUP_KEY);
  3074. linkChildren();
  3075. const onConfirm = () => {
  3076. emit("confirm", children.map((item) => item.confirm()));
  3077. };
  3078. const onCancel = () => emit("cancel");
  3079. return () => {
  3080. var _a;
  3081. const childNodes = (_a = slots.default) == null ? void 0 : _a.call(slots);
  3082. return createVNode("div", {
  3083. "class": bem$1c()
  3084. }, [createVNode(stdin_default$1w, mergeProps(props, {
  3085. "onConfirm": onConfirm,
  3086. "onCancel": onCancel
  3087. }), null), createVNode(Tabs, {
  3088. "shrink": true,
  3089. "class": bem$1c("tabs"),
  3090. "animated": true
  3091. }, {
  3092. default: () => [props.tabs.map((title, index) => createVNode(Tab, {
  3093. "title": title,
  3094. "titleClass": bem$1c("tab-title")
  3095. }, {
  3096. default: () => [childNodes == null ? void 0 : childNodes[index]]
  3097. }))]
  3098. })]);
  3099. };
  3100. }
  3101. });
  3102. const pickerSharedProps = extend({
  3103. loading: Boolean,
  3104. readonly: Boolean,
  3105. allowHtml: Boolean,
  3106. optionHeight: makeNumericProp(44),
  3107. showToolbar: truthProp,
  3108. swipeDuration: makeNumericProp(1e3),
  3109. visibleOptionNum: makeNumericProp(6)
  3110. }, pickerToolbarProps);
  3111. const pickerProps = extend({}, pickerSharedProps, {
  3112. columns: makeArrayProp(),
  3113. modelValue: makeArrayProp(),
  3114. toolbarPosition: makeStringProp("top"),
  3115. columnsFieldNames: Object
  3116. });
  3117. var stdin_default$1n = defineComponent({
  3118. name: name$1q,
  3119. props: pickerProps,
  3120. emits: ["confirm", "cancel", "change", "clickOption", "update:modelValue"],
  3121. setup(props, {
  3122. emit,
  3123. slots
  3124. }) {
  3125. const columnsRef = ref();
  3126. const selectedValues = ref(props.modelValue.slice(0));
  3127. const {
  3128. parent
  3129. } = useParent(PICKER_GROUP_KEY);
  3130. const {
  3131. children,
  3132. linkChildren
  3133. } = useChildren(PICKER_KEY);
  3134. linkChildren();
  3135. const fields = computed(() => assignDefaultFields(props.columnsFieldNames));
  3136. const optionHeight = computed(() => unitToPx(props.optionHeight));
  3137. const columnsType = computed(() => getColumnsType(props.columns, fields.value));
  3138. const currentColumns = computed(() => {
  3139. const {
  3140. columns
  3141. } = props;
  3142. switch (columnsType.value) {
  3143. case "multiple":
  3144. return columns;
  3145. case "cascade":
  3146. return formatCascadeColumns(columns, fields.value, selectedValues);
  3147. default:
  3148. return [columns];
  3149. }
  3150. });
  3151. const hasOptions = computed(() => currentColumns.value.some((options) => options.length));
  3152. const selectedOptions = computed(() => currentColumns.value.map((options, index) => findOptionByValue(options, selectedValues.value[index], fields.value)));
  3153. const selectedIndexes = computed(() => currentColumns.value.map((options, index) => options.findIndex((option) => option[fields.value.value] === selectedValues.value[index])));
  3154. const setValue = (index, value) => {
  3155. if (selectedValues.value[index] !== value) {
  3156. const newValues = selectedValues.value.slice(0);
  3157. newValues[index] = value;
  3158. selectedValues.value = newValues;
  3159. }
  3160. };
  3161. const getEventParams = () => ({
  3162. selectedValues: selectedValues.value.slice(0),
  3163. selectedOptions: selectedOptions.value,
  3164. selectedIndexes: selectedIndexes.value
  3165. });
  3166. const onChange = (value, columnIndex) => {
  3167. setValue(columnIndex, value);
  3168. if (columnsType.value === "cascade") {
  3169. selectedValues.value.forEach((value2, index) => {
  3170. const options = currentColumns.value[index];
  3171. if (!isOptionExist(options, value2, fields.value)) {
  3172. setValue(index, options.length ? options[0][fields.value.value] : void 0);
  3173. }
  3174. });
  3175. }
  3176. emit("change", extend({
  3177. columnIndex
  3178. }, getEventParams()));
  3179. };
  3180. const onClickOption = (currentOption, columnIndex) => emit("clickOption", extend({
  3181. columnIndex,
  3182. currentOption
  3183. }, getEventParams()));
  3184. const confirm = () => {
  3185. children.forEach((child) => child.stopMomentum());
  3186. const params = getEventParams();
  3187. nextTick(() => {
  3188. emit("confirm", params);
  3189. });
  3190. return params;
  3191. };
  3192. const cancel = () => emit("cancel", getEventParams());
  3193. const renderColumnItems = () => currentColumns.value.map((options, columnIndex) => createVNode(stdin_default$1x, {
  3194. "value": selectedValues.value[columnIndex],
  3195. "fields": fields.value,
  3196. "options": options,
  3197. "readonly": props.readonly,
  3198. "allowHtml": props.allowHtml,
  3199. "optionHeight": optionHeight.value,
  3200. "swipeDuration": props.swipeDuration,
  3201. "visibleOptionNum": props.visibleOptionNum,
  3202. "onChange": (value) => onChange(value, columnIndex),
  3203. "onClickOption": (option) => onClickOption(option, columnIndex)
  3204. }, {
  3205. option: slots.option
  3206. }));
  3207. const renderMask = (wrapHeight) => {
  3208. if (hasOptions.value) {
  3209. const frameStyle = {
  3210. height: `${optionHeight.value}px`
  3211. };
  3212. const maskStyle = {
  3213. backgroundSize: `100% ${(wrapHeight - optionHeight.value) / 2}px`
  3214. };
  3215. return [createVNode("div", {
  3216. "class": bem$1l("mask"),
  3217. "style": maskStyle
  3218. }, null), createVNode("div", {
  3219. "class": [BORDER_UNSET_TOP_BOTTOM, bem$1l("frame")],
  3220. "style": frameStyle
  3221. }, null)];
  3222. }
  3223. };
  3224. const renderColumns = () => {
  3225. const wrapHeight = optionHeight.value * +props.visibleOptionNum;
  3226. const columnsStyle = {
  3227. height: `${wrapHeight}px`
  3228. };
  3229. return createVNode("div", {
  3230. "ref": columnsRef,
  3231. "class": bem$1l("columns"),
  3232. "style": columnsStyle
  3233. }, [renderColumnItems(), renderMask(wrapHeight)]);
  3234. };
  3235. const renderToolbar = () => {
  3236. if (props.showToolbar && !parent) {
  3237. return createVNode(stdin_default$1w, mergeProps(pick(props, pickerToolbarPropKeys), {
  3238. "onConfirm": confirm,
  3239. "onCancel": cancel
  3240. }), pick(slots, pickerToolbarSlots));
  3241. }
  3242. };
  3243. watch(currentColumns, (columns) => {
  3244. columns.forEach((options, index) => {
  3245. if (options.length && !isOptionExist(options, selectedValues.value[index], fields.value)) {
  3246. setValue(index, getFirstEnabledOption(options)[fields.value.value]);
  3247. }
  3248. });
  3249. }, {
  3250. immediate: true
  3251. });
  3252. let lastEmittedModelValue;
  3253. watch(() => props.modelValue, (newValues) => {
  3254. if (!isSameValue(newValues, selectedValues.value) && !isSameValue(newValues, lastEmittedModelValue)) {
  3255. selectedValues.value = newValues.slice(0);
  3256. }
  3257. }, {
  3258. deep: true
  3259. });
  3260. watch(selectedValues, (newValues) => {
  3261. if (!isSameValue(newValues, props.modelValue)) {
  3262. lastEmittedModelValue = newValues.slice(0);
  3263. emit("update:modelValue", lastEmittedModelValue);
  3264. }
  3265. }, {
  3266. immediate: true
  3267. });
  3268. useEventListener("touchmove", preventDefault, {
  3269. target: columnsRef
  3270. });
  3271. const getSelectedOptions = () => selectedOptions.value;
  3272. useExpose({
  3273. confirm,
  3274. getSelectedOptions
  3275. });
  3276. return () => {
  3277. var _a, _b;
  3278. return createVNode("div", {
  3279. "class": bem$1l()
  3280. }, [props.toolbarPosition === "top" ? renderToolbar() : null, props.loading ? createVNode(Loading, {
  3281. "class": bem$1l("loading")
  3282. }, 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]);
  3283. };
  3284. }
  3285. });
  3286. const AREA_EMPTY_CODE = "000000";
  3287. const INHERIT_SLOTS = [
  3288. "title",
  3289. "cancel",
  3290. "confirm",
  3291. "toolbar",
  3292. "columns-top",
  3293. "columns-bottom"
  3294. ];
  3295. const INHERIT_PROPS = [
  3296. "title",
  3297. "loading",
  3298. "readonly",
  3299. "optionHeight",
  3300. "swipeDuration",
  3301. "visibleOptionNum",
  3302. "cancelButtonText",
  3303. "confirmButtonText"
  3304. ];
  3305. const makeOption = (text = "", value = AREA_EMPTY_CODE, children = void 0) => ({
  3306. text,
  3307. value,
  3308. children
  3309. });
  3310. function formatDataForCascade({
  3311. areaList,
  3312. columnsNum,
  3313. columnsPlaceholder: placeholder
  3314. }) {
  3315. const {
  3316. city_list: city = {},
  3317. county_list: county = {},
  3318. province_list: province = {}
  3319. } = areaList;
  3320. const showCity = columnsNum > 1;
  3321. const showCounty = columnsNum > 2;
  3322. const getProvinceChildren = () => {
  3323. if (showCity) {
  3324. return placeholder.length ? [
  3325. makeOption(
  3326. placeholder[0],
  3327. AREA_EMPTY_CODE,
  3328. showCounty ? [] : void 0
  3329. )
  3330. ] : [];
  3331. }
  3332. };
  3333. const provinceMap = /* @__PURE__ */ new Map();
  3334. Object.keys(province).forEach((code) => {
  3335. provinceMap.set(
  3336. code.slice(0, 2),
  3337. makeOption(province[code], code, getProvinceChildren())
  3338. );
  3339. });
  3340. const cityMap = /* @__PURE__ */ new Map();
  3341. if (showCity) {
  3342. const getCityChildren = () => {
  3343. if (showCounty) {
  3344. return placeholder.length ? [makeOption(placeholder[1])] : [];
  3345. }
  3346. };
  3347. Object.keys(city).forEach((code) => {
  3348. const option = makeOption(city[code], code, getCityChildren());
  3349. cityMap.set(code.slice(0, 4), option);
  3350. const province2 = provinceMap.get(code.slice(0, 2));
  3351. if (province2) {
  3352. province2.children.push(option);
  3353. }
  3354. });
  3355. }
  3356. if (showCounty) {
  3357. Object.keys(county).forEach((code) => {
  3358. const city2 = cityMap.get(code.slice(0, 4));
  3359. if (city2) {
  3360. city2.children.push(makeOption(county[code], code));
  3361. }
  3362. });
  3363. }
  3364. const options = Array.from(provinceMap.values());
  3365. if (placeholder.length) {
  3366. const county2 = showCounty ? [makeOption(placeholder[2])] : void 0;
  3367. const city2 = showCity ? [makeOption(placeholder[1], AREA_EMPTY_CODE, county2)] : void 0;
  3368. options.unshift(makeOption(placeholder[0], AREA_EMPTY_CODE, city2));
  3369. }
  3370. return options;
  3371. }
  3372. const Picker = withInstall(stdin_default$1n);
  3373. const [name$1f, bem$1b] = createNamespace("area");
  3374. const areaProps = extend({}, pickerSharedProps, {
  3375. modelValue: String,
  3376. columnsNum: makeNumericProp(3),
  3377. columnsPlaceholder: makeArrayProp(),
  3378. areaList: {
  3379. type: Object,
  3380. default: () => ({})
  3381. }
  3382. });
  3383. var stdin_default$1m = defineComponent({
  3384. name: name$1f,
  3385. props: areaProps,
  3386. emits: ["change", "confirm", "cancel", "update:modelValue"],
  3387. setup(props, {
  3388. emit,
  3389. slots
  3390. }) {
  3391. const codes = ref([]);
  3392. const picker = ref();
  3393. const columns = computed(() => formatDataForCascade(props));
  3394. const onChange = (...args) => emit("change", ...args);
  3395. const onCancel = (...args) => emit("cancel", ...args);
  3396. const onConfirm = (...args) => emit("confirm", ...args);
  3397. watch(codes, (newCodes) => {
  3398. const lastCode = newCodes.length ? newCodes[newCodes.length - 1] : "";
  3399. if (lastCode && lastCode !== props.modelValue) {
  3400. emit("update:modelValue", lastCode);
  3401. }
  3402. }, {
  3403. deep: true
  3404. });
  3405. watch(() => props.modelValue, (newCode) => {
  3406. if (newCode) {
  3407. const lastCode = codes.value.length ? codes.value[codes.value.length - 1] : "";
  3408. if (newCode !== lastCode) {
  3409. codes.value = [`${newCode.slice(0, 2)}0000`, `${newCode.slice(0, 4)}00`, newCode].slice(0, +props.columnsNum);
  3410. }
  3411. } else {
  3412. codes.value = [];
  3413. }
  3414. }, {
  3415. immediate: true
  3416. });
  3417. useExpose({
  3418. confirm: () => {
  3419. var _a;
  3420. return (_a = picker.value) == null ? void 0 : _a.confirm();
  3421. },
  3422. getSelectedOptions: () => {
  3423. var _a;
  3424. return ((_a = picker.value) == null ? void 0 : _a.getSelectedOptions()) || [];
  3425. }
  3426. });
  3427. return () => createVNode(Picker, mergeProps({
  3428. "ref": picker,
  3429. "modelValue": codes.value,
  3430. "onUpdate:modelValue": ($event) => codes.value = $event,
  3431. "class": bem$1b(),
  3432. "columns": columns.value,
  3433. "onChange": onChange,
  3434. "onCancel": onCancel,
  3435. "onConfirm": onConfirm
  3436. }, pick(props, INHERIT_PROPS)), pick(slots, INHERIT_SLOTS));
  3437. }
  3438. });
  3439. const Area = withInstall(stdin_default$1m);
  3440. const [name$1e, bem$1a] = createNamespace("cell");
  3441. const cellSharedProps = {
  3442. tag: makeStringProp("div"),
  3443. icon: String,
  3444. size: String,
  3445. title: numericProp,
  3446. value: numericProp,
  3447. label: numericProp,
  3448. center: Boolean,
  3449. isLink: Boolean,
  3450. border: truthProp,
  3451. required: Boolean,
  3452. iconPrefix: String,
  3453. valueClass: unknownProp,
  3454. labelClass: unknownProp,
  3455. titleClass: unknownProp,
  3456. titleStyle: null,
  3457. arrowDirection: String,
  3458. clickable: {
  3459. type: Boolean,
  3460. default: null
  3461. }
  3462. };
  3463. const cellProps = extend({}, cellSharedProps, routeProps);
  3464. var stdin_default$1l = defineComponent({
  3465. name: name$1e,
  3466. props: cellProps,
  3467. setup(props, {
  3468. slots
  3469. }) {
  3470. const route2 = useRoute();
  3471. const renderLabel = () => {
  3472. const showLabel = slots.label || isDef(props.label);
  3473. if (showLabel) {
  3474. return createVNode("div", {
  3475. "class": [bem$1a("label"), props.labelClass]
  3476. }, [slots.label ? slots.label() : props.label]);
  3477. }
  3478. };
  3479. const renderTitle = () => {
  3480. var _a;
  3481. if (slots.title || isDef(props.title)) {
  3482. const titleSlot = (_a = slots.title) == null ? void 0 : _a.call(slots);
  3483. if (Array.isArray(titleSlot) && titleSlot.length === 0) {
  3484. return;
  3485. }
  3486. return createVNode("div", {
  3487. "class": [bem$1a("title"), props.titleClass],
  3488. "style": props.titleStyle
  3489. }, [titleSlot || createVNode("span", null, [props.title]), renderLabel()]);
  3490. }
  3491. };
  3492. const renderValue = () => {
  3493. const slot = slots.value || slots.default;
  3494. const hasValue = slot || isDef(props.value);
  3495. if (hasValue) {
  3496. return createVNode("div", {
  3497. "class": [bem$1a("value"), props.valueClass]
  3498. }, [slot ? slot() : createVNode("span", null, [props.value])]);
  3499. }
  3500. };
  3501. const renderLeftIcon = () => {
  3502. if (slots.icon) {
  3503. return slots.icon();
  3504. }
  3505. if (props.icon) {
  3506. return createVNode(Icon, {
  3507. "name": props.icon,
  3508. "class": bem$1a("left-icon"),
  3509. "classPrefix": props.iconPrefix
  3510. }, null);
  3511. }
  3512. };
  3513. const renderRightIcon = () => {
  3514. if (slots["right-icon"]) {
  3515. return slots["right-icon"]();
  3516. }
  3517. if (props.isLink) {
  3518. const name2 = props.arrowDirection && props.arrowDirection !== "right" ? `arrow-${props.arrowDirection}` : "arrow";
  3519. return createVNode(Icon, {
  3520. "name": name2,
  3521. "class": bem$1a("right-icon")
  3522. }, null);
  3523. }
  3524. };
  3525. return () => {
  3526. var _a;
  3527. const {
  3528. tag,
  3529. size,
  3530. center,
  3531. border,
  3532. isLink,
  3533. required
  3534. } = props;
  3535. const clickable = (_a = props.clickable) != null ? _a : isLink;
  3536. const classes = {
  3537. center,
  3538. required,
  3539. clickable,
  3540. borderless: !border
  3541. };
  3542. if (size) {
  3543. classes[size] = !!size;
  3544. }
  3545. return createVNode(tag, {
  3546. "class": bem$1a(classes),
  3547. "role": clickable ? "button" : void 0,
  3548. "tabindex": clickable ? 0 : void 0,
  3549. "onClick": route2
  3550. }, {
  3551. default: () => {
  3552. var _a2;
  3553. return [renderLeftIcon(), renderTitle(), renderValue(), renderRightIcon(), (_a2 = slots.extra) == null ? void 0 : _a2.call(slots)];
  3554. }
  3555. });
  3556. };
  3557. }
  3558. });
  3559. const Cell = withInstall(stdin_default$1l);
  3560. const [name$1d, bem$19] = createNamespace("form");
  3561. const formProps = {
  3562. colon: Boolean,
  3563. disabled: Boolean,
  3564. readonly: Boolean,
  3565. showError: Boolean,
  3566. labelWidth: numericProp,
  3567. labelAlign: String,
  3568. inputAlign: String,
  3569. scrollToError: Boolean,
  3570. validateFirst: Boolean,
  3571. submitOnEnter: truthProp,
  3572. showErrorMessage: truthProp,
  3573. errorMessageAlign: String,
  3574. validateTrigger: {
  3575. type: [String, Array],
  3576. default: "onBlur"
  3577. }
  3578. };
  3579. var stdin_default$1k = defineComponent({
  3580. name: name$1d,
  3581. props: formProps,
  3582. emits: ["submit", "failed"],
  3583. setup(props, {
  3584. emit,
  3585. slots
  3586. }) {
  3587. const {
  3588. children,
  3589. linkChildren
  3590. } = useChildren(FORM_KEY);
  3591. const getFieldsByNames = (names) => {
  3592. if (names) {
  3593. return children.filter((field) => names.includes(field.name));
  3594. }
  3595. return children;
  3596. };
  3597. const validateSeq = (names) => new Promise((resolve, reject) => {
  3598. const errors = [];
  3599. const fields = getFieldsByNames(names);
  3600. fields.reduce((promise, field) => promise.then(() => {
  3601. if (!errors.length) {
  3602. return field.validate().then((error) => {
  3603. if (error) {
  3604. errors.push(error);
  3605. }
  3606. });
  3607. }
  3608. }), Promise.resolve()).then(() => {
  3609. if (errors.length) {
  3610. reject(errors);
  3611. } else {
  3612. resolve();
  3613. }
  3614. });
  3615. });
  3616. const validateAll = (names) => new Promise((resolve, reject) => {
  3617. const fields = getFieldsByNames(names);
  3618. Promise.all(fields.map((item) => item.validate())).then((errors) => {
  3619. errors = errors.filter(Boolean);
  3620. if (errors.length) {
  3621. reject(errors);
  3622. } else {
  3623. resolve();
  3624. }
  3625. });
  3626. });
  3627. const validateField = (name2) => {
  3628. const matched = children.find((item) => item.name === name2);
  3629. if (matched) {
  3630. return new Promise((resolve, reject) => {
  3631. matched.validate().then((error) => {
  3632. if (error) {
  3633. reject(error);
  3634. } else {
  3635. resolve();
  3636. }
  3637. });
  3638. });
  3639. }
  3640. return Promise.reject();
  3641. };
  3642. const validate = (name2) => {
  3643. if (typeof name2 === "string") {
  3644. return validateField(name2);
  3645. }
  3646. return props.validateFirst ? validateSeq(name2) : validateAll(name2);
  3647. };
  3648. const resetValidation = (name2) => {
  3649. if (typeof name2 === "string") {
  3650. name2 = [name2];
  3651. }
  3652. const fields = getFieldsByNames(name2);
  3653. fields.forEach((item) => {
  3654. item.resetValidation();
  3655. });
  3656. };
  3657. const getValidationStatus = () => children.reduce((form, field) => {
  3658. form[field.name] = field.getValidationStatus();
  3659. return form;
  3660. }, {});
  3661. const scrollToField = (name2, options) => {
  3662. children.some((item) => {
  3663. if (item.name === name2) {
  3664. item.$el.scrollIntoView(options);
  3665. return true;
  3666. }
  3667. return false;
  3668. });
  3669. };
  3670. const getValues = () => children.reduce((form, field) => {
  3671. form[field.name] = field.formValue.value;
  3672. return form;
  3673. }, {});
  3674. const submit = () => {
  3675. const values = getValues();
  3676. validate().then(() => emit("submit", values)).catch((errors) => {
  3677. emit("failed", {
  3678. values,
  3679. errors
  3680. });
  3681. if (props.scrollToError && errors[0].name) {
  3682. scrollToField(errors[0].name);
  3683. }
  3684. });
  3685. };
  3686. const onSubmit = (event) => {
  3687. preventDefault(event);
  3688. submit();
  3689. };
  3690. linkChildren({
  3691. props
  3692. });
  3693. useExpose({
  3694. submit,
  3695. validate,
  3696. getValues,
  3697. scrollToField,
  3698. resetValidation,
  3699. getValidationStatus
  3700. });
  3701. return () => {
  3702. var _a;
  3703. return createVNode("form", {
  3704. "class": bem$19(),
  3705. "onSubmit": onSubmit
  3706. }, [(_a = slots.default) == null ? void 0 : _a.call(slots)]);
  3707. };
  3708. }
  3709. });
  3710. const Form = withInstall(stdin_default$1k);
  3711. function isEmptyValue(value) {
  3712. if (Array.isArray(value)) {
  3713. return !value.length;
  3714. }
  3715. if (value === 0) {
  3716. return false;
  3717. }
  3718. return !value;
  3719. }
  3720. function runSyncRule(value, rule) {
  3721. if (isEmptyValue(value)) {
  3722. if (rule.required) {
  3723. return false;
  3724. }
  3725. if (rule.validateEmpty === false) {
  3726. return true;
  3727. }
  3728. }
  3729. if (rule.pattern && !rule.pattern.test(String(value))) {
  3730. return false;
  3731. }
  3732. return true;
  3733. }
  3734. function runRuleValidator(value, rule) {
  3735. return new Promise((resolve) => {
  3736. const returnVal = rule.validator(value, rule);
  3737. if (isPromise(returnVal)) {
  3738. returnVal.then(resolve);
  3739. return;
  3740. }
  3741. resolve(returnVal);
  3742. });
  3743. }
  3744. function getRuleMessage(value, rule) {
  3745. const { message } = rule;
  3746. if (isFunction(message)) {
  3747. return message(value, rule);
  3748. }
  3749. return message || "";
  3750. }
  3751. function startComposing({ target }) {
  3752. target.composing = true;
  3753. }
  3754. function endComposing({ target }) {
  3755. if (target.composing) {
  3756. target.composing = false;
  3757. target.dispatchEvent(new Event("input"));
  3758. }
  3759. }
  3760. function resizeTextarea(input, autosize) {
  3761. const scrollTop = getRootScrollTop();
  3762. input.style.height = "auto";
  3763. let height = input.scrollHeight;
  3764. if (isObject(autosize)) {
  3765. const { maxHeight, minHeight } = autosize;
  3766. if (maxHeight !== void 0) {
  3767. height = Math.min(height, maxHeight);
  3768. }
  3769. if (minHeight !== void 0) {
  3770. height = Math.max(height, minHeight);
  3771. }
  3772. }
  3773. if (height) {
  3774. input.style.height = `${height}px`;
  3775. setRootScrollTop(scrollTop);
  3776. }
  3777. }
  3778. function mapInputType(type) {
  3779. if (type === "number") {
  3780. return {
  3781. type: "text",
  3782. inputmode: "decimal"
  3783. };
  3784. }
  3785. if (type === "digit") {
  3786. return {
  3787. type: "tel",
  3788. inputmode: "numeric"
  3789. };
  3790. }
  3791. return { type };
  3792. }
  3793. function getStringLength(str) {
  3794. return [...str].length;
  3795. }
  3796. function cutString(str, maxlength) {
  3797. return [...str].slice(0, maxlength).join("");
  3798. }
  3799. const [name$1c, bem$18] = createNamespace("field");
  3800. const fieldSharedProps = {
  3801. id: String,
  3802. name: String,
  3803. leftIcon: String,
  3804. rightIcon: String,
  3805. autofocus: Boolean,
  3806. clearable: Boolean,
  3807. maxlength: numericProp,
  3808. formatter: Function,
  3809. clearIcon: makeStringProp("clear"),
  3810. modelValue: makeNumericProp(""),
  3811. inputAlign: String,
  3812. placeholder: String,
  3813. autocomplete: String,
  3814. errorMessage: String,
  3815. enterkeyhint: String,
  3816. clearTrigger: makeStringProp("focus"),
  3817. formatTrigger: makeStringProp("onChange"),
  3818. error: {
  3819. type: Boolean,
  3820. default: null
  3821. },
  3822. disabled: {
  3823. type: Boolean,
  3824. default: null
  3825. },
  3826. readonly: {
  3827. type: Boolean,
  3828. default: null
  3829. }
  3830. };
  3831. const fieldProps = extend({}, cellSharedProps, fieldSharedProps, {
  3832. rows: numericProp,
  3833. type: makeStringProp("text"),
  3834. rules: Array,
  3835. autosize: [Boolean, Object],
  3836. labelWidth: numericProp,
  3837. labelClass: unknownProp,
  3838. labelAlign: String,
  3839. showWordLimit: Boolean,
  3840. errorMessageAlign: String,
  3841. colon: {
  3842. type: Boolean,
  3843. default: null
  3844. }
  3845. });
  3846. var stdin_default$1j = defineComponent({
  3847. name: name$1c,
  3848. props: fieldProps,
  3849. emits: ["blur", "focus", "clear", "keypress", "clickInput", "endValidate", "startValidate", "clickLeftIcon", "clickRightIcon", "update:modelValue"],
  3850. setup(props, {
  3851. emit,
  3852. slots
  3853. }) {
  3854. const id = useId();
  3855. const state = reactive({
  3856. status: "unvalidated",
  3857. focused: false,
  3858. validateMessage: ""
  3859. });
  3860. const inputRef = ref();
  3861. const clearIconRef = ref();
  3862. const customValue = ref();
  3863. const {
  3864. parent: form
  3865. } = useParent(FORM_KEY);
  3866. const getModelValue = () => {
  3867. var _a;
  3868. return String((_a = props.modelValue) != null ? _a : "");
  3869. };
  3870. const getProp = (key) => {
  3871. if (isDef(props[key])) {
  3872. return props[key];
  3873. }
  3874. if (form && isDef(form.props[key])) {
  3875. return form.props[key];
  3876. }
  3877. };
  3878. const showClear = computed(() => {
  3879. const readonly = getProp("readonly");
  3880. if (props.clearable && !readonly) {
  3881. const hasValue = getModelValue() !== "";
  3882. const trigger = props.clearTrigger === "always" || props.clearTrigger === "focus" && state.focused;
  3883. return hasValue && trigger;
  3884. }
  3885. return false;
  3886. });
  3887. const formValue = computed(() => {
  3888. if (customValue.value && slots.input) {
  3889. return customValue.value();
  3890. }
  3891. return props.modelValue;
  3892. });
  3893. const runRules = (rules) => rules.reduce((promise, rule) => promise.then(() => {
  3894. if (state.status === "failed") {
  3895. return;
  3896. }
  3897. let {
  3898. value
  3899. } = formValue;
  3900. if (rule.formatter) {
  3901. value = rule.formatter(value, rule);
  3902. }
  3903. if (!runSyncRule(value, rule)) {
  3904. state.status = "failed";
  3905. state.validateMessage = getRuleMessage(value, rule);
  3906. return;
  3907. }
  3908. if (rule.validator) {
  3909. if (isEmptyValue(value) && rule.validateEmpty === false) {
  3910. return;
  3911. }
  3912. return runRuleValidator(value, rule).then((result) => {
  3913. if (result && typeof result === "string") {
  3914. state.status = "failed";
  3915. state.validateMessage = result;
  3916. } else if (result === false) {
  3917. state.status = "failed";
  3918. state.validateMessage = getRuleMessage(value, rule);
  3919. }
  3920. });
  3921. }
  3922. }), Promise.resolve());
  3923. const resetValidation = () => {
  3924. state.status = "unvalidated";
  3925. state.validateMessage = "";
  3926. };
  3927. const endValidate = () => emit("endValidate", {
  3928. status: state.status,
  3929. message: state.validateMessage
  3930. });
  3931. const validate = (rules = props.rules) => new Promise((resolve) => {
  3932. resetValidation();
  3933. if (rules) {
  3934. emit("startValidate");
  3935. runRules(rules).then(() => {
  3936. if (state.status === "failed") {
  3937. resolve({
  3938. name: props.name,
  3939. message: state.validateMessage
  3940. });
  3941. endValidate();
  3942. } else {
  3943. state.status = "passed";
  3944. resolve();
  3945. endValidate();
  3946. }
  3947. });
  3948. } else {
  3949. resolve();
  3950. }
  3951. });
  3952. const validateWithTrigger = (trigger) => {
  3953. if (form && props.rules) {
  3954. const {
  3955. validateTrigger
  3956. } = form.props;
  3957. const defaultTrigger = toArray(validateTrigger).includes(trigger);
  3958. const rules = props.rules.filter((rule) => {
  3959. if (rule.trigger) {
  3960. return toArray(rule.trigger).includes(trigger);
  3961. }
  3962. return defaultTrigger;
  3963. });
  3964. if (rules.length) {
  3965. validate(rules);
  3966. }
  3967. }
  3968. };
  3969. const limitValueLength = (value) => {
  3970. var _a;
  3971. const {
  3972. maxlength
  3973. } = props;
  3974. if (isDef(maxlength) && getStringLength(value) > maxlength) {
  3975. const modelValue = getModelValue();
  3976. if (modelValue && getStringLength(modelValue) === +maxlength) {
  3977. return modelValue;
  3978. }
  3979. const selectionEnd = (_a = inputRef.value) == null ? void 0 : _a.selectionEnd;
  3980. if (state.focused && selectionEnd) {
  3981. const valueArr = [...value];
  3982. const exceededLength = valueArr.length - +maxlength;
  3983. valueArr.splice(selectionEnd - exceededLength, exceededLength);
  3984. return valueArr.join("");
  3985. }
  3986. return cutString(value, +maxlength);
  3987. }
  3988. return value;
  3989. };
  3990. const updateValue = (value, trigger = "onChange") => {
  3991. const originalValue = value;
  3992. value = limitValueLength(value);
  3993. const limitDiffLen = getStringLength(originalValue) - getStringLength(value);
  3994. if (props.type === "number" || props.type === "digit") {
  3995. const isNumber = props.type === "number";
  3996. value = formatNumber(value, isNumber, isNumber);
  3997. }
  3998. let formatterDiffLen = 0;
  3999. if (props.formatter && trigger === props.formatTrigger) {
  4000. const {
  4001. formatter,
  4002. maxlength
  4003. } = props;
  4004. value = formatter(value);
  4005. if (isDef(maxlength) && getStringLength(value) > maxlength) {
  4006. value = cutString(value, +maxlength);
  4007. }
  4008. if (inputRef.value && state.focused) {
  4009. const {
  4010. selectionEnd
  4011. } = inputRef.value;
  4012. const bcoVal = cutString(originalValue, selectionEnd);
  4013. formatterDiffLen = getStringLength(formatter(bcoVal)) - getStringLength(bcoVal);
  4014. }
  4015. }
  4016. if (inputRef.value && inputRef.value.value !== value) {
  4017. if (state.focused) {
  4018. let {
  4019. selectionStart,
  4020. selectionEnd
  4021. } = inputRef.value;
  4022. inputRef.value.value = value;
  4023. if (isDef(selectionStart) && isDef(selectionEnd)) {
  4024. const valueLen = getStringLength(value);
  4025. if (limitDiffLen) {
  4026. selectionStart -= limitDiffLen;
  4027. selectionEnd -= limitDiffLen;
  4028. } else if (formatterDiffLen) {
  4029. selectionStart += formatterDiffLen;
  4030. selectionEnd += formatterDiffLen;
  4031. }
  4032. inputRef.value.setSelectionRange(Math.min(selectionStart, valueLen), Math.min(selectionEnd, valueLen));
  4033. }
  4034. } else {
  4035. inputRef.value.value = value;
  4036. }
  4037. }
  4038. if (value !== props.modelValue) {
  4039. emit("update:modelValue", value);
  4040. }
  4041. };
  4042. const onInput = (event) => {
  4043. if (!event.target.composing) {
  4044. updateValue(event.target.value);
  4045. }
  4046. };
  4047. const blur = () => {
  4048. var _a;
  4049. return (_a = inputRef.value) == null ? void 0 : _a.blur();
  4050. };
  4051. const focus = () => {
  4052. var _a;
  4053. return (_a = inputRef.value) == null ? void 0 : _a.focus();
  4054. };
  4055. const adjustTextareaSize = () => {
  4056. const input = inputRef.value;
  4057. if (props.type === "textarea" && props.autosize && input) {
  4058. resizeTextarea(input, props.autosize);
  4059. }
  4060. };
  4061. const onFocus = (event) => {
  4062. state.focused = true;
  4063. emit("focus", event);
  4064. nextTick(adjustTextareaSize);
  4065. if (getProp("readonly")) {
  4066. blur();
  4067. }
  4068. };
  4069. const onBlur = (event) => {
  4070. if (getProp("readonly")) {
  4071. return;
  4072. }
  4073. state.focused = false;
  4074. updateValue(getModelValue(), "onBlur");
  4075. emit("blur", event);
  4076. validateWithTrigger("onBlur");
  4077. nextTick(adjustTextareaSize);
  4078. resetScroll();
  4079. };
  4080. const onClickInput = (event) => emit("clickInput", event);
  4081. const onClickLeftIcon = (event) => emit("clickLeftIcon", event);
  4082. const onClickRightIcon = (event) => emit("clickRightIcon", event);
  4083. const onClear = (event) => {
  4084. preventDefault(event);
  4085. emit("update:modelValue", "");
  4086. emit("clear", event);
  4087. };
  4088. const showError = computed(() => {
  4089. if (typeof props.error === "boolean") {
  4090. return props.error;
  4091. }
  4092. if (form && form.props.showError && state.status === "failed") {
  4093. return true;
  4094. }
  4095. });
  4096. const labelStyle = computed(() => {
  4097. const labelWidth = getProp("labelWidth");
  4098. if (labelWidth) {
  4099. return {
  4100. width: addUnit(labelWidth)
  4101. };
  4102. }
  4103. });
  4104. const onKeypress = (event) => {
  4105. const ENTER_CODE = 13;
  4106. if (event.keyCode === ENTER_CODE) {
  4107. const submitOnEnter = form && form.props.submitOnEnter;
  4108. if (!submitOnEnter && props.type !== "textarea") {
  4109. preventDefault(event);
  4110. }
  4111. if (props.type === "search") {
  4112. blur();
  4113. }
  4114. }
  4115. emit("keypress", event);
  4116. };
  4117. const getInputId = () => props.id || `${id}-input`;
  4118. const getValidationStatus = () => state.status;
  4119. const renderInput = () => {
  4120. const controlClass = bem$18("control", [getProp("inputAlign"), {
  4121. error: showError.value,
  4122. custom: !!slots.input,
  4123. "min-height": props.type === "textarea" && !props.autosize
  4124. }]);
  4125. if (slots.input) {
  4126. return createVNode("div", {
  4127. "class": controlClass,
  4128. "onClick": onClickInput
  4129. }, [slots.input()]);
  4130. }
  4131. const inputAttrs = {
  4132. id: getInputId(),
  4133. ref: inputRef,
  4134. name: props.name,
  4135. rows: props.rows !== void 0 ? +props.rows : void 0,
  4136. class: controlClass,
  4137. disabled: getProp("disabled"),
  4138. readonly: getProp("readonly"),
  4139. autofocus: props.autofocus,
  4140. placeholder: props.placeholder,
  4141. autocomplete: props.autocomplete,
  4142. enterkeyhint: props.enterkeyhint,
  4143. "aria-labelledby": props.label ? `${id}-label` : void 0,
  4144. onBlur,
  4145. onFocus,
  4146. onInput,
  4147. onClick: onClickInput,
  4148. onChange: endComposing,
  4149. onKeypress,
  4150. onCompositionend: endComposing,
  4151. onCompositionstart: startComposing
  4152. };
  4153. if (props.type === "textarea") {
  4154. return createVNode("textarea", inputAttrs, null);
  4155. }
  4156. return createVNode("input", mergeProps(mapInputType(props.type), inputAttrs), null);
  4157. };
  4158. const renderLeftIcon = () => {
  4159. const leftIconSlot = slots["left-icon"];
  4160. if (props.leftIcon || leftIconSlot) {
  4161. return createVNode("div", {
  4162. "class": bem$18("left-icon"),
  4163. "onClick": onClickLeftIcon
  4164. }, [leftIconSlot ? leftIconSlot() : createVNode(Icon, {
  4165. "name": props.leftIcon,
  4166. "classPrefix": props.iconPrefix
  4167. }, null)]);
  4168. }
  4169. };
  4170. const renderRightIcon = () => {
  4171. const rightIconSlot = slots["right-icon"];
  4172. if (props.rightIcon || rightIconSlot) {
  4173. return createVNode("div", {
  4174. "class": bem$18("right-icon"),
  4175. "onClick": onClickRightIcon
  4176. }, [rightIconSlot ? rightIconSlot() : createVNode(Icon, {
  4177. "name": props.rightIcon,
  4178. "classPrefix": props.iconPrefix
  4179. }, null)]);
  4180. }
  4181. };
  4182. const renderWordLimit = () => {
  4183. if (props.showWordLimit && props.maxlength) {
  4184. const count = getStringLength(getModelValue());
  4185. return createVNode("div", {
  4186. "class": bem$18("word-limit")
  4187. }, [createVNode("span", {
  4188. "class": bem$18("word-num")
  4189. }, [count]), createTextVNode("/"), props.maxlength]);
  4190. }
  4191. };
  4192. const renderMessage = () => {
  4193. if (form && form.props.showErrorMessage === false) {
  4194. return;
  4195. }
  4196. const message = props.errorMessage || state.validateMessage;
  4197. if (message) {
  4198. const slot = slots["error-message"];
  4199. const errorMessageAlign = getProp("errorMessageAlign");
  4200. return createVNode("div", {
  4201. "class": bem$18("error-message", errorMessageAlign)
  4202. }, [slot ? slot({
  4203. message
  4204. }) : message]);
  4205. }
  4206. };
  4207. const renderLabel = () => {
  4208. const colon = getProp("colon") ? ":" : "";
  4209. if (slots.label) {
  4210. return [slots.label(), colon];
  4211. }
  4212. if (props.label) {
  4213. return createVNode("label", {
  4214. "id": `${id}-label`,
  4215. "for": getInputId()
  4216. }, [props.label + colon]);
  4217. }
  4218. };
  4219. const renderFieldBody = () => [createVNode("div", {
  4220. "class": bem$18("body")
  4221. }, [renderInput(), showClear.value && createVNode(Icon, {
  4222. "ref": clearIconRef,
  4223. "name": props.clearIcon,
  4224. "class": bem$18("clear")
  4225. }, null), renderRightIcon(), slots.button && createVNode("div", {
  4226. "class": bem$18("button")
  4227. }, [slots.button()])]), renderWordLimit(), renderMessage()];
  4228. useExpose({
  4229. blur,
  4230. focus,
  4231. validate,
  4232. formValue,
  4233. resetValidation,
  4234. getValidationStatus
  4235. });
  4236. provide(CUSTOM_FIELD_INJECTION_KEY, {
  4237. customValue,
  4238. resetValidation,
  4239. validateWithTrigger
  4240. });
  4241. watch(() => props.modelValue, () => {
  4242. updateValue(getModelValue());
  4243. resetValidation();
  4244. validateWithTrigger("onChange");
  4245. nextTick(adjustTextareaSize);
  4246. });
  4247. onMounted(() => {
  4248. updateValue(getModelValue(), props.formatTrigger);
  4249. nextTick(adjustTextareaSize);
  4250. });
  4251. useEventListener("touchstart", onClear, {
  4252. target: computed(() => {
  4253. var _a;
  4254. return (_a = clearIconRef.value) == null ? void 0 : _a.$el;
  4255. })
  4256. });
  4257. return () => {
  4258. const disabled = getProp("disabled");
  4259. const labelAlign = getProp("labelAlign");
  4260. const LeftIcon = renderLeftIcon();
  4261. const renderTitle = () => {
  4262. const Label = renderLabel();
  4263. if (labelAlign === "top") {
  4264. return [LeftIcon, Label].filter(Boolean);
  4265. }
  4266. return Label || [];
  4267. };
  4268. return createVNode(Cell, {
  4269. "size": props.size,
  4270. "class": bem$18({
  4271. error: showError.value,
  4272. disabled,
  4273. [`label-${labelAlign}`]: labelAlign
  4274. }),
  4275. "center": props.center,
  4276. "border": props.border,
  4277. "isLink": props.isLink,
  4278. "clickable": props.clickable,
  4279. "titleStyle": labelStyle.value,
  4280. "valueClass": bem$18("value"),
  4281. "titleClass": [bem$18("label", [labelAlign, {
  4282. required: props.required
  4283. }]), props.labelClass],
  4284. "arrowDirection": props.arrowDirection
  4285. }, {
  4286. icon: LeftIcon && labelAlign !== "top" ? () => LeftIcon : null,
  4287. title: renderTitle,
  4288. value: renderFieldBody,
  4289. extra: slots.extra
  4290. });
  4291. };
  4292. }
  4293. });
  4294. const Field = withInstall(stdin_default$1j);
  4295. let lockCount = 0;
  4296. function lockClick(lock) {
  4297. if (lock) {
  4298. if (!lockCount) {
  4299. document.body.classList.add("van-toast--unclickable");
  4300. }
  4301. lockCount++;
  4302. } else if (lockCount) {
  4303. lockCount--;
  4304. if (!lockCount) {
  4305. document.body.classList.remove("van-toast--unclickable");
  4306. }
  4307. }
  4308. }
  4309. const [name$1b, bem$17] = createNamespace("toast");
  4310. const popupInheritProps = ["show", "overlay", "teleport", "transition", "overlayClass", "overlayStyle", "closeOnClickOverlay"];
  4311. const toastProps = {
  4312. icon: String,
  4313. show: Boolean,
  4314. type: makeStringProp("text"),
  4315. overlay: Boolean,
  4316. message: numericProp,
  4317. iconSize: numericProp,
  4318. duration: makeNumberProp(2e3),
  4319. position: makeStringProp("middle"),
  4320. teleport: [String, Object],
  4321. wordBreak: String,
  4322. className: unknownProp,
  4323. iconPrefix: String,
  4324. transition: makeStringProp("van-fade"),
  4325. loadingType: String,
  4326. forbidClick: Boolean,
  4327. overlayClass: unknownProp,
  4328. overlayStyle: Object,
  4329. closeOnClick: Boolean,
  4330. closeOnClickOverlay: Boolean
  4331. };
  4332. var stdin_default$1i = defineComponent({
  4333. name: name$1b,
  4334. props: toastProps,
  4335. emits: ["update:show"],
  4336. setup(props, {
  4337. emit,
  4338. slots
  4339. }) {
  4340. let timer2;
  4341. let clickable = false;
  4342. const toggleClickable = () => {
  4343. const newValue = props.show && props.forbidClick;
  4344. if (clickable !== newValue) {
  4345. clickable = newValue;
  4346. lockClick(clickable);
  4347. }
  4348. };
  4349. const updateShow = (show) => emit("update:show", show);
  4350. const onClick = () => {
  4351. if (props.closeOnClick) {
  4352. updateShow(false);
  4353. }
  4354. };
  4355. const clearTimer = () => clearTimeout(timer2);
  4356. const renderIcon = () => {
  4357. const {
  4358. icon,
  4359. type,
  4360. iconSize,
  4361. iconPrefix,
  4362. loadingType
  4363. } = props;
  4364. const hasIcon = icon || type === "success" || type === "fail";
  4365. if (hasIcon) {
  4366. return createVNode(Icon, {
  4367. "name": icon || type,
  4368. "size": iconSize,
  4369. "class": bem$17("icon"),
  4370. "classPrefix": iconPrefix
  4371. }, null);
  4372. }
  4373. if (type === "loading") {
  4374. return createVNode(Loading, {
  4375. "class": bem$17("loading"),
  4376. "size": iconSize,
  4377. "type": loadingType
  4378. }, null);
  4379. }
  4380. };
  4381. const renderMessage = () => {
  4382. const {
  4383. type,
  4384. message
  4385. } = props;
  4386. if (slots.message) {
  4387. return createVNode("div", {
  4388. "class": bem$17("text")
  4389. }, [slots.message()]);
  4390. }
  4391. if (isDef(message) && message !== "") {
  4392. return type === "html" ? createVNode("div", {
  4393. "key": 0,
  4394. "class": bem$17("text"),
  4395. "innerHTML": String(message)
  4396. }, null) : createVNode("div", {
  4397. "class": bem$17("text")
  4398. }, [message]);
  4399. }
  4400. };
  4401. watch(() => [props.show, props.forbidClick], toggleClickable);
  4402. watch(() => [props.show, props.type, props.message, props.duration], () => {
  4403. clearTimer();
  4404. if (props.show && props.duration > 0) {
  4405. timer2 = setTimeout(() => {
  4406. updateShow(false);
  4407. }, props.duration);
  4408. }
  4409. });
  4410. onMounted(toggleClickable);
  4411. onUnmounted(toggleClickable);
  4412. return () => createVNode(Popup, mergeProps({
  4413. "class": [bem$17([props.position, props.wordBreak === "normal" ? "break-normal" : props.wordBreak, {
  4414. [props.type]: !props.icon
  4415. }]), props.className],
  4416. "lockScroll": false,
  4417. "onClick": onClick,
  4418. "onClosed": clearTimer,
  4419. "onUpdate:show": updateShow
  4420. }, pick(props, popupInheritProps)), {
  4421. default: () => [renderIcon(), renderMessage()]
  4422. });
  4423. }
  4424. });
  4425. function usePopupState() {
  4426. const state = reactive({
  4427. show: false
  4428. });
  4429. const toggle = (show) => {
  4430. state.show = show;
  4431. };
  4432. const open = (props) => {
  4433. extend(state, props, { transitionAppear: true });
  4434. toggle(true);
  4435. };
  4436. const close = () => toggle(false);
  4437. useExpose({ open, close, toggle });
  4438. return {
  4439. open,
  4440. close,
  4441. state,
  4442. toggle
  4443. };
  4444. }
  4445. function mountComponent(RootComponent) {
  4446. const app = createApp(RootComponent);
  4447. const root = document.createElement("div");
  4448. document.body.appendChild(root);
  4449. return {
  4450. instance: app.mount(root),
  4451. unmount() {
  4452. app.unmount();
  4453. document.body.removeChild(root);
  4454. }
  4455. };
  4456. }
  4457. const defaultOptions$1 = {
  4458. icon: "",
  4459. type: "text",
  4460. message: "",
  4461. className: "",
  4462. overlay: false,
  4463. onClose: void 0,
  4464. onOpened: void 0,
  4465. duration: 2e3,
  4466. teleport: "body",
  4467. iconSize: void 0,
  4468. iconPrefix: void 0,
  4469. position: "middle",
  4470. transition: "van-fade",
  4471. forbidClick: false,
  4472. loadingType: void 0,
  4473. overlayClass: "",
  4474. overlayStyle: void 0,
  4475. closeOnClick: false,
  4476. closeOnClickOverlay: false
  4477. };
  4478. let queue = [];
  4479. let allowMultiple = false;
  4480. let currentOptions$2 = extend({}, defaultOptions$1);
  4481. const defaultOptionsMap = /* @__PURE__ */ new Map();
  4482. function parseOptions$1(message) {
  4483. if (isObject(message)) {
  4484. return message;
  4485. }
  4486. return {
  4487. message
  4488. };
  4489. }
  4490. function createInstance() {
  4491. const {
  4492. instance: instance2,
  4493. unmount
  4494. } = mountComponent({
  4495. setup() {
  4496. const message = ref("");
  4497. const {
  4498. open,
  4499. state,
  4500. close,
  4501. toggle
  4502. } = usePopupState();
  4503. const onClosed = () => {
  4504. if (allowMultiple) {
  4505. queue = queue.filter((item) => item !== instance2);
  4506. unmount();
  4507. }
  4508. };
  4509. const render = () => {
  4510. const attrs = {
  4511. onClosed,
  4512. "onUpdate:show": toggle
  4513. };
  4514. return createVNode(stdin_default$1i, mergeProps(state, attrs), null);
  4515. };
  4516. watch(message, (val) => {
  4517. state.message = val;
  4518. });
  4519. getCurrentInstance().render = render;
  4520. return {
  4521. open,
  4522. close,
  4523. message
  4524. };
  4525. }
  4526. });
  4527. return instance2;
  4528. }
  4529. function getInstance() {
  4530. if (!queue.length || allowMultiple) {
  4531. const instance2 = createInstance();
  4532. queue.push(instance2);
  4533. }
  4534. return queue[queue.length - 1];
  4535. }
  4536. function showToast(options = {}) {
  4537. if (!inBrowser) {
  4538. return {};
  4539. }
  4540. const toast = getInstance();
  4541. const parsedOptions = parseOptions$1(options);
  4542. toast.open(extend({}, currentOptions$2, defaultOptionsMap.get(parsedOptions.type || currentOptions$2.type), parsedOptions));
  4543. return toast;
  4544. }
  4545. const createMethod = (type) => (options) => showToast(extend({
  4546. type
  4547. }, parseOptions$1(options)));
  4548. const showLoadingToast = createMethod("loading");
  4549. const showSuccessToast = createMethod("success");
  4550. const showFailToast = createMethod("fail");
  4551. const closeToast = (all) => {
  4552. var _a;
  4553. if (queue.length) {
  4554. if (all) {
  4555. queue.forEach((toast) => {
  4556. toast.close();
  4557. });
  4558. queue = [];
  4559. } else if (!allowMultiple) {
  4560. queue[0].close();
  4561. } else {
  4562. (_a = queue.shift()) == null ? void 0 : _a.close();
  4563. }
  4564. }
  4565. };
  4566. function setToastDefaultOptions(type, options) {
  4567. if (typeof type === "string") {
  4568. defaultOptionsMap.set(type, options);
  4569. } else {
  4570. extend(currentOptions$2, type);
  4571. }
  4572. }
  4573. const resetToastDefaultOptions = (type) => {
  4574. if (typeof type === "string") {
  4575. defaultOptionsMap.delete(type);
  4576. } else {
  4577. currentOptions$2 = extend({}, defaultOptions$1);
  4578. defaultOptionsMap.clear();
  4579. }
  4580. };
  4581. const allowMultipleToast = (value = true) => {
  4582. allowMultiple = value;
  4583. };
  4584. const Toast = withInstall(stdin_default$1i);
  4585. const [name$1a, bem$16] = createNamespace("switch");
  4586. const switchProps = {
  4587. size: numericProp,
  4588. loading: Boolean,
  4589. disabled: Boolean,
  4590. modelValue: unknownProp,
  4591. activeColor: String,
  4592. inactiveColor: String,
  4593. activeValue: {
  4594. type: unknownProp,
  4595. default: true
  4596. },
  4597. inactiveValue: {
  4598. type: unknownProp,
  4599. default: false
  4600. }
  4601. };
  4602. var stdin_default$1h = defineComponent({
  4603. name: name$1a,
  4604. props: switchProps,
  4605. emits: ["change", "update:modelValue"],
  4606. setup(props, {
  4607. emit,
  4608. slots
  4609. }) {
  4610. const isChecked = () => props.modelValue === props.activeValue;
  4611. const onClick = () => {
  4612. if (!props.disabled && !props.loading) {
  4613. const newValue = isChecked() ? props.inactiveValue : props.activeValue;
  4614. emit("update:modelValue", newValue);
  4615. emit("change", newValue);
  4616. }
  4617. };
  4618. const renderLoading = () => {
  4619. if (props.loading) {
  4620. const color = isChecked() ? props.activeColor : props.inactiveColor;
  4621. return createVNode(Loading, {
  4622. "class": bem$16("loading"),
  4623. "color": color
  4624. }, null);
  4625. }
  4626. if (slots.node) {
  4627. return slots.node();
  4628. }
  4629. };
  4630. useCustomFieldValue(() => props.modelValue);
  4631. return () => {
  4632. var _a;
  4633. const {
  4634. size,
  4635. loading,
  4636. disabled,
  4637. activeColor,
  4638. inactiveColor
  4639. } = props;
  4640. const checked = isChecked();
  4641. const style = {
  4642. fontSize: addUnit(size),
  4643. backgroundColor: checked ? activeColor : inactiveColor
  4644. };
  4645. return createVNode("div", {
  4646. "role": "switch",
  4647. "class": bem$16({
  4648. on: checked,
  4649. loading,
  4650. disabled
  4651. }),
  4652. "style": style,
  4653. "tabindex": disabled ? void 0 : 0,
  4654. "aria-checked": checked,
  4655. "onClick": onClick
  4656. }, [createVNode("div", {
  4657. "class": bem$16("node")
  4658. }, [renderLoading()]), (_a = slots.background) == null ? void 0 : _a.call(slots)]);
  4659. };
  4660. }
  4661. });
  4662. const Switch = withInstall(stdin_default$1h);
  4663. const [name$19, bem$15] = createNamespace("address-edit-detail");
  4664. const t$i = createNamespace("address-edit")[2];
  4665. var stdin_default$1g = defineComponent({
  4666. name: name$19,
  4667. props: {
  4668. show: Boolean,
  4669. rows: numericProp,
  4670. value: String,
  4671. rules: Array,
  4672. focused: Boolean,
  4673. maxlength: numericProp,
  4674. searchResult: Array,
  4675. showSearchResult: Boolean
  4676. },
  4677. emits: ["blur", "focus", "input", "selectSearch"],
  4678. setup(props, {
  4679. emit
  4680. }) {
  4681. const field = ref();
  4682. const showSearchResult = () => props.focused && props.searchResult && props.showSearchResult;
  4683. const onSelect = (express) => {
  4684. emit("selectSearch", express);
  4685. emit("input", `${express.address || ""} ${express.name || ""}`.trim());
  4686. };
  4687. const renderSearchResult = () => {
  4688. if (!showSearchResult()) {
  4689. return;
  4690. }
  4691. const {
  4692. searchResult
  4693. } = props;
  4694. return searchResult.map((express) => createVNode(Cell, {
  4695. "clickable": true,
  4696. "key": (express.name || "") + (express.address || ""),
  4697. "icon": "location-o",
  4698. "title": express.name,
  4699. "label": express.address,
  4700. "class": bem$15("search-item"),
  4701. "border": false,
  4702. "onClick": () => onSelect(express)
  4703. }, null));
  4704. };
  4705. const onBlur = (event) => emit("blur", event);
  4706. const onFocus = (event) => emit("focus", event);
  4707. const onInput = (value) => emit("input", value);
  4708. return () => {
  4709. if (props.show) {
  4710. return createVNode(Fragment, null, [createVNode(Field, {
  4711. "autosize": true,
  4712. "clearable": true,
  4713. "ref": field,
  4714. "class": bem$15(),
  4715. "rows": props.rows,
  4716. "type": "textarea",
  4717. "rules": props.rules,
  4718. "label": t$i("addressDetail"),
  4719. "border": !showSearchResult(),
  4720. "maxlength": props.maxlength,
  4721. "modelValue": props.value,
  4722. "placeholder": t$i("addressDetail"),
  4723. "onBlur": onBlur,
  4724. "onFocus": onFocus,
  4725. "onUpdate:modelValue": onInput
  4726. }, null), renderSearchResult()]);
  4727. }
  4728. };
  4729. }
  4730. });
  4731. const [name$18, bem$14, t$h] = createNamespace("address-edit");
  4732. const DEFAULT_DATA = {
  4733. name: "",
  4734. tel: "",
  4735. city: "",
  4736. county: "",
  4737. country: "",
  4738. province: "",
  4739. areaCode: "",
  4740. isDefault: false,
  4741. addressDetail: ""
  4742. };
  4743. const addressEditProps = {
  4744. areaList: Object,
  4745. isSaving: Boolean,
  4746. isDeleting: Boolean,
  4747. validator: Function,
  4748. showArea: truthProp,
  4749. showDetail: truthProp,
  4750. showDelete: Boolean,
  4751. disableArea: Boolean,
  4752. searchResult: Array,
  4753. telMaxlength: numericProp,
  4754. showSetDefault: Boolean,
  4755. saveButtonText: String,
  4756. areaPlaceholder: String,
  4757. deleteButtonText: String,
  4758. showSearchResult: Boolean,
  4759. detailRows: makeNumericProp(1),
  4760. detailMaxlength: makeNumericProp(200),
  4761. areaColumnsPlaceholder: makeArrayProp(),
  4762. addressInfo: {
  4763. type: Object,
  4764. default: () => extend({}, DEFAULT_DATA)
  4765. },
  4766. telValidator: {
  4767. type: Function,
  4768. default: isMobile
  4769. }
  4770. };
  4771. var stdin_default$1f = defineComponent({
  4772. name: name$18,
  4773. props: addressEditProps,
  4774. emits: ["save", "focus", "delete", "clickArea", "changeArea", "changeDetail", "selectSearch", "changeDefault"],
  4775. setup(props, {
  4776. emit,
  4777. slots
  4778. }) {
  4779. const areaRef = ref();
  4780. const data = reactive({});
  4781. const showAreaPopup = ref(false);
  4782. const detailFocused = ref(false);
  4783. const areaListLoaded = computed(() => isObject(props.areaList) && Object.keys(props.areaList).length);
  4784. const areaText = computed(() => {
  4785. const {
  4786. province,
  4787. city,
  4788. county,
  4789. areaCode
  4790. } = data;
  4791. if (areaCode) {
  4792. const arr = [province, city, county];
  4793. if (province && province === city) {
  4794. arr.splice(1, 1);
  4795. }
  4796. return arr.filter(Boolean).join("/");
  4797. }
  4798. return "";
  4799. });
  4800. const hideBottomFields = computed(() => {
  4801. var _a;
  4802. return ((_a = props.searchResult) == null ? void 0 : _a.length) && detailFocused.value;
  4803. });
  4804. const onFocus = (key) => {
  4805. detailFocused.value = key === "addressDetail";
  4806. emit("focus", key);
  4807. };
  4808. const rules = computed(() => {
  4809. const {
  4810. validator,
  4811. telValidator
  4812. } = props;
  4813. const makeRule = (name2, emptyMessage) => ({
  4814. validator: (value) => {
  4815. if (validator) {
  4816. const message = validator(name2, value);
  4817. if (message) {
  4818. return message;
  4819. }
  4820. }
  4821. if (!value) {
  4822. return emptyMessage;
  4823. }
  4824. return true;
  4825. }
  4826. });
  4827. return {
  4828. name: [makeRule("name", t$h("nameEmpty"))],
  4829. tel: [makeRule("tel", t$h("telInvalid")), {
  4830. validator: telValidator,
  4831. message: t$h("telInvalid")
  4832. }],
  4833. areaCode: [makeRule("areaCode", t$h("areaEmpty"))],
  4834. addressDetail: [makeRule("addressDetail", t$h("addressEmpty"))]
  4835. };
  4836. });
  4837. const onSave = () => emit("save", data);
  4838. const onChangeDetail = (val) => {
  4839. data.addressDetail = val;
  4840. emit("changeDetail", val);
  4841. };
  4842. const assignAreaText = (options) => {
  4843. data.province = options[0].text;
  4844. data.city = options[1].text;
  4845. data.county = options[2].text;
  4846. };
  4847. const onAreaConfirm = ({
  4848. selectedValues,
  4849. selectedOptions
  4850. }) => {
  4851. if (selectedValues.some((value) => value === AREA_EMPTY_CODE)) {
  4852. showToast(t$h("areaEmpty"));
  4853. } else {
  4854. showAreaPopup.value = false;
  4855. assignAreaText(selectedOptions);
  4856. emit("changeArea", selectedOptions);
  4857. }
  4858. };
  4859. const onDelete = () => emit("delete", data);
  4860. const setAreaCode = (code) => {
  4861. data.areaCode = code || "";
  4862. };
  4863. const onDetailBlur = () => {
  4864. setTimeout(() => {
  4865. detailFocused.value = false;
  4866. });
  4867. };
  4868. const setAddressDetail = (value) => {
  4869. data.addressDetail = value;
  4870. };
  4871. const renderSetDefaultCell = () => {
  4872. if (props.showSetDefault) {
  4873. const slots2 = {
  4874. "right-icon": () => createVNode(Switch, {
  4875. "modelValue": data.isDefault,
  4876. "onUpdate:modelValue": ($event) => data.isDefault = $event,
  4877. "onChange": (event) => emit("changeDefault", event)
  4878. }, null)
  4879. };
  4880. return withDirectives(createVNode(Cell, {
  4881. "center": true,
  4882. "title": t$h("defaultAddress"),
  4883. "class": bem$14("default")
  4884. }, slots2), [[vShow, !hideBottomFields.value]]);
  4885. }
  4886. };
  4887. useExpose({
  4888. setAreaCode,
  4889. setAddressDetail
  4890. });
  4891. watch(() => props.addressInfo, (value) => {
  4892. extend(data, DEFAULT_DATA, value);
  4893. nextTick(() => {
  4894. var _a;
  4895. const options = (_a = areaRef.value) == null ? void 0 : _a.getSelectedOptions();
  4896. if (options && options.every((option) => option && option.value !== AREA_EMPTY_CODE)) {
  4897. assignAreaText(options);
  4898. }
  4899. });
  4900. }, {
  4901. deep: true,
  4902. immediate: true
  4903. });
  4904. return () => {
  4905. const {
  4906. disableArea
  4907. } = props;
  4908. return createVNode(Form, {
  4909. "class": bem$14(),
  4910. "onSubmit": onSave
  4911. }, {
  4912. default: () => {
  4913. var _a;
  4914. return [createVNode("div", {
  4915. "class": bem$14("fields")
  4916. }, [createVNode(Field, {
  4917. "modelValue": data.name,
  4918. "onUpdate:modelValue": ($event) => data.name = $event,
  4919. "clearable": true,
  4920. "label": t$h("name"),
  4921. "rules": rules.value.name,
  4922. "placeholder": t$h("name"),
  4923. "onFocus": () => onFocus("name")
  4924. }, null), createVNode(Field, {
  4925. "modelValue": data.tel,
  4926. "onUpdate:modelValue": ($event) => data.tel = $event,
  4927. "clearable": true,
  4928. "type": "tel",
  4929. "label": t$h("tel"),
  4930. "rules": rules.value.tel,
  4931. "maxlength": props.telMaxlength,
  4932. "placeholder": t$h("tel"),
  4933. "onFocus": () => onFocus("tel")
  4934. }, null), withDirectives(createVNode(Field, {
  4935. "readonly": true,
  4936. "label": t$h("area"),
  4937. "is-link": !disableArea,
  4938. "modelValue": areaText.value,
  4939. "rules": rules.value.areaCode,
  4940. "placeholder": props.areaPlaceholder || t$h("area"),
  4941. "onFocus": () => onFocus("areaCode"),
  4942. "onClick": () => {
  4943. emit("clickArea");
  4944. showAreaPopup.value = !disableArea;
  4945. }
  4946. }, null), [[vShow, props.showArea]]), createVNode(stdin_default$1g, {
  4947. "show": props.showDetail,
  4948. "rows": props.detailRows,
  4949. "rules": rules.value.addressDetail,
  4950. "value": data.addressDetail,
  4951. "focused": detailFocused.value,
  4952. "maxlength": props.detailMaxlength,
  4953. "searchResult": props.searchResult,
  4954. "showSearchResult": props.showSearchResult,
  4955. "onBlur": onDetailBlur,
  4956. "onFocus": () => onFocus("addressDetail"),
  4957. "onInput": onChangeDetail,
  4958. "onSelectSearch": (event) => emit("selectSearch", event)
  4959. }, null), (_a = slots.default) == null ? void 0 : _a.call(slots)]), renderSetDefaultCell(), withDirectives(createVNode("div", {
  4960. "class": bem$14("buttons")
  4961. }, [createVNode(Button, {
  4962. "block": true,
  4963. "round": true,
  4964. "type": "primary",
  4965. "text": props.saveButtonText || t$h("save"),
  4966. "class": bem$14("button"),
  4967. "loading": props.isSaving,
  4968. "nativeType": "submit"
  4969. }, null), props.showDelete && createVNode(Button, {
  4970. "block": true,
  4971. "round": true,
  4972. "class": bem$14("button"),
  4973. "loading": props.isDeleting,
  4974. "text": props.deleteButtonText || t$h("delete"),
  4975. "onClick": onDelete
  4976. }, null)]), [[vShow, !hideBottomFields.value]]), createVNode(Popup, {
  4977. "show": showAreaPopup.value,
  4978. "onUpdate:show": ($event) => showAreaPopup.value = $event,
  4979. "round": true,
  4980. "teleport": "body",
  4981. "position": "bottom",
  4982. "lazyRender": false
  4983. }, {
  4984. default: () => [createVNode(Area, {
  4985. "modelValue": data.areaCode,
  4986. "onUpdate:modelValue": ($event) => data.areaCode = $event,
  4987. "ref": areaRef,
  4988. "loading": !areaListLoaded.value,
  4989. "areaList": props.areaList,
  4990. "columnsPlaceholder": props.areaColumnsPlaceholder,
  4991. "onConfirm": onAreaConfirm,
  4992. "onCancel": () => {
  4993. showAreaPopup.value = false;
  4994. }
  4995. }, null)]
  4996. })];
  4997. }
  4998. });
  4999. };
  5000. }
  5001. });
  5002. const AddressEdit = withInstall(stdin_default$1f);
  5003. const [name$17, bem$13] = createNamespace("radio-group");
  5004. const radioGroupProps = {
  5005. disabled: Boolean,
  5006. iconSize: numericProp,
  5007. direction: String,
  5008. modelValue: unknownProp,
  5009. checkedColor: String
  5010. };
  5011. const RADIO_KEY = Symbol(name$17);
  5012. var stdin_default$1e = defineComponent({
  5013. name: name$17,
  5014. props: radioGroupProps,
  5015. emits: ["change", "update:modelValue"],
  5016. setup(props, {
  5017. emit,
  5018. slots
  5019. }) {
  5020. const {
  5021. linkChildren
  5022. } = useChildren(RADIO_KEY);
  5023. const updateValue = (value) => emit("update:modelValue", value);
  5024. watch(() => props.modelValue, (value) => emit("change", value));
  5025. linkChildren({
  5026. props,
  5027. updateValue
  5028. });
  5029. useCustomFieldValue(() => props.modelValue);
  5030. return () => {
  5031. var _a;
  5032. return createVNode("div", {
  5033. "class": bem$13([props.direction]),
  5034. "role": "radiogroup"
  5035. }, [(_a = slots.default) == null ? void 0 : _a.call(slots)]);
  5036. };
  5037. }
  5038. });
  5039. const RadioGroup = withInstall(stdin_default$1e);
  5040. const [name$16, bem$12] = createNamespace("tag");
  5041. const tagProps = {
  5042. size: String,
  5043. mark: Boolean,
  5044. show: truthProp,
  5045. type: makeStringProp("default"),
  5046. color: String,
  5047. plain: Boolean,
  5048. round: Boolean,
  5049. textColor: String,
  5050. closeable: Boolean
  5051. };
  5052. var stdin_default$1d = defineComponent({
  5053. name: name$16,
  5054. props: tagProps,
  5055. emits: ["close"],
  5056. setup(props, {
  5057. slots,
  5058. emit
  5059. }) {
  5060. const onClose = (event) => {
  5061. event.stopPropagation();
  5062. emit("close", event);
  5063. };
  5064. const getStyle = () => {
  5065. if (props.plain) {
  5066. return {
  5067. color: props.textColor || props.color,
  5068. borderColor: props.color
  5069. };
  5070. }
  5071. return {
  5072. color: props.textColor,
  5073. background: props.color
  5074. };
  5075. };
  5076. const renderTag = () => {
  5077. var _a;
  5078. const {
  5079. type,
  5080. mark,
  5081. plain,
  5082. round,
  5083. size,
  5084. closeable
  5085. } = props;
  5086. const classes = {
  5087. mark,
  5088. plain,
  5089. round
  5090. };
  5091. if (size) {
  5092. classes[size] = size;
  5093. }
  5094. const CloseIcon = closeable && createVNode(Icon, {
  5095. "name": "cross",
  5096. "class": [bem$12("close"), HAPTICS_FEEDBACK],
  5097. "onClick": onClose
  5098. }, null);
  5099. return createVNode("span", {
  5100. "style": getStyle(),
  5101. "class": bem$12([classes, type])
  5102. }, [(_a = slots.default) == null ? void 0 : _a.call(slots), CloseIcon]);
  5103. };
  5104. return () => createVNode(Transition, {
  5105. "name": props.closeable ? "van-fade" : void 0
  5106. }, {
  5107. default: () => [props.show ? renderTag() : null]
  5108. });
  5109. }
  5110. });
  5111. const Tag = withInstall(stdin_default$1d);
  5112. const checkerProps = {
  5113. name: unknownProp,
  5114. shape: makeStringProp("round"),
  5115. disabled: Boolean,
  5116. iconSize: numericProp,
  5117. modelValue: unknownProp,
  5118. checkedColor: String,
  5119. labelPosition: String,
  5120. labelDisabled: Boolean
  5121. };
  5122. var stdin_default$1c = defineComponent({
  5123. props: extend({}, checkerProps, {
  5124. bem: makeRequiredProp(Function),
  5125. role: String,
  5126. parent: Object,
  5127. checked: Boolean,
  5128. bindGroup: truthProp
  5129. }),
  5130. emits: ["click", "toggle"],
  5131. setup(props, {
  5132. emit,
  5133. slots
  5134. }) {
  5135. const iconRef = ref();
  5136. const getParentProp = (name2) => {
  5137. if (props.parent && props.bindGroup) {
  5138. return props.parent.props[name2];
  5139. }
  5140. };
  5141. const disabled = computed(() => getParentProp("disabled") || props.disabled);
  5142. const direction = computed(() => getParentProp("direction"));
  5143. const iconStyle = computed(() => {
  5144. const checkedColor = props.checkedColor || getParentProp("checkedColor");
  5145. if (checkedColor && props.checked && !disabled.value) {
  5146. return {
  5147. borderColor: checkedColor,
  5148. backgroundColor: checkedColor
  5149. };
  5150. }
  5151. });
  5152. const onClick = (event) => {
  5153. const {
  5154. target
  5155. } = event;
  5156. const icon = iconRef.value;
  5157. const iconClicked = icon === target || (icon == null ? void 0 : icon.contains(target));
  5158. if (!disabled.value && (iconClicked || !props.labelDisabled)) {
  5159. emit("toggle");
  5160. }
  5161. emit("click", event);
  5162. };
  5163. const renderIcon = () => {
  5164. const {
  5165. bem: bem2,
  5166. shape,
  5167. checked
  5168. } = props;
  5169. const iconSize = props.iconSize || getParentProp("iconSize");
  5170. return createVNode("div", {
  5171. "ref": iconRef,
  5172. "class": bem2("icon", [shape, {
  5173. disabled: disabled.value,
  5174. checked
  5175. }]),
  5176. "style": {
  5177. fontSize: addUnit(iconSize)
  5178. }
  5179. }, [slots.icon ? slots.icon({
  5180. checked,
  5181. disabled: disabled.value
  5182. }) : createVNode(Icon, {
  5183. "name": "success",
  5184. "style": iconStyle.value
  5185. }, null)]);
  5186. };
  5187. const renderLabel = () => {
  5188. if (slots.default) {
  5189. return createVNode("span", {
  5190. "class": props.bem("label", [props.labelPosition, {
  5191. disabled: disabled.value
  5192. }])
  5193. }, [slots.default()]);
  5194. }
  5195. };
  5196. return () => {
  5197. const nodes = props.labelPosition === "left" ? [renderLabel(), renderIcon()] : [renderIcon(), renderLabel()];
  5198. return createVNode("div", {
  5199. "role": props.role,
  5200. "class": props.bem([{
  5201. disabled: disabled.value,
  5202. "label-disabled": props.labelDisabled
  5203. }, direction.value]),
  5204. "tabindex": disabled.value ? void 0 : 0,
  5205. "aria-checked": props.checked,
  5206. "onClick": onClick
  5207. }, [nodes]);
  5208. };
  5209. }
  5210. });
  5211. const radioProps = checkerProps;
  5212. const [name$15, bem$11] = createNamespace("radio");
  5213. var stdin_default$1b = defineComponent({
  5214. name: name$15,
  5215. props: checkerProps,
  5216. emits: ["update:modelValue"],
  5217. setup(props, {
  5218. emit,
  5219. slots
  5220. }) {
  5221. const {
  5222. parent
  5223. } = useParent(RADIO_KEY);
  5224. const checked = () => {
  5225. const value = parent ? parent.props.modelValue : props.modelValue;
  5226. return value === props.name;
  5227. };
  5228. const toggle = () => {
  5229. if (parent) {
  5230. parent.updateValue(props.name);
  5231. } else {
  5232. emit("update:modelValue", props.name);
  5233. }
  5234. };
  5235. return () => createVNode(stdin_default$1c, mergeProps({
  5236. "bem": bem$11,
  5237. "role": "radio",
  5238. "parent": parent,
  5239. "checked": checked(),
  5240. "onToggle": toggle
  5241. }, props), pick(slots, ["default", "icon"]));
  5242. }
  5243. });
  5244. const Radio = withInstall(stdin_default$1b);
  5245. const [name$14, bem$10] = createNamespace("address-item");
  5246. var stdin_default$1a = defineComponent({
  5247. name: name$14,
  5248. props: {
  5249. address: makeRequiredProp(Object),
  5250. disabled: Boolean,
  5251. switchable: Boolean,
  5252. defaultTagText: String
  5253. },
  5254. emits: ["edit", "click", "select"],
  5255. setup(props, {
  5256. slots,
  5257. emit
  5258. }) {
  5259. const onClick = () => {
  5260. if (props.switchable) {
  5261. emit("select");
  5262. }
  5263. emit("click");
  5264. };
  5265. const renderRightIcon = () => createVNode(Icon, {
  5266. "name": "edit",
  5267. "class": bem$10("edit"),
  5268. "onClick": (event) => {
  5269. event.stopPropagation();
  5270. emit("edit");
  5271. emit("click");
  5272. }
  5273. }, null);
  5274. const renderTag = () => {
  5275. if (slots.tag) {
  5276. return slots.tag(props.address);
  5277. }
  5278. if (props.address.isDefault && props.defaultTagText) {
  5279. return createVNode(Tag, {
  5280. "type": "primary",
  5281. "round": true,
  5282. "class": bem$10("tag")
  5283. }, {
  5284. default: () => [props.defaultTagText]
  5285. });
  5286. }
  5287. };
  5288. const renderContent = () => {
  5289. const {
  5290. address,
  5291. disabled,
  5292. switchable
  5293. } = props;
  5294. const Info = [createVNode("div", {
  5295. "class": bem$10("name")
  5296. }, [`${address.name} ${address.tel}`, renderTag()]), createVNode("div", {
  5297. "class": bem$10("address")
  5298. }, [address.address])];
  5299. if (switchable && !disabled) {
  5300. return createVNode(Radio, {
  5301. "name": address.id,
  5302. "iconSize": 18
  5303. }, {
  5304. default: () => [Info]
  5305. });
  5306. }
  5307. return Info;
  5308. };
  5309. return () => {
  5310. var _a;
  5311. const {
  5312. disabled
  5313. } = props;
  5314. return createVNode("div", {
  5315. "class": bem$10({
  5316. disabled
  5317. }),
  5318. "onClick": onClick
  5319. }, [createVNode(Cell, {
  5320. "border": false,
  5321. "titleClass": bem$10("title")
  5322. }, {
  5323. title: renderContent,
  5324. "right-icon": renderRightIcon
  5325. }), (_a = slots.bottom) == null ? void 0 : _a.call(slots, extend({}, props.address, {
  5326. disabled
  5327. }))]);
  5328. };
  5329. }
  5330. });
  5331. const [name$13, bem$$, t$g] = createNamespace("address-list");
  5332. const addressListProps = {
  5333. list: makeArrayProp(),
  5334. modelValue: numericProp,
  5335. switchable: truthProp,
  5336. disabledText: String,
  5337. disabledList: makeArrayProp(),
  5338. addButtonText: String,
  5339. defaultTagText: String
  5340. };
  5341. var stdin_default$19 = defineComponent({
  5342. name: name$13,
  5343. props: addressListProps,
  5344. emits: ["add", "edit", "select", "clickItem", "editDisabled", "selectDisabled", "update:modelValue"],
  5345. setup(props, {
  5346. slots,
  5347. emit
  5348. }) {
  5349. const renderItem = (item, index, disabled) => {
  5350. const onEdit = () => emit(disabled ? "editDisabled" : "edit", item, index);
  5351. const onClick = () => emit("clickItem", item, index);
  5352. const onSelect = () => {
  5353. emit(disabled ? "selectDisabled" : "select", item, index);
  5354. if (!disabled) {
  5355. emit("update:modelValue", item.id);
  5356. }
  5357. };
  5358. return createVNode(stdin_default$1a, {
  5359. "key": item.id,
  5360. "address": item,
  5361. "disabled": disabled,
  5362. "switchable": props.switchable,
  5363. "defaultTagText": props.defaultTagText,
  5364. "onEdit": onEdit,
  5365. "onClick": onClick,
  5366. "onSelect": onSelect
  5367. }, {
  5368. bottom: slots["item-bottom"],
  5369. tag: slots.tag
  5370. });
  5371. };
  5372. const renderList = (list, disabled) => {
  5373. if (list) {
  5374. return list.map((item, index) => renderItem(item, index, disabled));
  5375. }
  5376. };
  5377. const renderBottom = () => createVNode("div", {
  5378. "class": [bem$$("bottom"), "van-safe-area-bottom"]
  5379. }, [createVNode(Button, {
  5380. "round": true,
  5381. "block": true,
  5382. "type": "primary",
  5383. "text": props.addButtonText || t$g("add"),
  5384. "class": bem$$("add"),
  5385. "onClick": () => emit("add")
  5386. }, null)]);
  5387. return () => {
  5388. var _a, _b;
  5389. const List2 = renderList(props.list);
  5390. const DisabledList = renderList(props.disabledList, true);
  5391. const DisabledText = props.disabledText && createVNode("div", {
  5392. "class": bem$$("disabled-text")
  5393. }, [props.disabledText]);
  5394. return createVNode("div", {
  5395. "class": bem$$()
  5396. }, [(_a = slots.top) == null ? void 0 : _a.call(slots), createVNode(RadioGroup, {
  5397. "modelValue": props.modelValue
  5398. }, {
  5399. default: () => [List2]
  5400. }), DisabledText, DisabledList, (_b = slots.default) == null ? void 0 : _b.call(slots), renderBottom()]);
  5401. };
  5402. }
  5403. });
  5404. const AddressList = withInstall(stdin_default$19);
  5405. const hasIntersectionObserver = inBrowser$1 && "IntersectionObserver" in window && "IntersectionObserverEntry" in window && "intersectionRatio" in window.IntersectionObserverEntry.prototype;
  5406. const modeType = {
  5407. event: "event",
  5408. observer: "observer"
  5409. };
  5410. function remove(arr, item) {
  5411. if (!arr.length)
  5412. return;
  5413. const index = arr.indexOf(item);
  5414. if (index > -1)
  5415. return arr.splice(index, 1);
  5416. }
  5417. function getBestSelectionFromSrcset(el, scale) {
  5418. if (el.tagName !== "IMG" || !el.getAttribute("data-srcset"))
  5419. return;
  5420. let options = el.getAttribute("data-srcset");
  5421. const container = el.parentNode;
  5422. const containerWidth = container.offsetWidth * scale;
  5423. let spaceIndex;
  5424. let tmpSrc;
  5425. let tmpWidth;
  5426. options = options.trim().split(",");
  5427. const result = options.map((item) => {
  5428. item = item.trim();
  5429. spaceIndex = item.lastIndexOf(" ");
  5430. if (spaceIndex === -1) {
  5431. tmpSrc = item;
  5432. tmpWidth = 999998;
  5433. } else {
  5434. tmpSrc = item.substr(0, spaceIndex);
  5435. tmpWidth = parseInt(
  5436. item.substr(spaceIndex + 1, item.length - spaceIndex - 2),
  5437. 10
  5438. );
  5439. }
  5440. return [tmpWidth, tmpSrc];
  5441. });
  5442. result.sort((a, b) => {
  5443. if (a[0] < b[0]) {
  5444. return 1;
  5445. }
  5446. if (a[0] > b[0]) {
  5447. return -1;
  5448. }
  5449. if (a[0] === b[0]) {
  5450. if (b[1].indexOf(".webp", b[1].length - 5) !== -1) {
  5451. return 1;
  5452. }
  5453. if (a[1].indexOf(".webp", a[1].length - 5) !== -1) {
  5454. return -1;
  5455. }
  5456. }
  5457. return 0;
  5458. });
  5459. let bestSelectedSrc = "";
  5460. let tmpOption;
  5461. for (let i = 0; i < result.length; i++) {
  5462. tmpOption = result[i];
  5463. bestSelectedSrc = tmpOption[1];
  5464. const next = result[i + 1];
  5465. if (next && next[0] < containerWidth) {
  5466. bestSelectedSrc = tmpOption[1];
  5467. break;
  5468. } else if (!next) {
  5469. bestSelectedSrc = tmpOption[1];
  5470. break;
  5471. }
  5472. }
  5473. return bestSelectedSrc;
  5474. }
  5475. const getDPR = (scale = 1) => inBrowser$1 ? window.devicePixelRatio || scale : scale;
  5476. function supportWebp() {
  5477. if (!inBrowser$1)
  5478. return false;
  5479. let support = true;
  5480. try {
  5481. const elem = document.createElement("canvas");
  5482. if (elem.getContext && elem.getContext("2d")) {
  5483. support = elem.toDataURL("image/webp").indexOf("data:image/webp") === 0;
  5484. }
  5485. } catch (err) {
  5486. support = false;
  5487. }
  5488. return support;
  5489. }
  5490. function throttle(action, delay) {
  5491. let timeout = null;
  5492. let lastRun = 0;
  5493. return function(...args) {
  5494. if (timeout) {
  5495. return;
  5496. }
  5497. const elapsed = Date.now() - lastRun;
  5498. const runCallback = () => {
  5499. lastRun = Date.now();
  5500. timeout = false;
  5501. action.apply(this, args);
  5502. };
  5503. if (elapsed >= delay) {
  5504. runCallback();
  5505. } else {
  5506. timeout = setTimeout(runCallback, delay);
  5507. }
  5508. };
  5509. }
  5510. function on(el, type, func) {
  5511. el.addEventListener(type, func, {
  5512. capture: false,
  5513. passive: true
  5514. });
  5515. }
  5516. function off(el, type, func) {
  5517. el.removeEventListener(type, func, false);
  5518. }
  5519. const loadImageAsync = (item, resolve, reject) => {
  5520. const image = new Image();
  5521. if (!item || !item.src) {
  5522. return reject(new Error("image src is required"));
  5523. }
  5524. image.src = item.src;
  5525. if (item.cors) {
  5526. image.crossOrigin = item.cors;
  5527. }
  5528. image.onload = () => resolve({
  5529. naturalHeight: image.naturalHeight,
  5530. naturalWidth: image.naturalWidth,
  5531. src: image.src
  5532. });
  5533. image.onerror = (e) => reject(e);
  5534. };
  5535. class ImageCache {
  5536. constructor({ max }) {
  5537. this.options = {
  5538. max: max || 100
  5539. };
  5540. this.caches = [];
  5541. }
  5542. has(key) {
  5543. return this.caches.indexOf(key) > -1;
  5544. }
  5545. add(key) {
  5546. if (this.has(key))
  5547. return;
  5548. this.caches.push(key);
  5549. if (this.caches.length > this.options.max) {
  5550. this.free();
  5551. }
  5552. }
  5553. free() {
  5554. this.caches.shift();
  5555. }
  5556. }
  5557. const [name$12, bem$_] = createNamespace("back-top");
  5558. const backTopProps = {
  5559. right: numericProp,
  5560. bottom: numericProp,
  5561. target: [String, Object],
  5562. offset: makeNumericProp(200),
  5563. teleport: {
  5564. type: [String, Object],
  5565. default: "body"
  5566. }
  5567. };
  5568. var stdin_default$18 = defineComponent({
  5569. name: name$12,
  5570. inheritAttrs: false,
  5571. props: backTopProps,
  5572. emits: ["click"],
  5573. setup(props, {
  5574. emit,
  5575. slots,
  5576. attrs
  5577. }) {
  5578. const show = ref(false);
  5579. const root = ref();
  5580. const scrollParent = ref();
  5581. const style = computed(() => ({
  5582. right: addUnit(props.right),
  5583. bottom: addUnit(props.bottom)
  5584. }));
  5585. const onClick = (event) => {
  5586. var _a;
  5587. emit("click", event);
  5588. (_a = scrollParent.value) == null ? void 0 : _a.scrollTo({
  5589. top: 0,
  5590. behavior: "smooth"
  5591. });
  5592. };
  5593. const scroll = () => {
  5594. show.value = scrollParent.value ? getScrollTop(scrollParent.value) >= props.offset : false;
  5595. };
  5596. const getTarget = () => {
  5597. const {
  5598. target
  5599. } = props;
  5600. if (typeof target === "string") {
  5601. const el = document.querySelector(target);
  5602. if (el) {
  5603. return el;
  5604. }
  5605. if (process.env.NODE_ENV !== "production") {
  5606. console.error(`[Vant] BackTop: target element "${target}" was not found, the BackTop component will not be rendered.`);
  5607. }
  5608. } else {
  5609. return target;
  5610. }
  5611. };
  5612. const updateTarget = () => {
  5613. if (inBrowser) {
  5614. nextTick(() => {
  5615. scrollParent.value = props.target ? getTarget() : getScrollParent(root.value);
  5616. scroll();
  5617. });
  5618. }
  5619. };
  5620. useEventListener("scroll", throttle(scroll, 100), {
  5621. target: scrollParent
  5622. });
  5623. onMounted(updateTarget);
  5624. watch(() => props.target, updateTarget);
  5625. return () => {
  5626. const Content = createVNode("div", mergeProps({
  5627. "ref": root,
  5628. "class": bem$_({
  5629. active: show.value
  5630. }),
  5631. "style": style.value,
  5632. "onClick": onClick
  5633. }, attrs), [slots.default ? slots.default() : createVNode(Icon, {
  5634. "name": "back-top",
  5635. "class": bem$_("icon")
  5636. }, null)]);
  5637. if (props.teleport) {
  5638. return createVNode(Teleport, {
  5639. "to": props.teleport
  5640. }, {
  5641. default: () => [Content]
  5642. });
  5643. }
  5644. return Content;
  5645. };
  5646. }
  5647. });
  5648. const BackTop = withInstall(stdin_default$18);
  5649. const [name$11, bem$Z, t$f] = createNamespace("calendar");
  5650. const formatMonthTitle = (date) => t$f("monthTitle", date.getFullYear(), date.getMonth() + 1);
  5651. function compareMonth(date1, date2) {
  5652. const year1 = date1.getFullYear();
  5653. const year2 = date2.getFullYear();
  5654. if (year1 === year2) {
  5655. const month1 = date1.getMonth();
  5656. const month2 = date2.getMonth();
  5657. return month1 === month2 ? 0 : month1 > month2 ? 1 : -1;
  5658. }
  5659. return year1 > year2 ? 1 : -1;
  5660. }
  5661. function compareDay(day1, day2) {
  5662. const compareMonthResult = compareMonth(day1, day2);
  5663. if (compareMonthResult === 0) {
  5664. const date1 = day1.getDate();
  5665. const date2 = day2.getDate();
  5666. return date1 === date2 ? 0 : date1 > date2 ? 1 : -1;
  5667. }
  5668. return compareMonthResult;
  5669. }
  5670. const cloneDate = (date) => new Date(date);
  5671. const cloneDates = (dates) => Array.isArray(dates) ? dates.map(cloneDate) : cloneDate(dates);
  5672. function getDayByOffset(date, offset) {
  5673. const cloned = cloneDate(date);
  5674. cloned.setDate(cloned.getDate() + offset);
  5675. return cloned;
  5676. }
  5677. const getPrevDay = (date) => getDayByOffset(date, -1);
  5678. const getNextDay = (date) => getDayByOffset(date, 1);
  5679. const getToday = () => {
  5680. const today = new Date();
  5681. today.setHours(0, 0, 0, 0);
  5682. return today;
  5683. };
  5684. function calcDateNum(date) {
  5685. const day1 = date[0].getTime();
  5686. const day2 = date[1].getTime();
  5687. return (day2 - day1) / (1e3 * 60 * 60 * 24) + 1;
  5688. }
  5689. const sharedProps = extend({}, pickerSharedProps, {
  5690. modelValue: makeArrayProp(),
  5691. filter: Function,
  5692. formatter: {
  5693. type: Function,
  5694. default: (type, option) => option
  5695. }
  5696. });
  5697. const pickerInheritKeys = Object.keys(pickerSharedProps);
  5698. function times(n, iteratee) {
  5699. if (n < 0) {
  5700. return [];
  5701. }
  5702. const result = Array(n);
  5703. let index = -1;
  5704. while (++index < n) {
  5705. result[index] = iteratee(index);
  5706. }
  5707. return result;
  5708. }
  5709. const getMonthEndDay = (year, month) => 32 - new Date(year, month - 1, 32).getDate();
  5710. const genOptions = (min, max, type, formatter, filter) => {
  5711. const options = times(max - min + 1, (index) => {
  5712. const value = padZero(min + index);
  5713. return formatter(type, {
  5714. text: value,
  5715. value
  5716. });
  5717. });
  5718. return filter ? filter(type, options) : options;
  5719. };
  5720. const formatValueRange = (values, columns) => values.map((value, index) => {
  5721. const column = columns[index];
  5722. if (column.length) {
  5723. const maxValue = +column[column.length - 1].value;
  5724. if (+value > maxValue) {
  5725. return String(maxValue);
  5726. }
  5727. }
  5728. return value;
  5729. });
  5730. const [name$10] = createNamespace("calendar-day");
  5731. var stdin_default$17 = defineComponent({
  5732. name: name$10,
  5733. props: {
  5734. item: makeRequiredProp(Object),
  5735. color: String,
  5736. index: Number,
  5737. offset: makeNumberProp(0),
  5738. rowHeight: String
  5739. },
  5740. emits: ["click"],
  5741. setup(props, {
  5742. emit,
  5743. slots
  5744. }) {
  5745. const style = computed(() => {
  5746. var _a;
  5747. const {
  5748. item,
  5749. index,
  5750. color,
  5751. offset,
  5752. rowHeight
  5753. } = props;
  5754. const style2 = {
  5755. height: rowHeight
  5756. };
  5757. if (item.type === "placeholder") {
  5758. style2.width = "100%";
  5759. return style2;
  5760. }
  5761. if (index === 0) {
  5762. style2.marginLeft = `${100 * offset / 7}%`;
  5763. }
  5764. if (color) {
  5765. switch (item.type) {
  5766. case "end":
  5767. case "start":
  5768. case "start-end":
  5769. case "multiple-middle":
  5770. case "multiple-selected":
  5771. style2.background = color;
  5772. break;
  5773. case "middle":
  5774. style2.color = color;
  5775. break;
  5776. }
  5777. }
  5778. if (offset + (((_a = item.date) == null ? void 0 : _a.getDate()) || 1) > 28) {
  5779. style2.marginBottom = 0;
  5780. }
  5781. return style2;
  5782. });
  5783. const onClick = () => {
  5784. if (props.item.type !== "disabled") {
  5785. emit("click", props.item);
  5786. }
  5787. };
  5788. const renderTopInfo = () => {
  5789. const {
  5790. topInfo
  5791. } = props.item;
  5792. if (topInfo || slots["top-info"]) {
  5793. return createVNode("div", {
  5794. "class": bem$Z("top-info")
  5795. }, [slots["top-info"] ? slots["top-info"](props.item) : topInfo]);
  5796. }
  5797. };
  5798. const renderBottomInfo = () => {
  5799. const {
  5800. bottomInfo
  5801. } = props.item;
  5802. if (bottomInfo || slots["bottom-info"]) {
  5803. return createVNode("div", {
  5804. "class": bem$Z("bottom-info")
  5805. }, [slots["bottom-info"] ? slots["bottom-info"](props.item) : bottomInfo]);
  5806. }
  5807. };
  5808. const renderContent = () => {
  5809. const {
  5810. item,
  5811. color,
  5812. rowHeight
  5813. } = props;
  5814. const {
  5815. type,
  5816. text
  5817. } = item;
  5818. const Nodes = [renderTopInfo(), text, renderBottomInfo()];
  5819. if (type === "selected") {
  5820. return createVNode("div", {
  5821. "class": bem$Z("selected-day"),
  5822. "style": {
  5823. width: rowHeight,
  5824. height: rowHeight,
  5825. background: color
  5826. }
  5827. }, [Nodes]);
  5828. }
  5829. return Nodes;
  5830. };
  5831. return () => {
  5832. const {
  5833. type,
  5834. className
  5835. } = props.item;
  5836. if (type === "placeholder") {
  5837. return createVNode("div", {
  5838. "class": bem$Z("day"),
  5839. "style": style.value
  5840. }, null);
  5841. }
  5842. return createVNode("div", {
  5843. "role": "gridcell",
  5844. "style": style.value,
  5845. "class": [bem$Z("day", type), className],
  5846. "tabindex": type === "disabled" ? void 0 : -1,
  5847. "onClick": onClick
  5848. }, [renderContent()]);
  5849. };
  5850. }
  5851. });
  5852. const [name$$] = createNamespace("calendar-month");
  5853. const calendarMonthProps = {
  5854. date: makeRequiredProp(Date),
  5855. type: String,
  5856. color: String,
  5857. minDate: makeRequiredProp(Date),
  5858. maxDate: makeRequiredProp(Date),
  5859. showMark: Boolean,
  5860. rowHeight: numericProp,
  5861. formatter: Function,
  5862. lazyRender: Boolean,
  5863. currentDate: [Date, Array],
  5864. allowSameDay: Boolean,
  5865. showSubtitle: Boolean,
  5866. showMonthTitle: Boolean,
  5867. firstDayOfWeek: Number
  5868. };
  5869. var stdin_default$16 = defineComponent({
  5870. name: name$$,
  5871. props: calendarMonthProps,
  5872. emits: ["click"],
  5873. setup(props, {
  5874. emit,
  5875. slots
  5876. }) {
  5877. const [visible, setVisible] = useToggle();
  5878. const daysRef = ref();
  5879. const monthRef = ref();
  5880. const height = useHeight(monthRef);
  5881. const title = computed(() => formatMonthTitle(props.date));
  5882. const rowHeight = computed(() => addUnit(props.rowHeight));
  5883. const offset = computed(() => {
  5884. const realDay = props.date.getDay();
  5885. if (props.firstDayOfWeek) {
  5886. return (realDay + 7 - props.firstDayOfWeek) % 7;
  5887. }
  5888. return realDay;
  5889. });
  5890. const totalDay = computed(() => getMonthEndDay(props.date.getFullYear(), props.date.getMonth() + 1));
  5891. const shouldRender = computed(() => visible.value || !props.lazyRender);
  5892. const getTitle = () => title.value;
  5893. const getMultipleDayType = (day) => {
  5894. const isSelected = (date) => props.currentDate.some((item) => compareDay(item, date) === 0);
  5895. if (isSelected(day)) {
  5896. const prevDay = getPrevDay(day);
  5897. const nextDay = getNextDay(day);
  5898. const prevSelected = isSelected(prevDay);
  5899. const nextSelected = isSelected(nextDay);
  5900. if (prevSelected && nextSelected) {
  5901. return "multiple-middle";
  5902. }
  5903. if (prevSelected) {
  5904. return "end";
  5905. }
  5906. if (nextSelected) {
  5907. return "start";
  5908. }
  5909. return "multiple-selected";
  5910. }
  5911. return "";
  5912. };
  5913. const getRangeDayType = (day) => {
  5914. const [startDay, endDay] = props.currentDate;
  5915. if (!startDay) {
  5916. return "";
  5917. }
  5918. const compareToStart = compareDay(day, startDay);
  5919. if (!endDay) {
  5920. return compareToStart === 0 ? "start" : "";
  5921. }
  5922. const compareToEnd = compareDay(day, endDay);
  5923. if (props.allowSameDay && compareToStart === 0 && compareToEnd === 0) {
  5924. return "start-end";
  5925. }
  5926. if (compareToStart === 0) {
  5927. return "start";
  5928. }
  5929. if (compareToEnd === 0) {
  5930. return "end";
  5931. }
  5932. if (compareToStart > 0 && compareToEnd < 0) {
  5933. return "middle";
  5934. }
  5935. return "";
  5936. };
  5937. const getDayType = (day) => {
  5938. const {
  5939. type,
  5940. minDate,
  5941. maxDate,
  5942. currentDate
  5943. } = props;
  5944. if (compareDay(day, minDate) < 0 || compareDay(day, maxDate) > 0) {
  5945. return "disabled";
  5946. }
  5947. if (currentDate === null) {
  5948. return "";
  5949. }
  5950. if (Array.isArray(currentDate)) {
  5951. if (type === "multiple") {
  5952. return getMultipleDayType(day);
  5953. }
  5954. if (type === "range") {
  5955. return getRangeDayType(day);
  5956. }
  5957. } else if (type === "single") {
  5958. return compareDay(day, currentDate) === 0 ? "selected" : "";
  5959. }
  5960. return "";
  5961. };
  5962. const getBottomInfo = (dayType) => {
  5963. if (props.type === "range") {
  5964. if (dayType === "start" || dayType === "end") {
  5965. return t$f(dayType);
  5966. }
  5967. if (dayType === "start-end") {
  5968. return `${t$f("start")}/${t$f("end")}`;
  5969. }
  5970. }
  5971. };
  5972. const renderTitle = () => {
  5973. if (props.showMonthTitle) {
  5974. return createVNode("div", {
  5975. "class": bem$Z("month-title")
  5976. }, [title.value]);
  5977. }
  5978. };
  5979. const renderMark = () => {
  5980. if (props.showMark && shouldRender.value) {
  5981. return createVNode("div", {
  5982. "class": bem$Z("month-mark")
  5983. }, [props.date.getMonth() + 1]);
  5984. }
  5985. };
  5986. const placeholders = computed(() => {
  5987. const count = Math.ceil((totalDay.value + offset.value) / 7);
  5988. return Array(count).fill({
  5989. type: "placeholder"
  5990. });
  5991. });
  5992. const days = computed(() => {
  5993. const days2 = [];
  5994. const year = props.date.getFullYear();
  5995. const month = props.date.getMonth();
  5996. for (let day = 1; day <= totalDay.value; day++) {
  5997. const date = new Date(year, month, day);
  5998. const type = getDayType(date);
  5999. let config = {
  6000. date,
  6001. type,
  6002. text: day,
  6003. bottomInfo: getBottomInfo(type)
  6004. };
  6005. if (props.formatter) {
  6006. config = props.formatter(config);
  6007. }
  6008. days2.push(config);
  6009. }
  6010. return days2;
  6011. });
  6012. const disabledDays = computed(() => days.value.filter((day) => day.type === "disabled"));
  6013. const scrollToDate = (body, targetDate) => {
  6014. if (daysRef.value) {
  6015. const daysRect = useRect(daysRef.value);
  6016. const totalRows = placeholders.value.length;
  6017. const currentRow = Math.ceil((targetDate.getDate() + offset.value) / 7);
  6018. const rowOffset = (currentRow - 1) * daysRect.height / totalRows;
  6019. setScrollTop(body, daysRect.top + rowOffset + body.scrollTop - useRect(body).top);
  6020. }
  6021. };
  6022. const renderDay = (item, index) => createVNode(stdin_default$17, {
  6023. "item": item,
  6024. "index": index,
  6025. "color": props.color,
  6026. "offset": offset.value,
  6027. "rowHeight": rowHeight.value,
  6028. "onClick": (item2) => emit("click", item2)
  6029. }, pick(slots, ["top-info", "bottom-info"]));
  6030. const renderDays = () => createVNode("div", {
  6031. "ref": daysRef,
  6032. "role": "grid",
  6033. "class": bem$Z("days")
  6034. }, [renderMark(), (shouldRender.value ? days : placeholders).value.map(renderDay)]);
  6035. useExpose({
  6036. getTitle,
  6037. getHeight: () => height.value,
  6038. setVisible,
  6039. scrollToDate,
  6040. disabledDays
  6041. });
  6042. return () => createVNode("div", {
  6043. "class": bem$Z("month"),
  6044. "ref": monthRef
  6045. }, [renderTitle(), renderDays()]);
  6046. }
  6047. });
  6048. const [name$_] = createNamespace("calendar-header");
  6049. var stdin_default$15 = defineComponent({
  6050. name: name$_,
  6051. props: {
  6052. date: Date,
  6053. title: String,
  6054. subtitle: String,
  6055. showTitle: Boolean,
  6056. showSubtitle: Boolean,
  6057. firstDayOfWeek: Number
  6058. },
  6059. emits: ["clickSubtitle"],
  6060. setup(props, {
  6061. slots,
  6062. emit
  6063. }) {
  6064. const renderTitle = () => {
  6065. if (props.showTitle) {
  6066. const text = props.title || t$f("title");
  6067. const title = slots.title ? slots.title() : text;
  6068. return createVNode("div", {
  6069. "class": bem$Z("header-title")
  6070. }, [title]);
  6071. }
  6072. };
  6073. const onClickSubtitle = (event) => emit("clickSubtitle", event);
  6074. const renderSubtitle = () => {
  6075. if (props.showSubtitle) {
  6076. const title = slots.subtitle ? slots.subtitle({
  6077. date: props.date,
  6078. text: props.subtitle
  6079. }) : props.subtitle;
  6080. return createVNode("div", {
  6081. "class": bem$Z("header-subtitle"),
  6082. "onClick": onClickSubtitle
  6083. }, [title]);
  6084. }
  6085. };
  6086. const renderWeekDays = () => {
  6087. const {
  6088. firstDayOfWeek
  6089. } = props;
  6090. const weekdays = t$f("weekdays");
  6091. const renderWeekDays2 = [...weekdays.slice(firstDayOfWeek, 7), ...weekdays.slice(0, firstDayOfWeek)];
  6092. return createVNode("div", {
  6093. "class": bem$Z("weekdays")
  6094. }, [renderWeekDays2.map((text) => createVNode("span", {
  6095. "class": bem$Z("weekday")
  6096. }, [text]))]);
  6097. };
  6098. return () => createVNode("div", {
  6099. "class": bem$Z("header")
  6100. }, [renderTitle(), renderSubtitle(), renderWeekDays()]);
  6101. }
  6102. });
  6103. const calendarProps = {
  6104. show: Boolean,
  6105. type: makeStringProp("single"),
  6106. title: String,
  6107. color: String,
  6108. round: truthProp,
  6109. readonly: Boolean,
  6110. poppable: truthProp,
  6111. maxRange: makeNumericProp(null),
  6112. position: makeStringProp("bottom"),
  6113. teleport: [String, Object],
  6114. showMark: truthProp,
  6115. showTitle: truthProp,
  6116. formatter: Function,
  6117. rowHeight: numericProp,
  6118. confirmText: String,
  6119. rangePrompt: String,
  6120. lazyRender: truthProp,
  6121. showConfirm: truthProp,
  6122. defaultDate: [Date, Array],
  6123. allowSameDay: Boolean,
  6124. showSubtitle: truthProp,
  6125. closeOnPopstate: truthProp,
  6126. showRangePrompt: truthProp,
  6127. confirmDisabledText: String,
  6128. closeOnClickOverlay: truthProp,
  6129. safeAreaInsetTop: Boolean,
  6130. safeAreaInsetBottom: truthProp,
  6131. minDate: {
  6132. type: Date,
  6133. validator: isDate,
  6134. default: getToday
  6135. },
  6136. maxDate: {
  6137. type: Date,
  6138. validator: isDate,
  6139. default: () => {
  6140. const now = getToday();
  6141. return new Date(now.getFullYear(), now.getMonth() + 6, now.getDate());
  6142. }
  6143. },
  6144. firstDayOfWeek: {
  6145. type: numericProp,
  6146. default: 0,
  6147. validator: (val) => val >= 0 && val <= 6
  6148. }
  6149. };
  6150. var stdin_default$14 = defineComponent({
  6151. name: name$11,
  6152. props: calendarProps,
  6153. emits: ["select", "confirm", "unselect", "monthShow", "overRange", "update:show", "clickSubtitle"],
  6154. setup(props, {
  6155. emit,
  6156. slots
  6157. }) {
  6158. const limitDateRange = (date, minDate = props.minDate, maxDate = props.maxDate) => {
  6159. if (compareDay(date, minDate) === -1) {
  6160. return minDate;
  6161. }
  6162. if (compareDay(date, maxDate) === 1) {
  6163. return maxDate;
  6164. }
  6165. return date;
  6166. };
  6167. const getInitialDate = (defaultDate = props.defaultDate) => {
  6168. const {
  6169. type,
  6170. minDate,
  6171. maxDate,
  6172. allowSameDay
  6173. } = props;
  6174. if (defaultDate === null) {
  6175. return defaultDate;
  6176. }
  6177. const now = getToday();
  6178. if (type === "range") {
  6179. if (!Array.isArray(defaultDate)) {
  6180. defaultDate = [];
  6181. }
  6182. const start = limitDateRange(defaultDate[0] || now, minDate, allowSameDay ? maxDate : getPrevDay(maxDate));
  6183. const end = limitDateRange(defaultDate[1] || now, allowSameDay ? minDate : getNextDay(minDate));
  6184. return [start, end];
  6185. }
  6186. if (type === "multiple") {
  6187. if (Array.isArray(defaultDate)) {
  6188. return defaultDate.map((date) => limitDateRange(date));
  6189. }
  6190. return [limitDateRange(now)];
  6191. }
  6192. if (!defaultDate || Array.isArray(defaultDate)) {
  6193. defaultDate = now;
  6194. }
  6195. return limitDateRange(defaultDate);
  6196. };
  6197. let bodyHeight;
  6198. const bodyRef = ref();
  6199. const subtitle = ref({
  6200. text: "",
  6201. date: void 0
  6202. });
  6203. const currentDate = ref(getInitialDate());
  6204. const [monthRefs, setMonthRefs] = useRefs();
  6205. const dayOffset = computed(() => props.firstDayOfWeek ? +props.firstDayOfWeek % 7 : 0);
  6206. const months = computed(() => {
  6207. const months2 = [];
  6208. const cursor = new Date(props.minDate);
  6209. cursor.setDate(1);
  6210. do {
  6211. months2.push(new Date(cursor));
  6212. cursor.setMonth(cursor.getMonth() + 1);
  6213. } while (compareMonth(cursor, props.maxDate) !== 1);
  6214. return months2;
  6215. });
  6216. const buttonDisabled = computed(() => {
  6217. if (currentDate.value) {
  6218. if (props.type === "range") {
  6219. return !currentDate.value[0] || !currentDate.value[1];
  6220. }
  6221. if (props.type === "multiple") {
  6222. return !currentDate.value.length;
  6223. }
  6224. }
  6225. return !currentDate.value;
  6226. });
  6227. const getSelectedDate = () => currentDate.value;
  6228. const onScroll = () => {
  6229. const top = getScrollTop(bodyRef.value);
  6230. const bottom = top + bodyHeight;
  6231. const heights = months.value.map((item, index) => monthRefs.value[index].getHeight());
  6232. const heightSum = heights.reduce((a, b) => a + b, 0);
  6233. if (bottom > heightSum && top > 0) {
  6234. return;
  6235. }
  6236. let height = 0;
  6237. let currentMonth;
  6238. const visibleRange = [-1, -1];
  6239. for (let i = 0; i < months.value.length; i++) {
  6240. const month = monthRefs.value[i];
  6241. const visible = height <= bottom && height + heights[i] >= top;
  6242. if (visible) {
  6243. visibleRange[1] = i;
  6244. if (!currentMonth) {
  6245. currentMonth = month;
  6246. visibleRange[0] = i;
  6247. }
  6248. if (!monthRefs.value[i].showed) {
  6249. monthRefs.value[i].showed = true;
  6250. emit("monthShow", {
  6251. date: month.date,
  6252. title: month.getTitle()
  6253. });
  6254. }
  6255. }
  6256. height += heights[i];
  6257. }
  6258. months.value.forEach((month, index) => {
  6259. const visible = index >= visibleRange[0] - 1 && index <= visibleRange[1] + 1;
  6260. monthRefs.value[index].setVisible(visible);
  6261. });
  6262. if (currentMonth) {
  6263. subtitle.value = {
  6264. text: currentMonth.getTitle(),
  6265. date: currentMonth.date
  6266. };
  6267. }
  6268. };
  6269. const scrollToDate = (targetDate) => {
  6270. raf(() => {
  6271. months.value.some((month, index) => {
  6272. if (compareMonth(month, targetDate) === 0) {
  6273. if (bodyRef.value) {
  6274. monthRefs.value[index].scrollToDate(bodyRef.value, targetDate);
  6275. }
  6276. return true;
  6277. }
  6278. return false;
  6279. });
  6280. onScroll();
  6281. });
  6282. };
  6283. const scrollToCurrentDate = () => {
  6284. if (props.poppable && !props.show) {
  6285. return;
  6286. }
  6287. if (currentDate.value) {
  6288. const targetDate = props.type === "single" ? currentDate.value : currentDate.value[0];
  6289. if (isDate(targetDate)) {
  6290. scrollToDate(targetDate);
  6291. }
  6292. } else {
  6293. raf(onScroll);
  6294. }
  6295. };
  6296. const init = () => {
  6297. if (props.poppable && !props.show) {
  6298. return;
  6299. }
  6300. raf(() => {
  6301. bodyHeight = Math.floor(useRect(bodyRef).height);
  6302. });
  6303. scrollToCurrentDate();
  6304. };
  6305. const reset = (date = getInitialDate()) => {
  6306. currentDate.value = date;
  6307. scrollToCurrentDate();
  6308. };
  6309. const checkRange = (date) => {
  6310. const {
  6311. maxRange,
  6312. rangePrompt,
  6313. showRangePrompt
  6314. } = props;
  6315. if (maxRange && calcDateNum(date) > maxRange) {
  6316. if (showRangePrompt) {
  6317. showToast(rangePrompt || t$f("rangePrompt", maxRange));
  6318. }
  6319. emit("overRange");
  6320. return false;
  6321. }
  6322. return true;
  6323. };
  6324. const onConfirm = () => {
  6325. var _a;
  6326. return emit("confirm", (_a = currentDate.value) != null ? _a : cloneDates(currentDate.value));
  6327. };
  6328. const select = (date, complete) => {
  6329. const setCurrentDate = (date2) => {
  6330. currentDate.value = date2;
  6331. emit("select", cloneDates(date2));
  6332. };
  6333. if (complete && props.type === "range") {
  6334. const valid = checkRange(date);
  6335. if (!valid) {
  6336. setCurrentDate([date[0], getDayByOffset(date[0], +props.maxRange - 1)]);
  6337. return;
  6338. }
  6339. }
  6340. setCurrentDate(date);
  6341. if (complete && !props.showConfirm) {
  6342. onConfirm();
  6343. }
  6344. };
  6345. const getDisabledDate = (disabledDays2, startDay, date) => {
  6346. var _a;
  6347. return (_a = disabledDays2.find((day) => compareDay(startDay, day.date) === -1 && compareDay(day.date, date) === -1)) == null ? void 0 : _a.date;
  6348. };
  6349. const disabledDays = computed(() => monthRefs.value.reduce((arr, ref2) => {
  6350. var _a, _b;
  6351. arr.push(...(_b = (_a = ref2.disabledDays) == null ? void 0 : _a.value) != null ? _b : []);
  6352. return arr;
  6353. }, []));
  6354. const onClickDay = (item) => {
  6355. if (props.readonly || !item.date) {
  6356. return;
  6357. }
  6358. const {
  6359. date
  6360. } = item;
  6361. const {
  6362. type
  6363. } = props;
  6364. if (type === "range") {
  6365. if (!currentDate.value) {
  6366. select([date]);
  6367. return;
  6368. }
  6369. const [startDay, endDay] = currentDate.value;
  6370. if (startDay && !endDay) {
  6371. const compareToStart = compareDay(date, startDay);
  6372. if (compareToStart === 1) {
  6373. const disabledDay = getDisabledDate(disabledDays.value, startDay, date);
  6374. if (disabledDay) {
  6375. const endDay2 = getPrevDay(disabledDay);
  6376. if (compareDay(startDay, endDay2) === -1) {
  6377. select([startDay, endDay2]);
  6378. } else {
  6379. select([date]);
  6380. }
  6381. } else {
  6382. select([startDay, date], true);
  6383. }
  6384. } else if (compareToStart === -1) {
  6385. select([date]);
  6386. } else if (props.allowSameDay) {
  6387. select([date, date], true);
  6388. }
  6389. } else {
  6390. select([date]);
  6391. }
  6392. } else if (type === "multiple") {
  6393. if (!currentDate.value) {
  6394. select([date]);
  6395. return;
  6396. }
  6397. const dates = currentDate.value;
  6398. const selectedIndex = dates.findIndex((dateItem) => compareDay(dateItem, date) === 0);
  6399. if (selectedIndex !== -1) {
  6400. const [unselectedDate] = dates.splice(selectedIndex, 1);
  6401. emit("unselect", cloneDate(unselectedDate));
  6402. } else if (props.maxRange && dates.length >= props.maxRange) {
  6403. showToast(props.rangePrompt || t$f("rangePrompt", props.maxRange));
  6404. } else {
  6405. select([...dates, date]);
  6406. }
  6407. } else {
  6408. select(date, true);
  6409. }
  6410. };
  6411. const updateShow = (value) => emit("update:show", value);
  6412. const renderMonth = (date, index) => {
  6413. const showMonthTitle = index !== 0 || !props.showSubtitle;
  6414. return createVNode(stdin_default$16, mergeProps({
  6415. "ref": setMonthRefs(index),
  6416. "date": date,
  6417. "currentDate": currentDate.value,
  6418. "showMonthTitle": showMonthTitle,
  6419. "firstDayOfWeek": dayOffset.value
  6420. }, pick(props, ["type", "color", "minDate", "maxDate", "showMark", "formatter", "rowHeight", "lazyRender", "showSubtitle", "allowSameDay"]), {
  6421. "onClick": onClickDay
  6422. }), pick(slots, ["top-info", "bottom-info"]));
  6423. };
  6424. const renderFooterButton = () => {
  6425. if (slots.footer) {
  6426. return slots.footer();
  6427. }
  6428. if (props.showConfirm) {
  6429. const slot = slots["confirm-text"];
  6430. const disabled = buttonDisabled.value;
  6431. const text = disabled ? props.confirmDisabledText : props.confirmText;
  6432. return createVNode(Button, {
  6433. "round": true,
  6434. "block": true,
  6435. "type": "primary",
  6436. "color": props.color,
  6437. "class": bem$Z("confirm"),
  6438. "disabled": disabled,
  6439. "nativeType": "button",
  6440. "onClick": onConfirm
  6441. }, {
  6442. default: () => [slot ? slot({
  6443. disabled
  6444. }) : text || t$f("confirm")]
  6445. });
  6446. }
  6447. };
  6448. const renderFooter = () => createVNode("div", {
  6449. "class": [bem$Z("footer"), {
  6450. "van-safe-area-bottom": props.safeAreaInsetBottom
  6451. }]
  6452. }, [renderFooterButton()]);
  6453. const renderCalendar = () => createVNode("div", {
  6454. "class": bem$Z()
  6455. }, [createVNode(stdin_default$15, {
  6456. "date": subtitle.value.date,
  6457. "title": props.title,
  6458. "subtitle": subtitle.value.text,
  6459. "showTitle": props.showTitle,
  6460. "showSubtitle": props.showSubtitle,
  6461. "firstDayOfWeek": dayOffset.value,
  6462. "onClickSubtitle": (event) => emit("clickSubtitle", event)
  6463. }, pick(slots, ["title", "subtitle"])), createVNode("div", {
  6464. "ref": bodyRef,
  6465. "class": bem$Z("body"),
  6466. "onScroll": onScroll
  6467. }, [months.value.map(renderMonth)]), renderFooter()]);
  6468. watch(() => props.show, init);
  6469. watch(() => [props.type, props.minDate, props.maxDate], () => reset(getInitialDate(currentDate.value)));
  6470. watch(() => props.defaultDate, (value = null) => {
  6471. currentDate.value = value;
  6472. scrollToCurrentDate();
  6473. });
  6474. useExpose({
  6475. reset,
  6476. scrollToDate,
  6477. getSelectedDate
  6478. });
  6479. onMountedOrActivated(init);
  6480. return () => {
  6481. if (props.poppable) {
  6482. return createVNode(Popup, {
  6483. "show": props.show,
  6484. "class": bem$Z("popup"),
  6485. "round": props.round,
  6486. "position": props.position,
  6487. "closeable": props.showTitle || props.showSubtitle,
  6488. "teleport": props.teleport,
  6489. "closeOnPopstate": props.closeOnPopstate,
  6490. "safeAreaInsetTop": props.safeAreaInsetTop,
  6491. "closeOnClickOverlay": props.closeOnClickOverlay,
  6492. "onUpdate:show": updateShow
  6493. }, {
  6494. default: renderCalendar
  6495. });
  6496. }
  6497. return renderCalendar();
  6498. };
  6499. }
  6500. });
  6501. const Calendar = withInstall(stdin_default$14);
  6502. const [name$Z, bem$Y] = createNamespace("image");
  6503. const imageProps = {
  6504. src: String,
  6505. alt: String,
  6506. fit: String,
  6507. position: String,
  6508. round: Boolean,
  6509. block: Boolean,
  6510. width: numericProp,
  6511. height: numericProp,
  6512. radius: numericProp,
  6513. lazyLoad: Boolean,
  6514. iconSize: numericProp,
  6515. showError: truthProp,
  6516. errorIcon: makeStringProp("photo-fail"),
  6517. iconPrefix: String,
  6518. showLoading: truthProp,
  6519. loadingIcon: makeStringProp("photo")
  6520. };
  6521. var stdin_default$13 = defineComponent({
  6522. name: name$Z,
  6523. props: imageProps,
  6524. emits: ["load", "error"],
  6525. setup(props, {
  6526. emit,
  6527. slots
  6528. }) {
  6529. const error = ref(false);
  6530. const loading = ref(true);
  6531. const imageRef = ref();
  6532. const {
  6533. $Lazyload
  6534. } = getCurrentInstance().proxy;
  6535. const style = computed(() => {
  6536. const style2 = {
  6537. width: addUnit(props.width),
  6538. height: addUnit(props.height)
  6539. };
  6540. if (isDef(props.radius)) {
  6541. style2.overflow = "hidden";
  6542. style2.borderRadius = addUnit(props.radius);
  6543. }
  6544. return style2;
  6545. });
  6546. watch(() => props.src, () => {
  6547. error.value = false;
  6548. loading.value = true;
  6549. });
  6550. const onLoad = (event) => {
  6551. if (loading.value) {
  6552. loading.value = false;
  6553. emit("load", event);
  6554. }
  6555. };
  6556. const triggerLoad = () => {
  6557. const loadEvent = new Event("load");
  6558. Object.defineProperty(loadEvent, "target", {
  6559. value: imageRef.value,
  6560. enumerable: true
  6561. });
  6562. onLoad(loadEvent);
  6563. };
  6564. const onError = (event) => {
  6565. error.value = true;
  6566. loading.value = false;
  6567. emit("error", event);
  6568. };
  6569. const renderIcon = (name2, className, slot) => {
  6570. if (slot) {
  6571. return slot();
  6572. }
  6573. return createVNode(Icon, {
  6574. "name": name2,
  6575. "size": props.iconSize,
  6576. "class": className,
  6577. "classPrefix": props.iconPrefix
  6578. }, null);
  6579. };
  6580. const renderPlaceholder = () => {
  6581. if (loading.value && props.showLoading) {
  6582. return createVNode("div", {
  6583. "class": bem$Y("loading")
  6584. }, [renderIcon(props.loadingIcon, bem$Y("loading-icon"), slots.loading)]);
  6585. }
  6586. if (error.value && props.showError) {
  6587. return createVNode("div", {
  6588. "class": bem$Y("error")
  6589. }, [renderIcon(props.errorIcon, bem$Y("error-icon"), slots.error)]);
  6590. }
  6591. };
  6592. const renderImage = () => {
  6593. if (error.value || !props.src) {
  6594. return;
  6595. }
  6596. const attrs = {
  6597. alt: props.alt,
  6598. class: bem$Y("img"),
  6599. style: {
  6600. objectFit: props.fit,
  6601. objectPosition: props.position
  6602. }
  6603. };
  6604. if (props.lazyLoad) {
  6605. return withDirectives(createVNode("img", mergeProps({
  6606. "ref": imageRef
  6607. }, attrs), null), [[resolveDirective("lazy"), props.src]]);
  6608. }
  6609. return createVNode("img", mergeProps({
  6610. "ref": imageRef,
  6611. "src": props.src,
  6612. "onLoad": onLoad,
  6613. "onError": onError
  6614. }, attrs), null);
  6615. };
  6616. const onLazyLoaded = ({
  6617. el
  6618. }) => {
  6619. const check = () => {
  6620. if (el === imageRef.value && loading.value) {
  6621. triggerLoad();
  6622. }
  6623. };
  6624. if (imageRef.value) {
  6625. check();
  6626. } else {
  6627. nextTick(check);
  6628. }
  6629. };
  6630. const onLazyLoadError = ({
  6631. el
  6632. }) => {
  6633. if (el === imageRef.value && !error.value) {
  6634. onError();
  6635. }
  6636. };
  6637. if ($Lazyload && inBrowser) {
  6638. $Lazyload.$on("loaded", onLazyLoaded);
  6639. $Lazyload.$on("error", onLazyLoadError);
  6640. onBeforeUnmount(() => {
  6641. $Lazyload.$off("loaded", onLazyLoaded);
  6642. $Lazyload.$off("error", onLazyLoadError);
  6643. });
  6644. }
  6645. onMounted(() => {
  6646. nextTick(() => {
  6647. var _a;
  6648. if ((_a = imageRef.value) == null ? void 0 : _a.complete) {
  6649. triggerLoad();
  6650. }
  6651. });
  6652. });
  6653. return () => {
  6654. var _a;
  6655. return createVNode("div", {
  6656. "class": bem$Y({
  6657. round: props.round,
  6658. block: props.block
  6659. }),
  6660. "style": style.value
  6661. }, [renderImage(), renderPlaceholder(), (_a = slots.default) == null ? void 0 : _a.call(slots)]);
  6662. };
  6663. }
  6664. });
  6665. const Image$1 = withInstall(stdin_default$13);
  6666. const [name$Y, bem$X] = createNamespace("card");
  6667. const cardProps = {
  6668. tag: String,
  6669. num: numericProp,
  6670. desc: String,
  6671. thumb: String,
  6672. title: String,
  6673. price: numericProp,
  6674. centered: Boolean,
  6675. lazyLoad: Boolean,
  6676. currency: makeStringProp("\xA5"),
  6677. thumbLink: String,
  6678. originPrice: numericProp
  6679. };
  6680. var stdin_default$12 = defineComponent({
  6681. name: name$Y,
  6682. props: cardProps,
  6683. emits: ["clickThumb"],
  6684. setup(props, {
  6685. slots,
  6686. emit
  6687. }) {
  6688. const renderTitle = () => {
  6689. if (slots.title) {
  6690. return slots.title();
  6691. }
  6692. if (props.title) {
  6693. return createVNode("div", {
  6694. "class": [bem$X("title"), "van-multi-ellipsis--l2"]
  6695. }, [props.title]);
  6696. }
  6697. };
  6698. const renderThumbTag = () => {
  6699. if (slots.tag || props.tag) {
  6700. return createVNode("div", {
  6701. "class": bem$X("tag")
  6702. }, [slots.tag ? slots.tag() : createVNode(Tag, {
  6703. "mark": true,
  6704. "type": "primary"
  6705. }, {
  6706. default: () => [props.tag]
  6707. })]);
  6708. }
  6709. };
  6710. const renderThumbImage = () => {
  6711. if (slots.thumb) {
  6712. return slots.thumb();
  6713. }
  6714. return createVNode(Image$1, {
  6715. "src": props.thumb,
  6716. "fit": "cover",
  6717. "width": "100%",
  6718. "height": "100%",
  6719. "lazyLoad": props.lazyLoad
  6720. }, null);
  6721. };
  6722. const renderThumb = () => {
  6723. if (slots.thumb || props.thumb) {
  6724. return createVNode("a", {
  6725. "href": props.thumbLink,
  6726. "class": bem$X("thumb"),
  6727. "onClick": (event) => emit("clickThumb", event)
  6728. }, [renderThumbImage(), renderThumbTag()]);
  6729. }
  6730. };
  6731. const renderDesc = () => {
  6732. if (slots.desc) {
  6733. return slots.desc();
  6734. }
  6735. if (props.desc) {
  6736. return createVNode("div", {
  6737. "class": [bem$X("desc"), "van-ellipsis"]
  6738. }, [props.desc]);
  6739. }
  6740. };
  6741. const renderPriceText = () => {
  6742. const priceArr = props.price.toString().split(".");
  6743. return createVNode("div", null, [createVNode("span", {
  6744. "class": bem$X("price-currency")
  6745. }, [props.currency]), createVNode("span", {
  6746. "class": bem$X("price-integer")
  6747. }, [priceArr[0]]), createTextVNode("."), createVNode("span", {
  6748. "class": bem$X("price-decimal")
  6749. }, [priceArr[1]])]);
  6750. };
  6751. return () => {
  6752. var _a, _b, _c;
  6753. const showNum = slots.num || isDef(props.num);
  6754. const showPrice = slots.price || isDef(props.price);
  6755. const showOriginPrice = slots["origin-price"] || isDef(props.originPrice);
  6756. const showBottom = showNum || showPrice || showOriginPrice || slots.bottom;
  6757. const Price = showPrice && createVNode("div", {
  6758. "class": bem$X("price")
  6759. }, [slots.price ? slots.price() : renderPriceText()]);
  6760. const OriginPrice = showOriginPrice && createVNode("div", {
  6761. "class": bem$X("origin-price")
  6762. }, [slots["origin-price"] ? slots["origin-price"]() : `${props.currency} ${props.originPrice}`]);
  6763. const Num = showNum && createVNode("div", {
  6764. "class": bem$X("num")
  6765. }, [slots.num ? slots.num() : `x${props.num}`]);
  6766. const Footer = slots.footer && createVNode("div", {
  6767. "class": bem$X("footer")
  6768. }, [slots.footer()]);
  6769. const Bottom = showBottom && createVNode("div", {
  6770. "class": bem$X("bottom")
  6771. }, [(_a = slots["price-top"]) == null ? void 0 : _a.call(slots), Price, OriginPrice, Num, (_b = slots.bottom) == null ? void 0 : _b.call(slots)]);
  6772. return createVNode("div", {
  6773. "class": bem$X()
  6774. }, [createVNode("div", {
  6775. "class": bem$X("header")
  6776. }, [renderThumb(), createVNode("div", {
  6777. "class": bem$X("content", {
  6778. centered: props.centered
  6779. })
  6780. }, [createVNode("div", null, [renderTitle(), renderDesc(), (_c = slots.tags) == null ? void 0 : _c.call(slots)]), Bottom])]), Footer]);
  6781. };
  6782. }
  6783. });
  6784. const Card = withInstall(stdin_default$12);
  6785. const [name$X, bem$W, t$e] = createNamespace("cascader");
  6786. const cascaderProps = {
  6787. title: String,
  6788. options: makeArrayProp(),
  6789. closeable: truthProp,
  6790. swipeable: truthProp,
  6791. closeIcon: makeStringProp("cross"),
  6792. showHeader: truthProp,
  6793. modelValue: numericProp,
  6794. fieldNames: Object,
  6795. placeholder: String,
  6796. activeColor: String
  6797. };
  6798. var stdin_default$11 = defineComponent({
  6799. name: name$X,
  6800. props: cascaderProps,
  6801. emits: ["close", "change", "finish", "clickTab", "update:modelValue"],
  6802. setup(props, {
  6803. slots,
  6804. emit
  6805. }) {
  6806. const tabs = ref([]);
  6807. const activeTab = ref(0);
  6808. const {
  6809. text: textKey,
  6810. value: valueKey,
  6811. children: childrenKey
  6812. } = extend({
  6813. text: "text",
  6814. value: "value",
  6815. children: "children"
  6816. }, props.fieldNames);
  6817. const getSelectedOptionsByValue = (options, value) => {
  6818. for (const option of options) {
  6819. if (option[valueKey] === value) {
  6820. return [option];
  6821. }
  6822. if (option[childrenKey]) {
  6823. const selectedOptions = getSelectedOptionsByValue(option[childrenKey], value);
  6824. if (selectedOptions) {
  6825. return [option, ...selectedOptions];
  6826. }
  6827. }
  6828. }
  6829. };
  6830. const updateTabs = () => {
  6831. const {
  6832. options,
  6833. modelValue
  6834. } = props;
  6835. if (modelValue !== void 0) {
  6836. const selectedOptions = getSelectedOptionsByValue(options, modelValue);
  6837. if (selectedOptions) {
  6838. let optionsCursor = options;
  6839. tabs.value = selectedOptions.map((option) => {
  6840. const tab = {
  6841. options: optionsCursor,
  6842. selected: option
  6843. };
  6844. const next = optionsCursor.find((item) => item[valueKey] === option[valueKey]);
  6845. if (next) {
  6846. optionsCursor = next[childrenKey];
  6847. }
  6848. return tab;
  6849. });
  6850. if (optionsCursor) {
  6851. tabs.value.push({
  6852. options: optionsCursor,
  6853. selected: null
  6854. });
  6855. }
  6856. nextTick(() => {
  6857. activeTab.value = tabs.value.length - 1;
  6858. });
  6859. return;
  6860. }
  6861. }
  6862. tabs.value = [{
  6863. options,
  6864. selected: null
  6865. }];
  6866. };
  6867. const onSelect = (option, tabIndex) => {
  6868. if (option.disabled) {
  6869. return;
  6870. }
  6871. tabs.value[tabIndex].selected = option;
  6872. if (tabs.value.length > tabIndex + 1) {
  6873. tabs.value = tabs.value.slice(0, tabIndex + 1);
  6874. }
  6875. if (option[childrenKey]) {
  6876. const nextTab = {
  6877. options: option[childrenKey],
  6878. selected: null
  6879. };
  6880. if (tabs.value[tabIndex + 1]) {
  6881. tabs.value[tabIndex + 1] = nextTab;
  6882. } else {
  6883. tabs.value.push(nextTab);
  6884. }
  6885. nextTick(() => {
  6886. activeTab.value++;
  6887. });
  6888. }
  6889. const selectedOptions = tabs.value.map((tab) => tab.selected).filter(Boolean);
  6890. emit("update:modelValue", option[valueKey]);
  6891. const params = {
  6892. value: option[valueKey],
  6893. tabIndex,
  6894. selectedOptions
  6895. };
  6896. emit("change", params);
  6897. if (!option[childrenKey]) {
  6898. emit("finish", params);
  6899. }
  6900. };
  6901. const onClose = () => emit("close");
  6902. const onClickTab = ({
  6903. name: name2,
  6904. title
  6905. }) => emit("clickTab", name2, title);
  6906. const renderHeader = () => props.showHeader ? createVNode("div", {
  6907. "class": bem$W("header")
  6908. }, [createVNode("h2", {
  6909. "class": bem$W("title")
  6910. }, [slots.title ? slots.title() : props.title]), props.closeable ? createVNode(Icon, {
  6911. "name": props.closeIcon,
  6912. "class": [bem$W("close-icon"), HAPTICS_FEEDBACK],
  6913. "onClick": onClose
  6914. }, null) : null]) : null;
  6915. const renderOption = (option, selectedOption, tabIndex) => {
  6916. const {
  6917. disabled
  6918. } = option;
  6919. const selected = !!(selectedOption && option[valueKey] === selectedOption[valueKey]);
  6920. const color = option.color || (selected ? props.activeColor : void 0);
  6921. const Text2 = slots.option ? slots.option({
  6922. option,
  6923. selected
  6924. }) : createVNode("span", null, [option[textKey]]);
  6925. return createVNode("li", {
  6926. "role": "menuitemradio",
  6927. "class": [bem$W("option", {
  6928. selected,
  6929. disabled
  6930. }), option.className],
  6931. "style": {
  6932. color
  6933. },
  6934. "tabindex": disabled ? void 0 : selected ? 0 : -1,
  6935. "aria-checked": selected,
  6936. "aria-disabled": disabled || void 0,
  6937. "onClick": () => onSelect(option, tabIndex)
  6938. }, [Text2, selected ? createVNode(Icon, {
  6939. "name": "success",
  6940. "class": bem$W("selected-icon")
  6941. }, null) : null]);
  6942. };
  6943. const renderOptions = (options, selectedOption, tabIndex) => createVNode("ul", {
  6944. "role": "menu",
  6945. "class": bem$W("options")
  6946. }, [options.map((option) => renderOption(option, selectedOption, tabIndex))]);
  6947. const renderTab = (tab, tabIndex) => {
  6948. const {
  6949. options,
  6950. selected
  6951. } = tab;
  6952. const placeholder = props.placeholder || t$e("select");
  6953. const title = selected ? selected[textKey] : placeholder;
  6954. return createVNode(Tab, {
  6955. "title": title,
  6956. "titleClass": bem$W("tab", {
  6957. unselected: !selected
  6958. })
  6959. }, {
  6960. default: () => {
  6961. var _a, _b;
  6962. return [(_a = slots["options-top"]) == null ? void 0 : _a.call(slots, {
  6963. tabIndex
  6964. }), renderOptions(options, selected, tabIndex), (_b = slots["options-bottom"]) == null ? void 0 : _b.call(slots, {
  6965. tabIndex
  6966. })];
  6967. }
  6968. });
  6969. };
  6970. const renderTabs = () => createVNode(Tabs, {
  6971. "active": activeTab.value,
  6972. "onUpdate:active": ($event) => activeTab.value = $event,
  6973. "shrink": true,
  6974. "animated": true,
  6975. "class": bem$W("tabs"),
  6976. "color": props.activeColor,
  6977. "swipeable": props.swipeable,
  6978. "onClickTab": onClickTab
  6979. }, {
  6980. default: () => [tabs.value.map(renderTab)]
  6981. });
  6982. updateTabs();
  6983. watch(() => props.options, updateTabs, {
  6984. deep: true
  6985. });
  6986. watch(() => props.modelValue, (value) => {
  6987. if (value !== void 0) {
  6988. const values = tabs.value.map((tab) => {
  6989. var _a;
  6990. return (_a = tab.selected) == null ? void 0 : _a[valueKey];
  6991. });
  6992. if (values.includes(value)) {
  6993. return;
  6994. }
  6995. }
  6996. updateTabs();
  6997. });
  6998. return () => createVNode("div", {
  6999. "class": bem$W()
  7000. }, [renderHeader(), renderTabs()]);
  7001. }
  7002. });
  7003. const Cascader = withInstall(stdin_default$11);
  7004. const [name$W, bem$V] = createNamespace("cell-group");
  7005. const cellGroupProps = {
  7006. title: String,
  7007. inset: Boolean,
  7008. border: truthProp
  7009. };
  7010. var stdin_default$10 = defineComponent({
  7011. name: name$W,
  7012. inheritAttrs: false,
  7013. props: cellGroupProps,
  7014. setup(props, {
  7015. slots,
  7016. attrs
  7017. }) {
  7018. const renderGroup = () => {
  7019. var _a;
  7020. return createVNode("div", mergeProps({
  7021. "class": [bem$V({
  7022. inset: props.inset
  7023. }), {
  7024. [BORDER_TOP_BOTTOM]: props.border && !props.inset
  7025. }]
  7026. }, attrs), [(_a = slots.default) == null ? void 0 : _a.call(slots)]);
  7027. };
  7028. const renderTitle = () => createVNode("div", {
  7029. "class": bem$V("title", {
  7030. inset: props.inset
  7031. })
  7032. }, [slots.title ? slots.title() : props.title]);
  7033. return () => {
  7034. if (props.title || slots.title) {
  7035. return createVNode(Fragment, null, [renderTitle(), renderGroup()]);
  7036. }
  7037. return renderGroup();
  7038. };
  7039. }
  7040. });
  7041. const CellGroup = withInstall(stdin_default$10);
  7042. const [name$V, bem$U] = createNamespace("checkbox-group");
  7043. const checkboxGroupProps = {
  7044. max: numericProp,
  7045. disabled: Boolean,
  7046. iconSize: numericProp,
  7047. direction: String,
  7048. modelValue: makeArrayProp(),
  7049. checkedColor: String
  7050. };
  7051. const CHECKBOX_GROUP_KEY = Symbol(name$V);
  7052. var stdin_default$$ = defineComponent({
  7053. name: name$V,
  7054. props: checkboxGroupProps,
  7055. emits: ["change", "update:modelValue"],
  7056. setup(props, {
  7057. emit,
  7058. slots
  7059. }) {
  7060. const {
  7061. children,
  7062. linkChildren
  7063. } = useChildren(CHECKBOX_GROUP_KEY);
  7064. const updateValue = (value) => emit("update:modelValue", value);
  7065. const toggleAll = (options = {}) => {
  7066. if (typeof options === "boolean") {
  7067. options = {
  7068. checked: options
  7069. };
  7070. }
  7071. const {
  7072. checked,
  7073. skipDisabled
  7074. } = options;
  7075. const checkedChildren = children.filter((item) => {
  7076. if (!item.props.bindGroup) {
  7077. return false;
  7078. }
  7079. if (item.props.disabled && skipDisabled) {
  7080. return item.checked.value;
  7081. }
  7082. return checked != null ? checked : !item.checked.value;
  7083. });
  7084. const names = checkedChildren.map((item) => item.name);
  7085. updateValue(names);
  7086. };
  7087. watch(() => props.modelValue, (value) => emit("change", value));
  7088. useExpose({
  7089. toggleAll
  7090. });
  7091. useCustomFieldValue(() => props.modelValue);
  7092. linkChildren({
  7093. props,
  7094. updateValue
  7095. });
  7096. return () => {
  7097. var _a;
  7098. return createVNode("div", {
  7099. "class": bem$U([props.direction])
  7100. }, [(_a = slots.default) == null ? void 0 : _a.call(slots)]);
  7101. };
  7102. }
  7103. });
  7104. const [name$U, bem$T] = createNamespace("checkbox");
  7105. const checkboxProps = extend({}, checkerProps, {
  7106. bindGroup: truthProp
  7107. });
  7108. var stdin_default$_ = defineComponent({
  7109. name: name$U,
  7110. props: checkboxProps,
  7111. emits: ["change", "update:modelValue"],
  7112. setup(props, {
  7113. emit,
  7114. slots
  7115. }) {
  7116. const {
  7117. parent
  7118. } = useParent(CHECKBOX_GROUP_KEY);
  7119. const setParentValue = (checked2) => {
  7120. const {
  7121. name: name2
  7122. } = props;
  7123. const {
  7124. max,
  7125. modelValue
  7126. } = parent.props;
  7127. const value = modelValue.slice();
  7128. if (checked2) {
  7129. const overlimit = max && value.length >= max;
  7130. if (!overlimit && !value.includes(name2)) {
  7131. value.push(name2);
  7132. if (props.bindGroup) {
  7133. parent.updateValue(value);
  7134. }
  7135. }
  7136. } else {
  7137. const index = value.indexOf(name2);
  7138. if (index !== -1) {
  7139. value.splice(index, 1);
  7140. if (props.bindGroup) {
  7141. parent.updateValue(value);
  7142. }
  7143. }
  7144. }
  7145. };
  7146. const checked = computed(() => {
  7147. if (parent && props.bindGroup) {
  7148. return parent.props.modelValue.indexOf(props.name) !== -1;
  7149. }
  7150. return !!props.modelValue;
  7151. });
  7152. const toggle = (newValue = !checked.value) => {
  7153. if (parent && props.bindGroup) {
  7154. setParentValue(newValue);
  7155. } else {
  7156. emit("update:modelValue", newValue);
  7157. }
  7158. };
  7159. watch(() => props.modelValue, (value) => emit("change", value));
  7160. useExpose({
  7161. toggle,
  7162. props,
  7163. checked
  7164. });
  7165. useCustomFieldValue(() => props.modelValue);
  7166. return () => createVNode(stdin_default$1c, mergeProps({
  7167. "bem": bem$T,
  7168. "role": "checkbox",
  7169. "parent": parent,
  7170. "checked": checked.value,
  7171. "onToggle": toggle
  7172. }, props), pick(slots, ["default", "icon"]));
  7173. }
  7174. });
  7175. const Checkbox = withInstall(stdin_default$_);
  7176. const CheckboxGroup = withInstall(stdin_default$$);
  7177. const [name$T, bem$S] = createNamespace("circle");
  7178. let uid = 0;
  7179. const format = (rate) => Math.min(Math.max(+rate, 0), 100);
  7180. function getPath(clockwise, viewBoxSize) {
  7181. const sweepFlag = clockwise ? 1 : 0;
  7182. 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`;
  7183. }
  7184. const circleProps = {
  7185. text: String,
  7186. size: numericProp,
  7187. fill: makeStringProp("none"),
  7188. rate: makeNumericProp(100),
  7189. speed: makeNumericProp(0),
  7190. color: [String, Object],
  7191. clockwise: truthProp,
  7192. layerColor: String,
  7193. currentRate: makeNumberProp(0),
  7194. strokeWidth: makeNumericProp(40),
  7195. strokeLinecap: String,
  7196. startPosition: makeStringProp("top")
  7197. };
  7198. var stdin_default$Z = defineComponent({
  7199. name: name$T,
  7200. props: circleProps,
  7201. emits: ["update:currentRate"],
  7202. setup(props, {
  7203. emit,
  7204. slots
  7205. }) {
  7206. const id = `van-circle-${uid++}`;
  7207. const viewBoxSize = computed(() => +props.strokeWidth + 1e3);
  7208. const path = computed(() => getPath(props.clockwise, viewBoxSize.value));
  7209. const svgStyle = computed(() => {
  7210. const ROTATE_ANGLE_MAP = {
  7211. top: 0,
  7212. right: 90,
  7213. bottom: 180,
  7214. left: 270
  7215. };
  7216. const angleValue = ROTATE_ANGLE_MAP[props.startPosition];
  7217. if (angleValue) {
  7218. return {
  7219. transform: `rotate(${angleValue}deg)`
  7220. };
  7221. }
  7222. });
  7223. watch(() => props.rate, (rate) => {
  7224. let rafId;
  7225. const startTime = Date.now();
  7226. const startRate = props.currentRate;
  7227. const endRate = format(rate);
  7228. const duration = Math.abs((startRate - endRate) * 1e3 / +props.speed);
  7229. const animate = () => {
  7230. const now = Date.now();
  7231. const progress = Math.min((now - startTime) / duration, 1);
  7232. const rate2 = progress * (endRate - startRate) + startRate;
  7233. emit("update:currentRate", format(parseFloat(rate2.toFixed(1))));
  7234. if (endRate > startRate ? rate2 < endRate : rate2 > endRate) {
  7235. rafId = raf(animate);
  7236. }
  7237. };
  7238. if (props.speed) {
  7239. if (rafId) {
  7240. cancelRaf(rafId);
  7241. }
  7242. rafId = raf(animate);
  7243. } else {
  7244. emit("update:currentRate", endRate);
  7245. }
  7246. }, {
  7247. immediate: true
  7248. });
  7249. const renderHover = () => {
  7250. const PERIMETER = 3140;
  7251. const {
  7252. strokeWidth,
  7253. currentRate,
  7254. strokeLinecap
  7255. } = props;
  7256. const offset = PERIMETER * currentRate / 100;
  7257. const color = isObject(props.color) ? `url(#${id})` : props.color;
  7258. const style = {
  7259. stroke: color,
  7260. strokeWidth: `${+strokeWidth + 1}px`,
  7261. strokeLinecap,
  7262. strokeDasharray: `${offset}px ${PERIMETER}px`
  7263. };
  7264. return createVNode("path", {
  7265. "d": path.value,
  7266. "style": style,
  7267. "class": bem$S("hover"),
  7268. "stroke": color
  7269. }, null);
  7270. };
  7271. const renderLayer = () => {
  7272. const style = {
  7273. fill: props.fill,
  7274. stroke: props.layerColor,
  7275. strokeWidth: `${props.strokeWidth}px`
  7276. };
  7277. return createVNode("path", {
  7278. "class": bem$S("layer"),
  7279. "style": style,
  7280. "d": path.value
  7281. }, null);
  7282. };
  7283. const renderGradient = () => {
  7284. const {
  7285. color
  7286. } = props;
  7287. if (!isObject(color)) {
  7288. return;
  7289. }
  7290. const Stops = Object.keys(color).sort((a, b) => parseFloat(a) - parseFloat(b)).map((key, index) => createVNode("stop", {
  7291. "key": index,
  7292. "offset": key,
  7293. "stop-color": color[key]
  7294. }, null));
  7295. return createVNode("defs", null, [createVNode("linearGradient", {
  7296. "id": id,
  7297. "x1": "100%",
  7298. "y1": "0%",
  7299. "x2": "0%",
  7300. "y2": "0%"
  7301. }, [Stops])]);
  7302. };
  7303. const renderText = () => {
  7304. if (slots.default) {
  7305. return slots.default();
  7306. }
  7307. if (props.text) {
  7308. return createVNode("div", {
  7309. "class": bem$S("text")
  7310. }, [props.text]);
  7311. }
  7312. };
  7313. return () => createVNode("div", {
  7314. "class": bem$S(),
  7315. "style": getSizeStyle(props.size)
  7316. }, [createVNode("svg", {
  7317. "viewBox": `0 0 ${viewBoxSize.value} ${viewBoxSize.value}`,
  7318. "style": svgStyle.value
  7319. }, [renderGradient(), renderLayer(), renderHover()]), renderText()]);
  7320. }
  7321. });
  7322. const Circle = withInstall(stdin_default$Z);
  7323. const [name$S, bem$R] = createNamespace("row");
  7324. const ROW_KEY = Symbol(name$S);
  7325. const rowProps = {
  7326. tag: makeStringProp("div"),
  7327. wrap: truthProp,
  7328. align: String,
  7329. gutter: makeNumericProp(0),
  7330. justify: String
  7331. };
  7332. var stdin_default$Y = defineComponent({
  7333. name: name$S,
  7334. props: rowProps,
  7335. setup(props, {
  7336. slots
  7337. }) {
  7338. const {
  7339. children,
  7340. linkChildren
  7341. } = useChildren(ROW_KEY);
  7342. const groups = computed(() => {
  7343. const groups2 = [[]];
  7344. let totalSpan = 0;
  7345. children.forEach((child, index) => {
  7346. totalSpan += Number(child.span);
  7347. if (totalSpan > 24) {
  7348. groups2.push([index]);
  7349. totalSpan -= 24;
  7350. } else {
  7351. groups2[groups2.length - 1].push(index);
  7352. }
  7353. });
  7354. return groups2;
  7355. });
  7356. const spaces = computed(() => {
  7357. const gutter = Number(props.gutter);
  7358. const spaces2 = [];
  7359. if (!gutter) {
  7360. return spaces2;
  7361. }
  7362. groups.value.forEach((group) => {
  7363. const averagePadding = gutter * (group.length - 1) / group.length;
  7364. group.forEach((item, index) => {
  7365. if (index === 0) {
  7366. spaces2.push({
  7367. right: averagePadding
  7368. });
  7369. } else {
  7370. const left = gutter - spaces2[item - 1].right;
  7371. const right = averagePadding - left;
  7372. spaces2.push({
  7373. left,
  7374. right
  7375. });
  7376. }
  7377. });
  7378. });
  7379. return spaces2;
  7380. });
  7381. linkChildren({
  7382. spaces
  7383. });
  7384. return () => {
  7385. const {
  7386. tag,
  7387. wrap,
  7388. align,
  7389. justify
  7390. } = props;
  7391. return createVNode(tag, {
  7392. "class": bem$R({
  7393. [`align-${align}`]: align,
  7394. [`justify-${justify}`]: justify,
  7395. nowrap: !wrap
  7396. })
  7397. }, {
  7398. default: () => {
  7399. var _a;
  7400. return [(_a = slots.default) == null ? void 0 : _a.call(slots)];
  7401. }
  7402. });
  7403. };
  7404. }
  7405. });
  7406. const [name$R, bem$Q] = createNamespace("col");
  7407. const colProps = {
  7408. tag: makeStringProp("div"),
  7409. span: makeNumericProp(0),
  7410. offset: numericProp
  7411. };
  7412. var stdin_default$X = defineComponent({
  7413. name: name$R,
  7414. props: colProps,
  7415. setup(props, {
  7416. slots
  7417. }) {
  7418. const {
  7419. parent,
  7420. index
  7421. } = useParent(ROW_KEY);
  7422. const style = computed(() => {
  7423. if (!parent) {
  7424. return;
  7425. }
  7426. const {
  7427. spaces
  7428. } = parent;
  7429. if (spaces && spaces.value && spaces.value[index.value]) {
  7430. const {
  7431. left,
  7432. right
  7433. } = spaces.value[index.value];
  7434. return {
  7435. paddingLeft: left ? `${left}px` : null,
  7436. paddingRight: right ? `${right}px` : null
  7437. };
  7438. }
  7439. });
  7440. return () => {
  7441. const {
  7442. tag,
  7443. span,
  7444. offset
  7445. } = props;
  7446. return createVNode(tag, {
  7447. "style": style.value,
  7448. "class": bem$Q({
  7449. [span]: span,
  7450. [`offset-${offset}`]: offset
  7451. })
  7452. }, {
  7453. default: () => {
  7454. var _a;
  7455. return [(_a = slots.default) == null ? void 0 : _a.call(slots)];
  7456. }
  7457. });
  7458. };
  7459. }
  7460. });
  7461. const Col = withInstall(stdin_default$X);
  7462. const [name$Q, bem$P] = createNamespace("collapse");
  7463. const COLLAPSE_KEY = Symbol(name$Q);
  7464. const collapseProps = {
  7465. border: truthProp,
  7466. accordion: Boolean,
  7467. modelValue: {
  7468. type: [String, Number, Array],
  7469. default: ""
  7470. }
  7471. };
  7472. function validateModelValue(modelValue, accordion) {
  7473. if (accordion && Array.isArray(modelValue)) {
  7474. console.error('[Vant] Collapse: "v-model" should not be Array in accordion mode');
  7475. return false;
  7476. }
  7477. if (!accordion && !Array.isArray(modelValue)) {
  7478. console.error('[Vant] Collapse: "v-model" should be Array in non-accordion mode');
  7479. return false;
  7480. }
  7481. return true;
  7482. }
  7483. var stdin_default$W = defineComponent({
  7484. name: name$Q,
  7485. props: collapseProps,
  7486. emits: ["change", "update:modelValue"],
  7487. setup(props, {
  7488. emit,
  7489. slots
  7490. }) {
  7491. const {
  7492. linkChildren,
  7493. children
  7494. } = useChildren(COLLAPSE_KEY);
  7495. const updateName = (name2) => {
  7496. emit("change", name2);
  7497. emit("update:modelValue", name2);
  7498. };
  7499. const toggle = (name2, expanded) => {
  7500. const {
  7501. accordion,
  7502. modelValue
  7503. } = props;
  7504. if (accordion) {
  7505. updateName(name2 === modelValue ? "" : name2);
  7506. } else if (expanded) {
  7507. updateName(modelValue.concat(name2));
  7508. } else {
  7509. updateName(modelValue.filter((activeName) => activeName !== name2));
  7510. }
  7511. };
  7512. const toggleAll = (options = {}) => {
  7513. if (props.accordion) {
  7514. return;
  7515. }
  7516. if (typeof options === "boolean") {
  7517. options = {
  7518. expanded: options
  7519. };
  7520. }
  7521. const {
  7522. expanded,
  7523. skipDisabled
  7524. } = options;
  7525. const expandedChildren = children.filter((item) => {
  7526. if (item.disabled && skipDisabled) {
  7527. return item.expanded.value;
  7528. }
  7529. return expanded != null ? expanded : !item.expanded.value;
  7530. });
  7531. const names = expandedChildren.map((item) => item.itemName.value);
  7532. updateName(names);
  7533. };
  7534. const isExpanded = (name2) => {
  7535. const {
  7536. accordion,
  7537. modelValue
  7538. } = props;
  7539. if (process.env.NODE_ENV !== "production" && !validateModelValue(modelValue, accordion)) {
  7540. return false;
  7541. }
  7542. return accordion ? modelValue === name2 : modelValue.includes(name2);
  7543. };
  7544. useExpose({
  7545. toggleAll
  7546. });
  7547. linkChildren({
  7548. toggle,
  7549. isExpanded
  7550. });
  7551. return () => {
  7552. var _a;
  7553. return createVNode("div", {
  7554. "class": [bem$P(), {
  7555. [BORDER_TOP_BOTTOM]: props.border
  7556. }]
  7557. }, [(_a = slots.default) == null ? void 0 : _a.call(slots)]);
  7558. };
  7559. }
  7560. });
  7561. const Collapse = withInstall(stdin_default$W);
  7562. const [name$P, bem$O] = createNamespace("collapse-item");
  7563. const CELL_SLOTS = ["icon", "title", "value", "label", "right-icon"];
  7564. const collapseItemProps = extend({}, cellSharedProps, {
  7565. name: numericProp,
  7566. isLink: truthProp,
  7567. disabled: Boolean,
  7568. readonly: Boolean,
  7569. lazyRender: truthProp
  7570. });
  7571. var stdin_default$V = defineComponent({
  7572. name: name$P,
  7573. props: collapseItemProps,
  7574. setup(props, {
  7575. slots
  7576. }) {
  7577. const wrapperRef = ref();
  7578. const contentRef = ref();
  7579. const {
  7580. parent,
  7581. index
  7582. } = useParent(COLLAPSE_KEY);
  7583. if (!parent) {
  7584. if (process.env.NODE_ENV !== "production") {
  7585. console.error("[Vant] <CollapseItem> must be a child component of <Collapse>.");
  7586. }
  7587. return;
  7588. }
  7589. const name2 = computed(() => {
  7590. var _a;
  7591. return (_a = props.name) != null ? _a : index.value;
  7592. });
  7593. const expanded = computed(() => parent.isExpanded(name2.value));
  7594. const show = ref(expanded.value);
  7595. const lazyRender = useLazyRender(() => show.value || !props.lazyRender);
  7596. const onTransitionEnd = () => {
  7597. if (!expanded.value) {
  7598. show.value = false;
  7599. } else if (wrapperRef.value) {
  7600. wrapperRef.value.style.height = "";
  7601. }
  7602. };
  7603. watch(expanded, (value, oldValue) => {
  7604. if (oldValue === null) {
  7605. return;
  7606. }
  7607. if (value) {
  7608. show.value = true;
  7609. }
  7610. const tick = value ? nextTick : raf;
  7611. tick(() => {
  7612. if (!contentRef.value || !wrapperRef.value) {
  7613. return;
  7614. }
  7615. const {
  7616. offsetHeight
  7617. } = contentRef.value;
  7618. if (offsetHeight) {
  7619. const contentHeight = `${offsetHeight}px`;
  7620. wrapperRef.value.style.height = value ? "0" : contentHeight;
  7621. doubleRaf(() => {
  7622. if (wrapperRef.value) {
  7623. wrapperRef.value.style.height = value ? contentHeight : "0";
  7624. }
  7625. });
  7626. } else {
  7627. onTransitionEnd();
  7628. }
  7629. });
  7630. });
  7631. const toggle = (newValue = !expanded.value) => {
  7632. parent.toggle(name2.value, newValue);
  7633. };
  7634. const onClickTitle = () => {
  7635. if (!props.disabled && !props.readonly) {
  7636. toggle();
  7637. }
  7638. };
  7639. const renderTitle = () => {
  7640. const {
  7641. border,
  7642. disabled,
  7643. readonly
  7644. } = props;
  7645. const attrs = pick(props, Object.keys(cellSharedProps));
  7646. if (readonly) {
  7647. attrs.isLink = false;
  7648. }
  7649. if (disabled || readonly) {
  7650. attrs.clickable = false;
  7651. }
  7652. return createVNode(Cell, mergeProps({
  7653. "role": "button",
  7654. "class": bem$O("title", {
  7655. disabled,
  7656. expanded: expanded.value,
  7657. borderless: !border
  7658. }),
  7659. "aria-expanded": String(expanded.value),
  7660. "onClick": onClickTitle
  7661. }, attrs), pick(slots, CELL_SLOTS));
  7662. };
  7663. const renderContent = lazyRender(() => {
  7664. var _a;
  7665. return withDirectives(createVNode("div", {
  7666. "ref": wrapperRef,
  7667. "class": bem$O("wrapper"),
  7668. "onTransitionend": onTransitionEnd
  7669. }, [createVNode("div", {
  7670. "ref": contentRef,
  7671. "class": bem$O("content")
  7672. }, [(_a = slots.default) == null ? void 0 : _a.call(slots)])]), [[vShow, show.value]]);
  7673. });
  7674. useExpose({
  7675. toggle,
  7676. expanded,
  7677. itemName: name2
  7678. });
  7679. return () => createVNode("div", {
  7680. "class": [bem$O({
  7681. border: index.value && props.border
  7682. })]
  7683. }, [renderTitle(), renderContent()]);
  7684. }
  7685. });
  7686. const CollapseItem = withInstall(stdin_default$V);
  7687. const ConfigProvider = withInstall(stdin_default$1G);
  7688. const [name$O, bem$N, t$d] = createNamespace("contact-card");
  7689. const contactCardProps = {
  7690. tel: String,
  7691. name: String,
  7692. type: makeStringProp("add"),
  7693. addText: String,
  7694. editable: truthProp
  7695. };
  7696. var stdin_default$U = defineComponent({
  7697. name: name$O,
  7698. props: contactCardProps,
  7699. emits: ["click"],
  7700. setup(props, {
  7701. emit
  7702. }) {
  7703. const onClick = (event) => {
  7704. if (props.editable) {
  7705. emit("click", event);
  7706. }
  7707. };
  7708. const renderContent = () => {
  7709. if (props.type === "add") {
  7710. return props.addText || t$d("addContact");
  7711. }
  7712. return [createVNode("div", null, [`${t$d("name")}\uFF1A${props.name}`]), createVNode("div", null, [`${t$d("tel")}\uFF1A${props.tel}`])];
  7713. };
  7714. return () => createVNode(Cell, {
  7715. "center": true,
  7716. "icon": props.type === "edit" ? "contact" : "add-square",
  7717. "class": bem$N([props.type]),
  7718. "border": false,
  7719. "isLink": props.editable,
  7720. "titleClass": bem$N("title"),
  7721. "onClick": onClick
  7722. }, {
  7723. title: renderContent
  7724. });
  7725. }
  7726. });
  7727. const ContactCard = withInstall(stdin_default$U);
  7728. const [name$N, bem$M, t$c] = createNamespace("contact-edit");
  7729. const DEFAULT_CONTACT = {
  7730. tel: "",
  7731. name: ""
  7732. };
  7733. const contactEditProps = {
  7734. isEdit: Boolean,
  7735. isSaving: Boolean,
  7736. isDeleting: Boolean,
  7737. showSetDefault: Boolean,
  7738. setDefaultLabel: String,
  7739. contactInfo: {
  7740. type: Object,
  7741. default: () => extend({}, DEFAULT_CONTACT)
  7742. },
  7743. telValidator: {
  7744. type: Function,
  7745. default: isMobile
  7746. }
  7747. };
  7748. var stdin_default$T = defineComponent({
  7749. name: name$N,
  7750. props: contactEditProps,
  7751. emits: ["save", "delete", "changeDefault"],
  7752. setup(props, {
  7753. emit
  7754. }) {
  7755. const contact = reactive(extend({}, DEFAULT_CONTACT, props.contactInfo));
  7756. const onSave = () => {
  7757. if (!props.isSaving) {
  7758. emit("save", contact);
  7759. }
  7760. };
  7761. const onDelete = () => emit("delete", contact);
  7762. const renderButtons = () => createVNode("div", {
  7763. "class": bem$M("buttons")
  7764. }, [createVNode(Button, {
  7765. "block": true,
  7766. "round": true,
  7767. "type": "primary",
  7768. "text": t$c("save"),
  7769. "class": bem$M("button"),
  7770. "loading": props.isSaving,
  7771. "nativeType": "submit"
  7772. }, null), props.isEdit && createVNode(Button, {
  7773. "block": true,
  7774. "round": true,
  7775. "text": t$c("delete"),
  7776. "class": bem$M("button"),
  7777. "loading": props.isDeleting,
  7778. "onClick": onDelete
  7779. }, null)]);
  7780. const renderSwitch = () => createVNode(Switch, {
  7781. "modelValue": contact.isDefault,
  7782. "onUpdate:modelValue": ($event) => contact.isDefault = $event,
  7783. "onChange": (checked) => emit("changeDefault", checked)
  7784. }, null);
  7785. const renderSetDefault = () => {
  7786. if (props.showSetDefault) {
  7787. return createVNode(Cell, {
  7788. "title": props.setDefaultLabel,
  7789. "class": bem$M("switch-cell"),
  7790. "border": false
  7791. }, {
  7792. "right-icon": renderSwitch
  7793. });
  7794. }
  7795. };
  7796. watch(() => props.contactInfo, (value) => extend(contact, DEFAULT_CONTACT, value));
  7797. return () => createVNode(Form, {
  7798. "class": bem$M(),
  7799. "onSubmit": onSave
  7800. }, {
  7801. default: () => [createVNode("div", {
  7802. "class": bem$M("fields")
  7803. }, [createVNode(Field, {
  7804. "modelValue": contact.name,
  7805. "onUpdate:modelValue": ($event) => contact.name = $event,
  7806. "clearable": true,
  7807. "label": t$c("name"),
  7808. "rules": [{
  7809. required: true,
  7810. message: t$c("nameEmpty")
  7811. }],
  7812. "maxlength": "30",
  7813. "placeholder": t$c("name")
  7814. }, null), createVNode(Field, {
  7815. "modelValue": contact.tel,
  7816. "onUpdate:modelValue": ($event) => contact.tel = $event,
  7817. "clearable": true,
  7818. "type": "tel",
  7819. "label": t$c("tel"),
  7820. "rules": [{
  7821. validator: props.telValidator,
  7822. message: t$c("telInvalid")
  7823. }],
  7824. "placeholder": t$c("tel")
  7825. }, null)]), renderSetDefault(), renderButtons()]
  7826. });
  7827. }
  7828. });
  7829. const ContactEdit = withInstall(stdin_default$T);
  7830. const [name$M, bem$L, t$b] = createNamespace("contact-list");
  7831. const contactListProps = {
  7832. list: Array,
  7833. addText: String,
  7834. modelValue: unknownProp,
  7835. defaultTagText: String
  7836. };
  7837. var stdin_default$S = defineComponent({
  7838. name: name$M,
  7839. props: contactListProps,
  7840. emits: ["add", "edit", "select", "update:modelValue"],
  7841. setup(props, {
  7842. emit
  7843. }) {
  7844. const renderItem = (item, index) => {
  7845. const onClick = () => {
  7846. emit("update:modelValue", item.id);
  7847. emit("select", item, index);
  7848. };
  7849. const renderRightIcon = () => createVNode(Radio, {
  7850. "class": bem$L("radio"),
  7851. "name": item.id,
  7852. "iconSize": 16
  7853. }, null);
  7854. const renderEditIcon = () => createVNode(Icon, {
  7855. "name": "edit",
  7856. "class": bem$L("edit"),
  7857. "onClick": (event) => {
  7858. event.stopPropagation();
  7859. emit("edit", item, index);
  7860. }
  7861. }, null);
  7862. const renderContent = () => {
  7863. const nodes = [`${item.name}\uFF0C${item.tel}`];
  7864. if (item.isDefault && props.defaultTagText) {
  7865. nodes.push(createVNode(Tag, {
  7866. "type": "primary",
  7867. "round": true,
  7868. "class": bem$L("item-tag")
  7869. }, {
  7870. default: () => [props.defaultTagText]
  7871. }));
  7872. }
  7873. return nodes;
  7874. };
  7875. return createVNode(Cell, {
  7876. "key": item.id,
  7877. "isLink": true,
  7878. "center": true,
  7879. "class": bem$L("item"),
  7880. "titleClass": bem$L("item-title"),
  7881. "onClick": onClick
  7882. }, {
  7883. icon: renderEditIcon,
  7884. title: renderContent,
  7885. "right-icon": renderRightIcon
  7886. });
  7887. };
  7888. return () => createVNode("div", {
  7889. "class": bem$L()
  7890. }, [createVNode(RadioGroup, {
  7891. "modelValue": props.modelValue,
  7892. "class": bem$L("group")
  7893. }, {
  7894. default: () => [props.list && props.list.map(renderItem)]
  7895. }), createVNode("div", {
  7896. "class": [bem$L("bottom"), "van-safe-area-bottom"]
  7897. }, [createVNode(Button, {
  7898. "round": true,
  7899. "block": true,
  7900. "type": "primary",
  7901. "class": bem$L("add"),
  7902. "text": props.addText || t$b("addContact"),
  7903. "onClick": () => emit("add")
  7904. }, null)])]);
  7905. }
  7906. });
  7907. const ContactList = withInstall(stdin_default$S);
  7908. function parseFormat(format2, currentTime) {
  7909. const { days } = currentTime;
  7910. let { hours, minutes, seconds, milliseconds } = currentTime;
  7911. if (format2.includes("DD")) {
  7912. format2 = format2.replace("DD", padZero(days));
  7913. } else {
  7914. hours += days * 24;
  7915. }
  7916. if (format2.includes("HH")) {
  7917. format2 = format2.replace("HH", padZero(hours));
  7918. } else {
  7919. minutes += hours * 60;
  7920. }
  7921. if (format2.includes("mm")) {
  7922. format2 = format2.replace("mm", padZero(minutes));
  7923. } else {
  7924. seconds += minutes * 60;
  7925. }
  7926. if (format2.includes("ss")) {
  7927. format2 = format2.replace("ss", padZero(seconds));
  7928. } else {
  7929. milliseconds += seconds * 1e3;
  7930. }
  7931. if (format2.includes("S")) {
  7932. const ms = padZero(milliseconds, 3);
  7933. if (format2.includes("SSS")) {
  7934. format2 = format2.replace("SSS", ms);
  7935. } else if (format2.includes("SS")) {
  7936. format2 = format2.replace("SS", ms.slice(0, 2));
  7937. } else {
  7938. format2 = format2.replace("S", ms.charAt(0));
  7939. }
  7940. }
  7941. return format2;
  7942. }
  7943. const [name$L, bem$K] = createNamespace("count-down");
  7944. const countDownProps = {
  7945. time: makeNumericProp(0),
  7946. format: makeStringProp("HH:mm:ss"),
  7947. autoStart: truthProp,
  7948. millisecond: Boolean
  7949. };
  7950. var stdin_default$R = defineComponent({
  7951. name: name$L,
  7952. props: countDownProps,
  7953. emits: ["change", "finish"],
  7954. setup(props, {
  7955. emit,
  7956. slots
  7957. }) {
  7958. const {
  7959. start,
  7960. pause,
  7961. reset,
  7962. current: current2
  7963. } = useCountDown({
  7964. time: +props.time,
  7965. millisecond: props.millisecond,
  7966. onChange: (current22) => emit("change", current22),
  7967. onFinish: () => emit("finish")
  7968. });
  7969. const timeText = computed(() => parseFormat(props.format, current2.value));
  7970. const resetTime = () => {
  7971. reset(+props.time);
  7972. if (props.autoStart) {
  7973. start();
  7974. }
  7975. };
  7976. watch(() => props.time, resetTime, {
  7977. immediate: true
  7978. });
  7979. useExpose({
  7980. start,
  7981. pause,
  7982. reset: resetTime
  7983. });
  7984. return () => createVNode("div", {
  7985. "role": "timer",
  7986. "class": bem$K()
  7987. }, [slots.default ? slots.default(current2.value) : timeText.value]);
  7988. }
  7989. });
  7990. const CountDown = withInstall(stdin_default$R);
  7991. function getDate(timeStamp) {
  7992. const date = new Date(timeStamp * 1e3);
  7993. return `${date.getFullYear()}.${padZero(date.getMonth() + 1)}.${padZero(
  7994. date.getDate()
  7995. )}`;
  7996. }
  7997. const formatDiscount = (discount) => (discount / 10).toFixed(discount % 10 === 0 ? 0 : 1);
  7998. const formatAmount = (amount) => (amount / 100).toFixed(amount % 100 === 0 ? 0 : amount % 10 === 0 ? 1 : 2);
  7999. const [name$K, bem$J, t$a] = createNamespace("coupon");
  8000. var stdin_default$Q = defineComponent({
  8001. name: name$K,
  8002. props: {
  8003. chosen: Boolean,
  8004. coupon: makeRequiredProp(Object),
  8005. disabled: Boolean,
  8006. currency: makeStringProp("\xA5")
  8007. },
  8008. setup(props) {
  8009. const validPeriod = computed(() => {
  8010. const {
  8011. startAt,
  8012. endAt
  8013. } = props.coupon;
  8014. return `${getDate(startAt)} - ${getDate(endAt)}`;
  8015. });
  8016. const faceAmount = computed(() => {
  8017. const {
  8018. coupon,
  8019. currency
  8020. } = props;
  8021. if (coupon.valueDesc) {
  8022. return [coupon.valueDesc, createVNode("span", null, [coupon.unitDesc || ""])];
  8023. }
  8024. if (coupon.denominations) {
  8025. const denominations = formatAmount(coupon.denominations);
  8026. return [createVNode("span", null, [currency]), ` ${denominations}`];
  8027. }
  8028. if (coupon.discount) {
  8029. return t$a("discount", formatDiscount(coupon.discount));
  8030. }
  8031. return "";
  8032. });
  8033. const conditionMessage = computed(() => {
  8034. const condition = formatAmount(props.coupon.originCondition || 0);
  8035. return condition === "0" ? t$a("unlimited") : t$a("condition", condition);
  8036. });
  8037. return () => {
  8038. const {
  8039. chosen,
  8040. coupon,
  8041. disabled
  8042. } = props;
  8043. const description = disabled && coupon.reason || coupon.description;
  8044. return createVNode("div", {
  8045. "class": bem$J({
  8046. disabled
  8047. })
  8048. }, [createVNode("div", {
  8049. "class": bem$J("content")
  8050. }, [createVNode("div", {
  8051. "class": bem$J("head")
  8052. }, [createVNode("h2", {
  8053. "class": bem$J("amount")
  8054. }, [faceAmount.value]), createVNode("p", {
  8055. "class": bem$J("condition")
  8056. }, [coupon.condition || conditionMessage.value])]), createVNode("div", {
  8057. "class": bem$J("body")
  8058. }, [createVNode("p", {
  8059. "class": bem$J("name")
  8060. }, [coupon.name]), createVNode("p", {
  8061. "class": bem$J("valid")
  8062. }, [validPeriod.value]), !disabled && createVNode(Checkbox, {
  8063. "class": bem$J("corner"),
  8064. "modelValue": chosen
  8065. }, null)])]), description && createVNode("p", {
  8066. "class": bem$J("description")
  8067. }, [description])]);
  8068. };
  8069. }
  8070. });
  8071. const Coupon = withInstall(stdin_default$Q);
  8072. const [name$J, bem$I, t$9] = createNamespace("coupon-cell");
  8073. const couponCellProps = {
  8074. title: String,
  8075. border: truthProp,
  8076. editable: truthProp,
  8077. coupons: makeArrayProp(),
  8078. currency: makeStringProp("\xA5"),
  8079. chosenCoupon: makeNumericProp(-1)
  8080. };
  8081. function formatValue({
  8082. coupons,
  8083. chosenCoupon,
  8084. currency
  8085. }) {
  8086. const coupon = coupons[+chosenCoupon];
  8087. if (coupon) {
  8088. let value = 0;
  8089. if (isDef(coupon.value)) {
  8090. ({
  8091. value
  8092. } = coupon);
  8093. } else if (isDef(coupon.denominations)) {
  8094. value = coupon.denominations;
  8095. }
  8096. return `-${currency} ${(value / 100).toFixed(2)}`;
  8097. }
  8098. return coupons.length === 0 ? t$9("noCoupon") : t$9("count", coupons.length);
  8099. }
  8100. var stdin_default$P = defineComponent({
  8101. name: name$J,
  8102. props: couponCellProps,
  8103. setup(props) {
  8104. return () => {
  8105. const selected = props.coupons[+props.chosenCoupon];
  8106. return createVNode(Cell, {
  8107. "class": bem$I(),
  8108. "value": formatValue(props),
  8109. "title": props.title || t$9("title"),
  8110. "border": props.border,
  8111. "isLink": props.editable,
  8112. "valueClass": bem$I("value", {
  8113. selected
  8114. })
  8115. }, null);
  8116. };
  8117. }
  8118. });
  8119. const CouponCell = withInstall(stdin_default$P);
  8120. const [name$I, bem$H] = createNamespace("empty");
  8121. const emptyProps = {
  8122. image: makeStringProp("default"),
  8123. imageSize: [Number, String, Array],
  8124. description: String
  8125. };
  8126. var stdin_default$O = defineComponent({
  8127. name: name$I,
  8128. props: emptyProps,
  8129. setup(props, {
  8130. slots
  8131. }) {
  8132. const renderDescription = () => {
  8133. const description = slots.description ? slots.description() : props.description;
  8134. if (description) {
  8135. return createVNode("p", {
  8136. "class": bem$H("description")
  8137. }, [description]);
  8138. }
  8139. };
  8140. const renderBottom = () => {
  8141. if (slots.default) {
  8142. return createVNode("div", {
  8143. "class": bem$H("bottom")
  8144. }, [slots.default()]);
  8145. }
  8146. };
  8147. const baseId = useId();
  8148. const getId = (num) => `${baseId}-${num}`;
  8149. const getUrlById = (num) => `url(#${getId(num)})`;
  8150. const renderStop = (color, offset, opacity) => createVNode("stop", {
  8151. "stop-color": color,
  8152. "offset": `${offset}%`,
  8153. "stop-opacity": opacity
  8154. }, null);
  8155. const renderStops = (fromColor, toColor) => [renderStop(fromColor, 0), renderStop(toColor, 100)];
  8156. const renderShadow = (id) => [createVNode("defs", null, [createVNode("radialGradient", {
  8157. "id": getId(id),
  8158. "cx": "50%",
  8159. "cy": "54%",
  8160. "fx": "50%",
  8161. "fy": "54%",
  8162. "r": "297%",
  8163. "gradientTransform": "matrix(-.16 0 0 -.33 .58 .72)"
  8164. }, [renderStop("#EBEDF0", 0), renderStop("#F2F3F5", 100, 0.3)])]), createVNode("ellipse", {
  8165. "fill": getUrlById(id),
  8166. "opacity": ".8",
  8167. "cx": "80",
  8168. "cy": "140",
  8169. "rx": "46",
  8170. "ry": "8"
  8171. }, null)];
  8172. const renderBuilding = () => [createVNode("defs", null, [createVNode("linearGradient", {
  8173. "id": getId("a"),
  8174. "x1": "64%",
  8175. "y1": "100%",
  8176. "x2": "64%"
  8177. }, [renderStop("#FFF", 0, 0.5), renderStop("#F2F3F5", 100)])]), createVNode("g", {
  8178. "opacity": ".8"
  8179. }, [createVNode("path", {
  8180. "d": "M36 131V53H16v20H2v58h34z",
  8181. "fill": getUrlById("a")
  8182. }, null), createVNode("path", {
  8183. "d": "M123 15h22v14h9v77h-31V15z",
  8184. "fill": getUrlById("a")
  8185. }, null)])];
  8186. const renderCloud = () => [createVNode("defs", null, [createVNode("linearGradient", {
  8187. "id": getId("b"),
  8188. "x1": "64%",
  8189. "y1": "97%",
  8190. "x2": "64%",
  8191. "y2": "0%"
  8192. }, [renderStop("#F2F3F5", 0, 0.3), renderStop("#F2F3F5", 100)])]), createVNode("g", {
  8193. "opacity": ".8"
  8194. }, [createVNode("path", {
  8195. "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",
  8196. "fill": getUrlById("b")
  8197. }, null), createVNode("path", {
  8198. "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",
  8199. "fill": getUrlById("b")
  8200. }, null)])];
  8201. const renderNetwork = () => createVNode("svg", {
  8202. "viewBox": "0 0 160 160"
  8203. }, [createVNode("defs", null, [createVNode("linearGradient", {
  8204. "id": getId(1),
  8205. "x1": "64%",
  8206. "y1": "100%",
  8207. "x2": "64%"
  8208. }, [renderStop("#FFF", 0, 0.5), renderStop("#F2F3F5", 100)]), createVNode("linearGradient", {
  8209. "id": getId(2),
  8210. "x1": "50%",
  8211. "x2": "50%",
  8212. "y2": "84%"
  8213. }, [renderStop("#EBEDF0", 0), renderStop("#DCDEE0", 100, 0)]), createVNode("linearGradient", {
  8214. "id": getId(3),
  8215. "x1": "100%",
  8216. "x2": "100%",
  8217. "y2": "100%"
  8218. }, [renderStops("#EAEDF0", "#DCDEE0")]), createVNode("radialGradient", {
  8219. "id": getId(4),
  8220. "cx": "50%",
  8221. "cy": "0%",
  8222. "fx": "50%",
  8223. "fy": "0%",
  8224. "r": "100%",
  8225. "gradientTransform": "matrix(0 1 -.54 0 .5 -.5)"
  8226. }, [renderStop("#EBEDF0", 0), renderStop("#FFF", 100, 0)])]), createVNode("g", {
  8227. "fill": "none"
  8228. }, [renderBuilding(), createVNode("path", {
  8229. "fill": getUrlById(4),
  8230. "d": "M0 139h160v21H0z"
  8231. }, null), createVNode("path", {
  8232. "d": "M80 54a7 7 0 0 1 3 13v27l-2 2h-2a2 2 0 0 1-2-2V67a7 7 0 0 1 3-13z",
  8233. "fill": getUrlById(2)
  8234. }, null), createVNode("g", {
  8235. "opacity": ".6",
  8236. "stroke-linecap": "round",
  8237. "stroke-width": "7"
  8238. }, [createVNode("path", {
  8239. "d": "M64 47a19 19 0 0 0-5 13c0 5 2 10 5 13",
  8240. "stroke": getUrlById(3)
  8241. }, null), createVNode("path", {
  8242. "d": "M53 36a34 34 0 0 0 0 48",
  8243. "stroke": getUrlById(3)
  8244. }, null), createVNode("path", {
  8245. "d": "M95 73a19 19 0 0 0 6-13c0-5-2-9-6-13",
  8246. "stroke": getUrlById(3)
  8247. }, null), createVNode("path", {
  8248. "d": "M106 84a34 34 0 0 0 0-48",
  8249. "stroke": getUrlById(3)
  8250. }, null)]), createVNode("g", {
  8251. "transform": "translate(31 105)"
  8252. }, [createVNode("rect", {
  8253. "fill": "#EBEDF0",
  8254. "width": "98",
  8255. "height": "34",
  8256. "rx": "2"
  8257. }, null), createVNode("rect", {
  8258. "fill": "#FFF",
  8259. "x": "9",
  8260. "y": "8",
  8261. "width": "80",
  8262. "height": "18",
  8263. "rx": "1.1"
  8264. }, null), createVNode("rect", {
  8265. "fill": "#EBEDF0",
  8266. "x": "15",
  8267. "y": "12",
  8268. "width": "18",
  8269. "height": "6",
  8270. "rx": "1.1"
  8271. }, null)])])]);
  8272. const renderMaterial = () => createVNode("svg", {
  8273. "viewBox": "0 0 160 160"
  8274. }, [createVNode("defs", null, [createVNode("linearGradient", {
  8275. "x1": "50%",
  8276. "x2": "50%",
  8277. "y2": "100%",
  8278. "id": getId(5)
  8279. }, [renderStops("#F2F3F5", "#DCDEE0")]), createVNode("linearGradient", {
  8280. "x1": "95%",
  8281. "y1": "48%",
  8282. "x2": "5.5%",
  8283. "y2": "51%",
  8284. "id": getId(6)
  8285. }, [renderStops("#EAEDF1", "#DCDEE0")]), createVNode("linearGradient", {
  8286. "y1": "45%",
  8287. "x2": "100%",
  8288. "y2": "54%",
  8289. "id": getId(7)
  8290. }, [renderStops("#EAEDF1", "#DCDEE0")])]), renderBuilding(), renderCloud(), createVNode("g", {
  8291. "transform": "translate(36 50)",
  8292. "fill": "none"
  8293. }, [createVNode("g", {
  8294. "transform": "translate(8)"
  8295. }, [createVNode("rect", {
  8296. "fill": "#EBEDF0",
  8297. "opacity": ".6",
  8298. "x": "38",
  8299. "y": "13",
  8300. "width": "36",
  8301. "height": "53",
  8302. "rx": "2"
  8303. }, null), createVNode("rect", {
  8304. "fill": getUrlById(5),
  8305. "width": "64",
  8306. "height": "66",
  8307. "rx": "2"
  8308. }, null), createVNode("rect", {
  8309. "fill": "#FFF",
  8310. "x": "6",
  8311. "y": "6",
  8312. "width": "52",
  8313. "height": "55",
  8314. "rx": "1"
  8315. }, null), createVNode("g", {
  8316. "transform": "translate(15 17)",
  8317. "fill": getUrlById(6)
  8318. }, [createVNode("rect", {
  8319. "width": "34",
  8320. "height": "6",
  8321. "rx": "1"
  8322. }, null), createVNode("path", {
  8323. "d": "M0 14h34v6H0z"
  8324. }, null), createVNode("rect", {
  8325. "y": "28",
  8326. "width": "34",
  8327. "height": "6",
  8328. "rx": "1"
  8329. }, null)])]), createVNode("rect", {
  8330. "fill": getUrlById(7),
  8331. "y": "61",
  8332. "width": "88",
  8333. "height": "28",
  8334. "rx": "1"
  8335. }, null), createVNode("rect", {
  8336. "fill": "#F7F8FA",
  8337. "x": "29",
  8338. "y": "72",
  8339. "width": "30",
  8340. "height": "6",
  8341. "rx": "1"
  8342. }, null)])]);
  8343. const renderError = () => createVNode("svg", {
  8344. "viewBox": "0 0 160 160"
  8345. }, [createVNode("defs", null, [createVNode("linearGradient", {
  8346. "x1": "50%",
  8347. "x2": "50%",
  8348. "y2": "100%",
  8349. "id": getId(8)
  8350. }, [renderStops("#EAEDF1", "#DCDEE0")])]), renderBuilding(), renderCloud(), renderShadow("c"), createVNode("path", {
  8351. "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",
  8352. "fill": getUrlById(8)
  8353. }, null)]);
  8354. const renderSearch = () => createVNode("svg", {
  8355. "viewBox": "0 0 160 160"
  8356. }, [createVNode("defs", null, [createVNode("linearGradient", {
  8357. "x1": "50%",
  8358. "y1": "100%",
  8359. "x2": "50%",
  8360. "id": getId(9)
  8361. }, [renderStops("#EEE", "#D8D8D8")]), createVNode("linearGradient", {
  8362. "x1": "100%",
  8363. "y1": "50%",
  8364. "y2": "50%",
  8365. "id": getId(10)
  8366. }, [renderStops("#F2F3F5", "#DCDEE0")]), createVNode("linearGradient", {
  8367. "x1": "50%",
  8368. "x2": "50%",
  8369. "y2": "100%",
  8370. "id": getId(11)
  8371. }, [renderStops("#F2F3F5", "#DCDEE0")]), createVNode("linearGradient", {
  8372. "x1": "50%",
  8373. "x2": "50%",
  8374. "y2": "100%",
  8375. "id": getId(12)
  8376. }, [renderStops("#FFF", "#F7F8FA")])]), renderBuilding(), renderCloud(), renderShadow("d"), createVNode("g", {
  8377. "transform": "rotate(-45 113 -4)",
  8378. "fill": "none"
  8379. }, [createVNode("rect", {
  8380. "fill": getUrlById(9),
  8381. "x": "24",
  8382. "y": "52.8",
  8383. "width": "5.8",
  8384. "height": "19",
  8385. "rx": "1"
  8386. }, null), createVNode("rect", {
  8387. "fill": getUrlById(10),
  8388. "x": "22.1",
  8389. "y": "67.3",
  8390. "width": "9.9",
  8391. "height": "28",
  8392. "rx": "1"
  8393. }, null), createVNode("circle", {
  8394. "stroke": getUrlById(11),
  8395. "stroke-width": "8",
  8396. "cx": "27",
  8397. "cy": "27",
  8398. "r": "27"
  8399. }, null), createVNode("circle", {
  8400. "fill": getUrlById(12),
  8401. "cx": "27",
  8402. "cy": "27",
  8403. "r": "16"
  8404. }, null), createVNode("path", {
  8405. "d": "M37 7c-8 0-15 5-16 12",
  8406. "stroke": getUrlById(11),
  8407. "stroke-width": "3",
  8408. "opacity": ".5",
  8409. "stroke-linecap": "round",
  8410. "transform": "rotate(45 29 13)"
  8411. }, null)])]);
  8412. const renderImage = () => {
  8413. var _a;
  8414. if (slots.image) {
  8415. return slots.image();
  8416. }
  8417. const PRESET_IMAGES = {
  8418. error: renderError,
  8419. search: renderSearch,
  8420. network: renderNetwork,
  8421. default: renderMaterial
  8422. };
  8423. return ((_a = PRESET_IMAGES[props.image]) == null ? void 0 : _a.call(PRESET_IMAGES)) || createVNode("img", {
  8424. "src": props.image
  8425. }, null);
  8426. };
  8427. return () => createVNode("div", {
  8428. "class": bem$H()
  8429. }, [createVNode("div", {
  8430. "class": bem$H("image"),
  8431. "style": getSizeStyle(props.imageSize)
  8432. }, [renderImage()]), renderDescription(), renderBottom()]);
  8433. }
  8434. });
  8435. const Empty = withInstall(stdin_default$O);
  8436. const [name$H, bem$G, t$8] = createNamespace("coupon-list");
  8437. const couponListProps = {
  8438. code: makeStringProp(""),
  8439. coupons: makeArrayProp(),
  8440. currency: makeStringProp("\xA5"),
  8441. showCount: truthProp,
  8442. emptyImage: String,
  8443. chosenCoupon: makeNumberProp(-1),
  8444. enabledTitle: String,
  8445. disabledTitle: String,
  8446. disabledCoupons: makeArrayProp(),
  8447. showExchangeBar: truthProp,
  8448. showCloseButton: truthProp,
  8449. closeButtonText: String,
  8450. inputPlaceholder: String,
  8451. exchangeMinLength: makeNumberProp(1),
  8452. exchangeButtonText: String,
  8453. displayedCouponIndex: makeNumberProp(-1),
  8454. exchangeButtonLoading: Boolean,
  8455. exchangeButtonDisabled: Boolean
  8456. };
  8457. var stdin_default$N = defineComponent({
  8458. name: name$H,
  8459. props: couponListProps,
  8460. emits: ["change", "exchange", "update:code"],
  8461. setup(props, {
  8462. emit,
  8463. slots
  8464. }) {
  8465. const [couponRefs, setCouponRefs] = useRefs();
  8466. const root = ref();
  8467. const barRef = ref();
  8468. const activeTab = ref(0);
  8469. const listHeight = ref(0);
  8470. const currentCode = ref(props.code);
  8471. const buttonDisabled = computed(() => !props.exchangeButtonLoading && (props.exchangeButtonDisabled || !currentCode.value || currentCode.value.length < props.exchangeMinLength));
  8472. const updateListHeight = () => {
  8473. const TABS_HEIGHT = 44;
  8474. const rootHeight = useRect(root).height;
  8475. const headerHeight = useRect(barRef).height + TABS_HEIGHT;
  8476. listHeight.value = (rootHeight > headerHeight ? rootHeight : windowHeight.value) - headerHeight;
  8477. };
  8478. const onExchange = () => {
  8479. emit("exchange", currentCode.value);
  8480. if (!props.code) {
  8481. currentCode.value = "";
  8482. }
  8483. };
  8484. const scrollToCoupon = (index) => {
  8485. nextTick(() => {
  8486. var _a;
  8487. return (_a = couponRefs.value[index]) == null ? void 0 : _a.scrollIntoView();
  8488. });
  8489. };
  8490. const renderEmpty = () => createVNode(Empty, {
  8491. "image": props.emptyImage
  8492. }, {
  8493. default: () => [createVNode("p", {
  8494. "class": bem$G("empty-tip")
  8495. }, [t$8("noCoupon")])]
  8496. });
  8497. const renderExchangeBar = () => {
  8498. if (props.showExchangeBar) {
  8499. return createVNode("div", {
  8500. "ref": barRef,
  8501. "class": bem$G("exchange-bar")
  8502. }, [createVNode(Field, {
  8503. "modelValue": currentCode.value,
  8504. "onUpdate:modelValue": ($event) => currentCode.value = $event,
  8505. "clearable": true,
  8506. "border": false,
  8507. "class": bem$G("field"),
  8508. "placeholder": props.inputPlaceholder || t$8("placeholder"),
  8509. "maxlength": "20"
  8510. }, null), createVNode(Button, {
  8511. "plain": true,
  8512. "type": "primary",
  8513. "class": bem$G("exchange"),
  8514. "text": props.exchangeButtonText || t$8("exchange"),
  8515. "loading": props.exchangeButtonLoading,
  8516. "disabled": buttonDisabled.value,
  8517. "onClick": onExchange
  8518. }, null)]);
  8519. }
  8520. };
  8521. const renderCouponTab = () => {
  8522. const {
  8523. coupons
  8524. } = props;
  8525. const count = props.showCount ? ` (${coupons.length})` : "";
  8526. const title = (props.enabledTitle || t$8("enable")) + count;
  8527. return createVNode(Tab, {
  8528. "title": title
  8529. }, {
  8530. default: () => {
  8531. var _a;
  8532. return [createVNode("div", {
  8533. "class": bem$G("list", {
  8534. "with-bottom": props.showCloseButton
  8535. }),
  8536. "style": {
  8537. height: `${listHeight.value}px`
  8538. }
  8539. }, [coupons.map((coupon, index) => createVNode(Coupon, {
  8540. "key": coupon.id,
  8541. "ref": setCouponRefs(index),
  8542. "coupon": coupon,
  8543. "chosen": index === props.chosenCoupon,
  8544. "currency": props.currency,
  8545. "onClick": () => emit("change", index)
  8546. }, null)), !coupons.length && renderEmpty(), (_a = slots["list-footer"]) == null ? void 0 : _a.call(slots)])];
  8547. }
  8548. });
  8549. };
  8550. const renderDisabledTab = () => {
  8551. const {
  8552. disabledCoupons
  8553. } = props;
  8554. const count = props.showCount ? ` (${disabledCoupons.length})` : "";
  8555. const title = (props.disabledTitle || t$8("disabled")) + count;
  8556. return createVNode(Tab, {
  8557. "title": title
  8558. }, {
  8559. default: () => {
  8560. var _a;
  8561. return [createVNode("div", {
  8562. "class": bem$G("list", {
  8563. "with-bottom": props.showCloseButton
  8564. }),
  8565. "style": {
  8566. height: `${listHeight.value}px`
  8567. }
  8568. }, [disabledCoupons.map((coupon) => createVNode(Coupon, {
  8569. "disabled": true,
  8570. "key": coupon.id,
  8571. "coupon": coupon,
  8572. "currency": props.currency
  8573. }, null)), !disabledCoupons.length && renderEmpty(), (_a = slots["disabled-list-footer"]) == null ? void 0 : _a.call(slots)])];
  8574. }
  8575. });
  8576. };
  8577. watch(() => props.code, (value) => {
  8578. currentCode.value = value;
  8579. });
  8580. watch(windowHeight, updateListHeight);
  8581. watch(currentCode, (value) => emit("update:code", value));
  8582. watch(() => props.displayedCouponIndex, scrollToCoupon);
  8583. onMounted(() => {
  8584. updateListHeight();
  8585. scrollToCoupon(props.displayedCouponIndex);
  8586. });
  8587. return () => createVNode("div", {
  8588. "ref": root,
  8589. "class": bem$G()
  8590. }, [renderExchangeBar(), createVNode(Tabs, {
  8591. "active": activeTab.value,
  8592. "onUpdate:active": ($event) => activeTab.value = $event,
  8593. "class": bem$G("tab")
  8594. }, {
  8595. default: () => [renderCouponTab(), renderDisabledTab()]
  8596. }), createVNode("div", {
  8597. "class": bem$G("bottom")
  8598. }, [withDirectives(createVNode(Button, {
  8599. "round": true,
  8600. "block": true,
  8601. "type": "primary",
  8602. "class": bem$G("close"),
  8603. "text": props.closeButtonText || t$8("close"),
  8604. "onClick": () => emit("change", -1)
  8605. }, null), [[vShow, props.showCloseButton]])])]);
  8606. }
  8607. });
  8608. const CouponList = withInstall(stdin_default$N);
  8609. const currentYear = new Date().getFullYear();
  8610. const [name$G] = createNamespace("date-picker");
  8611. const datePickerProps = extend({}, sharedProps, {
  8612. columnsType: {
  8613. type: Array,
  8614. default: () => ["year", "month", "day"]
  8615. },
  8616. minDate: {
  8617. type: Date,
  8618. default: () => new Date(currentYear - 10, 0, 1),
  8619. validator: isDate
  8620. },
  8621. maxDate: {
  8622. type: Date,
  8623. default: () => new Date(currentYear + 10, 11, 31),
  8624. validator: isDate
  8625. }
  8626. });
  8627. var stdin_default$M = defineComponent({
  8628. name: name$G,
  8629. props: datePickerProps,
  8630. emits: ["confirm", "cancel", "change", "update:modelValue"],
  8631. setup(props, {
  8632. emit,
  8633. slots
  8634. }) {
  8635. const currentValues = ref(props.modelValue);
  8636. const genYearOptions = () => {
  8637. const minYear = props.minDate.getFullYear();
  8638. const maxYear = props.maxDate.getFullYear();
  8639. return genOptions(minYear, maxYear, "year", props.formatter, props.filter);
  8640. };
  8641. const isMinYear = (year) => year === props.minDate.getFullYear();
  8642. const isMaxYear = (year) => year === props.maxDate.getFullYear();
  8643. const isMinMonth = (month) => month === props.minDate.getMonth() + 1;
  8644. const isMaxMonth = (month) => month === props.maxDate.getMonth() + 1;
  8645. const getValue = (type) => {
  8646. const {
  8647. minDate,
  8648. columnsType
  8649. } = props;
  8650. const index = columnsType.indexOf(type);
  8651. const value = currentValues.value[index];
  8652. if (value) {
  8653. return +value;
  8654. }
  8655. switch (type) {
  8656. case "year":
  8657. return minDate.getFullYear();
  8658. case "month":
  8659. return minDate.getMonth() + 1;
  8660. case "day":
  8661. return minDate.getDate();
  8662. }
  8663. };
  8664. const genMonthOptions = () => {
  8665. const year = getValue("year");
  8666. const minMonth = isMinYear(year) ? props.minDate.getMonth() + 1 : 1;
  8667. const maxMonth = isMaxYear(year) ? props.maxDate.getMonth() + 1 : 12;
  8668. return genOptions(minMonth, maxMonth, "month", props.formatter, props.filter);
  8669. };
  8670. const genDayOptions = () => {
  8671. const year = getValue("year");
  8672. const month = getValue("month");
  8673. const minDate = isMinYear(year) && isMinMonth(month) ? props.minDate.getDate() : 1;
  8674. const maxDate = isMaxYear(year) && isMaxMonth(month) ? props.maxDate.getDate() : getMonthEndDay(year, month);
  8675. return genOptions(minDate, maxDate, "day", props.formatter, props.filter);
  8676. };
  8677. const columns = computed(() => props.columnsType.map((type) => {
  8678. switch (type) {
  8679. case "year":
  8680. return genYearOptions();
  8681. case "month":
  8682. return genMonthOptions();
  8683. case "day":
  8684. return genDayOptions();
  8685. default:
  8686. if (process.env.NODE_ENV !== "production") {
  8687. throw new Error(`[Vant] DatePicker: unsupported columns type: ${type}`);
  8688. }
  8689. return [];
  8690. }
  8691. }));
  8692. watch(currentValues, (newValues) => {
  8693. if (!isSameValue(newValues, props.modelValue)) {
  8694. emit("update:modelValue", newValues);
  8695. }
  8696. });
  8697. watch(() => props.modelValue, (newValues) => {
  8698. newValues = formatValueRange(newValues, columns.value);
  8699. if (!isSameValue(newValues, currentValues.value)) {
  8700. currentValues.value = newValues;
  8701. }
  8702. }, {
  8703. immediate: true
  8704. });
  8705. const onChange = (...args) => emit("change", ...args);
  8706. const onCancel = (...args) => emit("cancel", ...args);
  8707. const onConfirm = (...args) => emit("confirm", ...args);
  8708. return () => createVNode(Picker, mergeProps({
  8709. "modelValue": currentValues.value,
  8710. "onUpdate:modelValue": ($event) => currentValues.value = $event,
  8711. "columns": columns.value,
  8712. "onChange": onChange,
  8713. "onCancel": onCancel,
  8714. "onConfirm": onConfirm
  8715. }, pick(props, pickerInheritKeys)), slots);
  8716. }
  8717. });
  8718. const DatePicker = withInstall(stdin_default$M);
  8719. const [name$F, bem$F, t$7] = createNamespace("dialog");
  8720. const dialogProps = extend({}, popupSharedProps, {
  8721. title: String,
  8722. theme: String,
  8723. width: numericProp,
  8724. message: [String, Function],
  8725. callback: Function,
  8726. allowHtml: Boolean,
  8727. className: unknownProp,
  8728. transition: makeStringProp("van-dialog-bounce"),
  8729. messageAlign: String,
  8730. closeOnPopstate: truthProp,
  8731. showCancelButton: Boolean,
  8732. cancelButtonText: String,
  8733. cancelButtonColor: String,
  8734. cancelButtonDisabled: Boolean,
  8735. confirmButtonText: String,
  8736. confirmButtonColor: String,
  8737. confirmButtonDisabled: Boolean,
  8738. showConfirmButton: truthProp,
  8739. closeOnClickOverlay: Boolean
  8740. });
  8741. const popupInheritKeys$1 = [...popupSharedPropKeys, "transition", "closeOnPopstate"];
  8742. var stdin_default$L = defineComponent({
  8743. name: name$F,
  8744. props: dialogProps,
  8745. emits: ["confirm", "cancel", "keydown", "update:show"],
  8746. setup(props, {
  8747. emit,
  8748. slots
  8749. }) {
  8750. const root = ref();
  8751. const loading = reactive({
  8752. confirm: false,
  8753. cancel: false
  8754. });
  8755. const updateShow = (value) => emit("update:show", value);
  8756. const close = (action) => {
  8757. var _a;
  8758. updateShow(false);
  8759. (_a = props.callback) == null ? void 0 : _a.call(props, action);
  8760. };
  8761. const getActionHandler = (action) => () => {
  8762. if (!props.show) {
  8763. return;
  8764. }
  8765. emit(action);
  8766. if (props.beforeClose) {
  8767. loading[action] = true;
  8768. callInterceptor(props.beforeClose, {
  8769. args: [action],
  8770. done() {
  8771. close(action);
  8772. loading[action] = false;
  8773. },
  8774. canceled() {
  8775. loading[action] = false;
  8776. }
  8777. });
  8778. } else {
  8779. close(action);
  8780. }
  8781. };
  8782. const onCancel = getActionHandler("cancel");
  8783. const onConfirm = getActionHandler("confirm");
  8784. const onKeydown = withKeys((event) => {
  8785. var _a, _b;
  8786. if (event.target !== ((_b = (_a = root.value) == null ? void 0 : _a.popupRef) == null ? void 0 : _b.value)) {
  8787. return;
  8788. }
  8789. const onEventType = {
  8790. Enter: props.showConfirmButton ? onConfirm : noop,
  8791. Escape: props.showCancelButton ? onCancel : noop
  8792. };
  8793. onEventType[event.key]();
  8794. emit("keydown", event);
  8795. }, ["enter", "esc"]);
  8796. const renderTitle = () => {
  8797. const title = slots.title ? slots.title() : props.title;
  8798. if (title) {
  8799. return createVNode("div", {
  8800. "class": bem$F("header", {
  8801. isolated: !props.message && !slots.default
  8802. })
  8803. }, [title]);
  8804. }
  8805. };
  8806. const renderMessage = (hasTitle) => {
  8807. const {
  8808. message,
  8809. allowHtml,
  8810. messageAlign
  8811. } = props;
  8812. const classNames = bem$F("message", {
  8813. "has-title": hasTitle,
  8814. [messageAlign]: messageAlign
  8815. });
  8816. const content = isFunction(message) ? message() : message;
  8817. if (allowHtml && typeof content === "string") {
  8818. return createVNode("div", {
  8819. "class": classNames,
  8820. "innerHTML": content
  8821. }, null);
  8822. }
  8823. return createVNode("div", {
  8824. "class": classNames
  8825. }, [content]);
  8826. };
  8827. const renderContent = () => {
  8828. if (slots.default) {
  8829. return createVNode("div", {
  8830. "class": bem$F("content")
  8831. }, [slots.default()]);
  8832. }
  8833. const {
  8834. title,
  8835. message,
  8836. allowHtml
  8837. } = props;
  8838. if (message) {
  8839. const hasTitle = !!(title || slots.title);
  8840. return createVNode("div", {
  8841. "key": allowHtml ? 1 : 0,
  8842. "class": bem$F("content", {
  8843. isolated: !hasTitle
  8844. })
  8845. }, [renderMessage(hasTitle)]);
  8846. }
  8847. };
  8848. const renderButtons = () => createVNode("div", {
  8849. "class": [BORDER_TOP, bem$F("footer")]
  8850. }, [props.showCancelButton && createVNode(Button, {
  8851. "size": "large",
  8852. "text": props.cancelButtonText || t$7("cancel"),
  8853. "class": bem$F("cancel"),
  8854. "style": {
  8855. color: props.cancelButtonColor
  8856. },
  8857. "loading": loading.cancel,
  8858. "disabled": props.cancelButtonDisabled,
  8859. "onClick": onCancel
  8860. }, null), props.showConfirmButton && createVNode(Button, {
  8861. "size": "large",
  8862. "text": props.confirmButtonText || t$7("confirm"),
  8863. "class": [bem$F("confirm"), {
  8864. [BORDER_LEFT]: props.showCancelButton
  8865. }],
  8866. "style": {
  8867. color: props.confirmButtonColor
  8868. },
  8869. "loading": loading.confirm,
  8870. "disabled": props.confirmButtonDisabled,
  8871. "onClick": onConfirm
  8872. }, null)]);
  8873. const renderRoundButtons = () => createVNode(ActionBar, {
  8874. "class": bem$F("footer")
  8875. }, {
  8876. default: () => [props.showCancelButton && createVNode(ActionBarButton, {
  8877. "type": "warning",
  8878. "text": props.cancelButtonText || t$7("cancel"),
  8879. "class": bem$F("cancel"),
  8880. "color": props.cancelButtonColor,
  8881. "loading": loading.cancel,
  8882. "disabled": props.cancelButtonDisabled,
  8883. "onClick": onCancel
  8884. }, null), props.showConfirmButton && createVNode(ActionBarButton, {
  8885. "type": "danger",
  8886. "text": props.confirmButtonText || t$7("confirm"),
  8887. "class": bem$F("confirm"),
  8888. "color": props.confirmButtonColor,
  8889. "loading": loading.confirm,
  8890. "disabled": props.confirmButtonDisabled,
  8891. "onClick": onConfirm
  8892. }, null)]
  8893. });
  8894. const renderFooter = () => {
  8895. if (slots.footer) {
  8896. return slots.footer();
  8897. }
  8898. return props.theme === "round-button" ? renderRoundButtons() : renderButtons();
  8899. };
  8900. return () => {
  8901. const {
  8902. width,
  8903. title,
  8904. theme,
  8905. message,
  8906. className
  8907. } = props;
  8908. return createVNode(Popup, mergeProps({
  8909. "ref": root,
  8910. "role": "dialog",
  8911. "class": [bem$F([theme]), className],
  8912. "style": {
  8913. width: addUnit(width)
  8914. },
  8915. "tabindex": 0,
  8916. "aria-labelledby": title || message,
  8917. "onKeydown": onKeydown,
  8918. "onUpdate:show": updateShow
  8919. }, pick(props, popupInheritKeys$1)), {
  8920. default: () => [renderTitle(), renderContent(), renderFooter()]
  8921. });
  8922. };
  8923. }
  8924. });
  8925. let instance$2;
  8926. const DEFAULT_OPTIONS = {
  8927. title: "",
  8928. width: "",
  8929. theme: null,
  8930. message: "",
  8931. overlay: true,
  8932. callback: null,
  8933. teleport: "body",
  8934. className: "",
  8935. allowHtml: false,
  8936. lockScroll: true,
  8937. transition: void 0,
  8938. beforeClose: null,
  8939. overlayClass: "",
  8940. overlayStyle: void 0,
  8941. messageAlign: "",
  8942. cancelButtonText: "",
  8943. cancelButtonColor: null,
  8944. cancelButtonDisabled: false,
  8945. confirmButtonText: "",
  8946. confirmButtonColor: null,
  8947. confirmButtonDisabled: false,
  8948. showConfirmButton: true,
  8949. showCancelButton: false,
  8950. closeOnPopstate: true,
  8951. closeOnClickOverlay: false
  8952. };
  8953. let currentOptions$1 = extend({}, DEFAULT_OPTIONS);
  8954. function initInstance$2() {
  8955. const Wrapper = {
  8956. setup() {
  8957. const {
  8958. state,
  8959. toggle
  8960. } = usePopupState();
  8961. return () => createVNode(stdin_default$L, mergeProps(state, {
  8962. "onUpdate:show": toggle
  8963. }), null);
  8964. }
  8965. };
  8966. ({
  8967. instance: instance$2
  8968. } = mountComponent(Wrapper));
  8969. }
  8970. function showDialog(options) {
  8971. if (!inBrowser) {
  8972. return Promise.resolve();
  8973. }
  8974. return new Promise((resolve, reject) => {
  8975. if (!instance$2) {
  8976. initInstance$2();
  8977. }
  8978. instance$2.open(extend({}, currentOptions$1, options, {
  8979. callback: (action) => {
  8980. (action === "confirm" ? resolve : reject)(action);
  8981. }
  8982. }));
  8983. });
  8984. }
  8985. const setDialogDefaultOptions = (options) => {
  8986. extend(currentOptions$1, options);
  8987. };
  8988. const resetDialogDefaultOptions = () => {
  8989. currentOptions$1 = extend({}, DEFAULT_OPTIONS);
  8990. };
  8991. const showConfirmDialog = (options) => showDialog(extend({
  8992. showCancelButton: true
  8993. }, options));
  8994. const closeDialog = () => {
  8995. if (instance$2) {
  8996. instance$2.toggle(false);
  8997. }
  8998. };
  8999. const Dialog = withInstall(stdin_default$L);
  9000. const [name$E, bem$E] = createNamespace("divider");
  9001. const dividerProps = {
  9002. dashed: Boolean,
  9003. hairline: truthProp,
  9004. contentPosition: makeStringProp("center")
  9005. };
  9006. var stdin_default$K = defineComponent({
  9007. name: name$E,
  9008. props: dividerProps,
  9009. setup(props, {
  9010. slots
  9011. }) {
  9012. return () => {
  9013. var _a;
  9014. return createVNode("div", {
  9015. "role": "separator",
  9016. "class": bem$E({
  9017. dashed: props.dashed,
  9018. hairline: props.hairline,
  9019. [`content-${props.contentPosition}`]: !!slots.default
  9020. })
  9021. }, [(_a = slots.default) == null ? void 0 : _a.call(slots)]);
  9022. };
  9023. }
  9024. });
  9025. const Divider = withInstall(stdin_default$K);
  9026. const [name$D, bem$D] = createNamespace("dropdown-menu");
  9027. const dropdownMenuProps = {
  9028. overlay: truthProp,
  9029. zIndex: numericProp,
  9030. duration: makeNumericProp(0.2),
  9031. direction: makeStringProp("down"),
  9032. activeColor: String,
  9033. closeOnClickOutside: truthProp,
  9034. closeOnClickOverlay: truthProp
  9035. };
  9036. const DROPDOWN_KEY = Symbol(name$D);
  9037. var stdin_default$J = defineComponent({
  9038. name: name$D,
  9039. props: dropdownMenuProps,
  9040. setup(props, {
  9041. slots
  9042. }) {
  9043. const id = useId();
  9044. const root = ref();
  9045. const barRef = ref();
  9046. const offset = ref(0);
  9047. const {
  9048. children,
  9049. linkChildren
  9050. } = useChildren(DROPDOWN_KEY);
  9051. const scrollParent = useScrollParent(root);
  9052. const opened = computed(() => children.some((item) => item.state.showWrapper));
  9053. const barStyle = computed(() => {
  9054. if (opened.value && isDef(props.zIndex)) {
  9055. return {
  9056. zIndex: +props.zIndex + 1
  9057. };
  9058. }
  9059. });
  9060. const onClickAway = () => {
  9061. if (props.closeOnClickOutside) {
  9062. children.forEach((item) => {
  9063. item.toggle(false);
  9064. });
  9065. }
  9066. };
  9067. const updateOffset = () => {
  9068. if (barRef.value) {
  9069. const rect = useRect(barRef);
  9070. if (props.direction === "down") {
  9071. offset.value = rect.bottom;
  9072. } else {
  9073. offset.value = windowHeight.value - rect.top;
  9074. }
  9075. }
  9076. };
  9077. const onScroll = () => {
  9078. if (opened.value) {
  9079. updateOffset();
  9080. }
  9081. };
  9082. const toggleItem = (active) => {
  9083. children.forEach((item, index) => {
  9084. if (index === active) {
  9085. updateOffset();
  9086. item.toggle();
  9087. } else if (item.state.showPopup) {
  9088. item.toggle(false, {
  9089. immediate: true
  9090. });
  9091. }
  9092. });
  9093. };
  9094. const renderTitle = (item, index) => {
  9095. const {
  9096. showPopup
  9097. } = item.state;
  9098. const {
  9099. disabled,
  9100. titleClass
  9101. } = item;
  9102. return createVNode("div", {
  9103. "id": `${id}-${index}`,
  9104. "role": "button",
  9105. "tabindex": disabled ? void 0 : 0,
  9106. "class": [bem$D("item", {
  9107. disabled
  9108. }), {
  9109. [HAPTICS_FEEDBACK]: !disabled
  9110. }],
  9111. "onClick": () => {
  9112. if (!disabled) {
  9113. toggleItem(index);
  9114. }
  9115. }
  9116. }, [createVNode("span", {
  9117. "class": [bem$D("title", {
  9118. down: showPopup === (props.direction === "down"),
  9119. active: showPopup
  9120. }), titleClass],
  9121. "style": {
  9122. color: showPopup ? props.activeColor : ""
  9123. }
  9124. }, [createVNode("div", {
  9125. "class": "van-ellipsis"
  9126. }, [item.renderTitle()])])]);
  9127. };
  9128. linkChildren({
  9129. id,
  9130. props,
  9131. offset
  9132. });
  9133. useClickAway(root, onClickAway);
  9134. useEventListener("scroll", onScroll, {
  9135. target: scrollParent,
  9136. passive: true
  9137. });
  9138. return () => {
  9139. var _a;
  9140. return createVNode("div", {
  9141. "ref": root,
  9142. "class": bem$D()
  9143. }, [createVNode("div", {
  9144. "ref": barRef,
  9145. "style": barStyle.value,
  9146. "class": bem$D("bar", {
  9147. opened: opened.value
  9148. })
  9149. }, [children.map(renderTitle)]), (_a = slots.default) == null ? void 0 : _a.call(slots)]);
  9150. };
  9151. }
  9152. });
  9153. const [name$C, bem$C] = createNamespace("dropdown-item");
  9154. const dropdownItemProps = {
  9155. title: String,
  9156. options: makeArrayProp(),
  9157. disabled: Boolean,
  9158. teleport: [String, Object],
  9159. lazyRender: truthProp,
  9160. modelValue: unknownProp,
  9161. titleClass: unknownProp
  9162. };
  9163. var stdin_default$I = defineComponent({
  9164. name: name$C,
  9165. inheritAttrs: false,
  9166. props: dropdownItemProps,
  9167. emits: ["open", "opened", "close", "closed", "change", "update:modelValue"],
  9168. setup(props, {
  9169. emit,
  9170. slots,
  9171. attrs
  9172. }) {
  9173. const state = reactive({
  9174. showPopup: false,
  9175. transition: true,
  9176. showWrapper: false
  9177. });
  9178. const {
  9179. parent,
  9180. index
  9181. } = useParent(DROPDOWN_KEY);
  9182. if (!parent) {
  9183. if (process.env.NODE_ENV !== "production") {
  9184. console.error("[Vant] <DropdownItem> must be a child component of <DropdownMenu>.");
  9185. }
  9186. return;
  9187. }
  9188. const getEmitter = (name2) => () => emit(name2);
  9189. const onOpen = getEmitter("open");
  9190. const onClose = getEmitter("close");
  9191. const onOpened = getEmitter("opened");
  9192. const onClosed = () => {
  9193. state.showWrapper = false;
  9194. emit("closed");
  9195. };
  9196. const onClickWrapper = (event) => {
  9197. if (props.teleport) {
  9198. event.stopPropagation();
  9199. }
  9200. };
  9201. const toggle = (show = !state.showPopup, options = {}) => {
  9202. if (show === state.showPopup) {
  9203. return;
  9204. }
  9205. state.showPopup = show;
  9206. state.transition = !options.immediate;
  9207. if (show) {
  9208. state.showWrapper = true;
  9209. }
  9210. };
  9211. const renderTitle = () => {
  9212. if (slots.title) {
  9213. return slots.title();
  9214. }
  9215. if (props.title) {
  9216. return props.title;
  9217. }
  9218. const match = props.options.find((option) => option.value === props.modelValue);
  9219. return match ? match.text : "";
  9220. };
  9221. const renderOption = (option) => {
  9222. const {
  9223. activeColor
  9224. } = parent.props;
  9225. const active = option.value === props.modelValue;
  9226. const onClick = () => {
  9227. state.showPopup = false;
  9228. if (option.value !== props.modelValue) {
  9229. emit("update:modelValue", option.value);
  9230. emit("change", option.value);
  9231. }
  9232. };
  9233. const renderIcon = () => {
  9234. if (active) {
  9235. return createVNode(Icon, {
  9236. "class": bem$C("icon"),
  9237. "color": activeColor,
  9238. "name": "success"
  9239. }, null);
  9240. }
  9241. };
  9242. return createVNode(Cell, {
  9243. "role": "menuitem",
  9244. "key": option.value,
  9245. "icon": option.icon,
  9246. "title": option.text,
  9247. "class": bem$C("option", {
  9248. active
  9249. }),
  9250. "style": {
  9251. color: active ? activeColor : ""
  9252. },
  9253. "tabindex": active ? 0 : -1,
  9254. "clickable": true,
  9255. "onClick": onClick
  9256. }, {
  9257. value: renderIcon
  9258. });
  9259. };
  9260. const renderContent = () => {
  9261. const {
  9262. offset
  9263. } = parent;
  9264. const {
  9265. zIndex,
  9266. overlay,
  9267. duration,
  9268. direction,
  9269. closeOnClickOverlay
  9270. } = parent.props;
  9271. const style = getZIndexStyle(zIndex);
  9272. if (direction === "down") {
  9273. style.top = `${offset.value}px`;
  9274. } else {
  9275. style.bottom = `${offset.value}px`;
  9276. }
  9277. return withDirectives(createVNode("div", mergeProps({
  9278. "style": style,
  9279. "class": bem$C([direction]),
  9280. "onClick": onClickWrapper
  9281. }, attrs), [createVNode(Popup, {
  9282. "show": state.showPopup,
  9283. "onUpdate:show": ($event) => state.showPopup = $event,
  9284. "role": "menu",
  9285. "class": bem$C("content"),
  9286. "overlay": overlay,
  9287. "position": direction === "down" ? "top" : "bottom",
  9288. "duration": state.transition ? duration : 0,
  9289. "lazyRender": props.lazyRender,
  9290. "overlayStyle": {
  9291. position: "absolute"
  9292. },
  9293. "aria-labelledby": `${parent.id}-${index.value}`,
  9294. "closeOnClickOverlay": closeOnClickOverlay,
  9295. "onOpen": onOpen,
  9296. "onClose": onClose,
  9297. "onOpened": onOpened,
  9298. "onClosed": onClosed
  9299. }, {
  9300. default: () => {
  9301. var _a;
  9302. return [props.options.map(renderOption), (_a = slots.default) == null ? void 0 : _a.call(slots)];
  9303. }
  9304. })]), [[vShow, state.showWrapper]]);
  9305. };
  9306. useExpose({
  9307. state,
  9308. toggle,
  9309. renderTitle
  9310. });
  9311. return () => {
  9312. if (props.teleport) {
  9313. return createVNode(Teleport, {
  9314. "to": props.teleport
  9315. }, {
  9316. default: () => [renderContent()]
  9317. });
  9318. }
  9319. return renderContent();
  9320. };
  9321. }
  9322. });
  9323. const DropdownItem = withInstall(stdin_default$I);
  9324. const DropdownMenu = withInstall(stdin_default$J);
  9325. const [name$B, bem$B] = createNamespace("grid");
  9326. const gridProps = {
  9327. square: Boolean,
  9328. center: truthProp,
  9329. border: truthProp,
  9330. gutter: numericProp,
  9331. reverse: Boolean,
  9332. iconSize: numericProp,
  9333. direction: String,
  9334. clickable: Boolean,
  9335. columnNum: makeNumericProp(4)
  9336. };
  9337. const GRID_KEY = Symbol(name$B);
  9338. var stdin_default$H = defineComponent({
  9339. name: name$B,
  9340. props: gridProps,
  9341. setup(props, {
  9342. slots
  9343. }) {
  9344. const {
  9345. linkChildren
  9346. } = useChildren(GRID_KEY);
  9347. linkChildren({
  9348. props
  9349. });
  9350. return () => {
  9351. var _a;
  9352. return createVNode("div", {
  9353. "style": {
  9354. paddingLeft: addUnit(props.gutter)
  9355. },
  9356. "class": [bem$B(), {
  9357. [BORDER_TOP]: props.border && !props.gutter
  9358. }]
  9359. }, [(_a = slots.default) == null ? void 0 : _a.call(slots)]);
  9360. };
  9361. }
  9362. });
  9363. const Grid = withInstall(stdin_default$H);
  9364. const [name$A, bem$A] = createNamespace("grid-item");
  9365. const gridItemProps = extend({}, routeProps, {
  9366. dot: Boolean,
  9367. text: String,
  9368. icon: String,
  9369. badge: numericProp,
  9370. iconColor: String,
  9371. iconPrefix: String,
  9372. badgeProps: Object
  9373. });
  9374. var stdin_default$G = defineComponent({
  9375. name: name$A,
  9376. props: gridItemProps,
  9377. setup(props, {
  9378. slots
  9379. }) {
  9380. const {
  9381. parent,
  9382. index
  9383. } = useParent(GRID_KEY);
  9384. const route2 = useRoute();
  9385. if (!parent) {
  9386. if (process.env.NODE_ENV !== "production") {
  9387. console.error("[Vant] <GridItem> must be a child component of <Grid>.");
  9388. }
  9389. return;
  9390. }
  9391. const rootStyle = computed(() => {
  9392. const {
  9393. square,
  9394. gutter,
  9395. columnNum
  9396. } = parent.props;
  9397. const percent = `${100 / +columnNum}%`;
  9398. const style = {
  9399. flexBasis: percent
  9400. };
  9401. if (square) {
  9402. style.paddingTop = percent;
  9403. } else if (gutter) {
  9404. const gutterValue = addUnit(gutter);
  9405. style.paddingRight = gutterValue;
  9406. if (index.value >= columnNum) {
  9407. style.marginTop = gutterValue;
  9408. }
  9409. }
  9410. return style;
  9411. });
  9412. const contentStyle = computed(() => {
  9413. const {
  9414. square,
  9415. gutter
  9416. } = parent.props;
  9417. if (square && gutter) {
  9418. const gutterValue = addUnit(gutter);
  9419. return {
  9420. right: gutterValue,
  9421. bottom: gutterValue,
  9422. height: "auto"
  9423. };
  9424. }
  9425. });
  9426. const renderIcon = () => {
  9427. if (slots.icon) {
  9428. return createVNode(Badge, mergeProps({
  9429. "dot": props.dot,
  9430. "content": props.badge
  9431. }, props.badgeProps), {
  9432. default: slots.icon
  9433. });
  9434. }
  9435. if (props.icon) {
  9436. return createVNode(Icon, {
  9437. "dot": props.dot,
  9438. "name": props.icon,
  9439. "size": parent.props.iconSize,
  9440. "badge": props.badge,
  9441. "class": bem$A("icon"),
  9442. "color": props.iconColor,
  9443. "badgeProps": props.badgeProps,
  9444. "classPrefix": props.iconPrefix
  9445. }, null);
  9446. }
  9447. };
  9448. const renderText = () => {
  9449. if (slots.text) {
  9450. return slots.text();
  9451. }
  9452. if (props.text) {
  9453. return createVNode("span", {
  9454. "class": bem$A("text")
  9455. }, [props.text]);
  9456. }
  9457. };
  9458. const renderContent = () => {
  9459. if (slots.default) {
  9460. return slots.default();
  9461. }
  9462. return [renderIcon(), renderText()];
  9463. };
  9464. return () => {
  9465. const {
  9466. center,
  9467. border,
  9468. square,
  9469. gutter,
  9470. reverse,
  9471. direction,
  9472. clickable
  9473. } = parent.props;
  9474. const classes = [bem$A("content", [direction, {
  9475. center,
  9476. square,
  9477. reverse,
  9478. clickable,
  9479. surround: border && gutter
  9480. }]), {
  9481. [BORDER]: border
  9482. }];
  9483. return createVNode("div", {
  9484. "class": [bem$A({
  9485. square
  9486. })],
  9487. "style": rootStyle.value
  9488. }, [createVNode("div", {
  9489. "role": clickable ? "button" : void 0,
  9490. "class": classes,
  9491. "style": contentStyle.value,
  9492. "tabindex": clickable ? 0 : void 0,
  9493. "onClick": route2
  9494. }, [renderContent()])]);
  9495. };
  9496. }
  9497. });
  9498. const GridItem = withInstall(stdin_default$G);
  9499. const getDistance = (touches) => Math.sqrt((touches[0].clientX - touches[1].clientX) ** 2 + (touches[0].clientY - touches[1].clientY) ** 2);
  9500. const bem$z = createNamespace("image-preview")[1];
  9501. var stdin_default$F = defineComponent({
  9502. props: {
  9503. src: String,
  9504. show: Boolean,
  9505. active: Number,
  9506. minZoom: makeRequiredProp(numericProp),
  9507. maxZoom: makeRequiredProp(numericProp),
  9508. rootWidth: makeRequiredProp(Number),
  9509. rootHeight: makeRequiredProp(Number)
  9510. },
  9511. emits: ["scale", "close", "longPress"],
  9512. setup(props, {
  9513. emit,
  9514. slots
  9515. }) {
  9516. const state = reactive({
  9517. scale: 1,
  9518. moveX: 0,
  9519. moveY: 0,
  9520. moving: false,
  9521. zooming: false,
  9522. imageRatio: 0,
  9523. displayWidth: 0,
  9524. displayHeight: 0
  9525. });
  9526. const touch = useTouch();
  9527. const swipeItem = ref();
  9528. const vertical = computed(() => {
  9529. const {
  9530. rootWidth,
  9531. rootHeight
  9532. } = props;
  9533. const rootRatio = rootHeight / rootWidth;
  9534. return state.imageRatio > rootRatio;
  9535. });
  9536. const imageStyle = computed(() => {
  9537. const {
  9538. scale,
  9539. moveX,
  9540. moveY,
  9541. moving,
  9542. zooming
  9543. } = state;
  9544. const style = {
  9545. transitionDuration: zooming || moving ? "0s" : ".3s"
  9546. };
  9547. if (scale !== 1) {
  9548. const offsetX = moveX / scale;
  9549. const offsetY = moveY / scale;
  9550. style.transform = `scale(${scale}, ${scale}) translate(${offsetX}px, ${offsetY}px)`;
  9551. }
  9552. return style;
  9553. });
  9554. const maxMoveX = computed(() => {
  9555. if (state.imageRatio) {
  9556. const {
  9557. rootWidth,
  9558. rootHeight
  9559. } = props;
  9560. const displayWidth = vertical.value ? rootHeight / state.imageRatio : rootWidth;
  9561. return Math.max(0, (state.scale * displayWidth - rootWidth) / 2);
  9562. }
  9563. return 0;
  9564. });
  9565. const maxMoveY = computed(() => {
  9566. if (state.imageRatio) {
  9567. const {
  9568. rootWidth,
  9569. rootHeight
  9570. } = props;
  9571. const displayHeight = vertical.value ? rootHeight : rootWidth * state.imageRatio;
  9572. return Math.max(0, (state.scale * displayHeight - rootHeight) / 2);
  9573. }
  9574. return 0;
  9575. });
  9576. const setScale = (scale) => {
  9577. scale = clamp(scale, +props.minZoom, +props.maxZoom + 1);
  9578. if (scale !== state.scale) {
  9579. state.scale = scale;
  9580. emit("scale", {
  9581. scale,
  9582. index: props.active
  9583. });
  9584. }
  9585. };
  9586. const resetScale = () => {
  9587. setScale(1);
  9588. state.moveX = 0;
  9589. state.moveY = 0;
  9590. };
  9591. const toggleScale = () => {
  9592. const scale = state.scale > 1 ? 1 : 2;
  9593. setScale(scale);
  9594. state.moveX = 0;
  9595. state.moveY = 0;
  9596. };
  9597. let fingerNum;
  9598. let startMoveX;
  9599. let startMoveY;
  9600. let startScale;
  9601. let startDistance;
  9602. let doubleTapTimer;
  9603. let touchStartTime;
  9604. const onTouchStart = (event) => {
  9605. const {
  9606. touches
  9607. } = event;
  9608. const {
  9609. offsetX
  9610. } = touch;
  9611. touch.start(event);
  9612. fingerNum = touches.length;
  9613. startMoveX = state.moveX;
  9614. startMoveY = state.moveY;
  9615. touchStartTime = Date.now();
  9616. state.moving = fingerNum === 1 && state.scale !== 1;
  9617. state.zooming = fingerNum === 2 && !offsetX.value;
  9618. if (state.zooming) {
  9619. startScale = state.scale;
  9620. startDistance = getDistance(event.touches);
  9621. }
  9622. };
  9623. const onTouchMove = (event) => {
  9624. const {
  9625. touches
  9626. } = event;
  9627. touch.move(event);
  9628. if (state.moving || state.zooming) {
  9629. preventDefault(event, true);
  9630. }
  9631. if (state.moving) {
  9632. const {
  9633. deltaX,
  9634. deltaY
  9635. } = touch;
  9636. const moveX = deltaX.value + startMoveX;
  9637. const moveY = deltaY.value + startMoveY;
  9638. state.moveX = clamp(moveX, -maxMoveX.value, maxMoveX.value);
  9639. state.moveY = clamp(moveY, -maxMoveY.value, maxMoveY.value);
  9640. }
  9641. if (state.zooming && touches.length === 2) {
  9642. const distance = getDistance(touches);
  9643. const scale = startScale * distance / startDistance;
  9644. setScale(scale);
  9645. }
  9646. };
  9647. const checkTap = () => {
  9648. if (fingerNum > 1) {
  9649. return;
  9650. }
  9651. const {
  9652. offsetX,
  9653. offsetY
  9654. } = touch;
  9655. const deltaTime = Date.now() - touchStartTime;
  9656. const TAP_TIME = 250;
  9657. const TAP_OFFSET = 5;
  9658. if (offsetX.value < TAP_OFFSET && offsetY.value < TAP_OFFSET) {
  9659. if (deltaTime < TAP_TIME) {
  9660. if (doubleTapTimer) {
  9661. clearTimeout(doubleTapTimer);
  9662. doubleTapTimer = null;
  9663. toggleScale();
  9664. } else {
  9665. doubleTapTimer = setTimeout(() => {
  9666. emit("close");
  9667. doubleTapTimer = null;
  9668. }, TAP_TIME);
  9669. }
  9670. } else if (deltaTime > LONG_PRESS_START_TIME) {
  9671. emit("longPress");
  9672. }
  9673. }
  9674. };
  9675. const onTouchEnd = (event) => {
  9676. let stopPropagation2 = false;
  9677. if (state.moving || state.zooming) {
  9678. stopPropagation2 = true;
  9679. if (state.moving && startMoveX === state.moveX && startMoveY === state.moveY) {
  9680. stopPropagation2 = false;
  9681. }
  9682. if (!event.touches.length) {
  9683. if (state.zooming) {
  9684. state.moveX = clamp(state.moveX, -maxMoveX.value, maxMoveX.value);
  9685. state.moveY = clamp(state.moveY, -maxMoveY.value, maxMoveY.value);
  9686. state.zooming = false;
  9687. }
  9688. state.moving = false;
  9689. startMoveX = 0;
  9690. startMoveY = 0;
  9691. startScale = 1;
  9692. if (state.scale < 1) {
  9693. resetScale();
  9694. }
  9695. if (state.scale > props.maxZoom) {
  9696. state.scale = +props.maxZoom;
  9697. }
  9698. }
  9699. }
  9700. preventDefault(event, stopPropagation2);
  9701. checkTap();
  9702. touch.reset();
  9703. };
  9704. const onLoad = (event) => {
  9705. const {
  9706. naturalWidth,
  9707. naturalHeight
  9708. } = event.target;
  9709. state.imageRatio = naturalHeight / naturalWidth;
  9710. };
  9711. watch(() => props.active, resetScale);
  9712. watch(() => props.show, (value) => {
  9713. if (!value) {
  9714. resetScale();
  9715. }
  9716. });
  9717. useEventListener("touchmove", onTouchMove, {
  9718. target: computed(() => {
  9719. var _a;
  9720. return (_a = swipeItem.value) == null ? void 0 : _a.$el;
  9721. })
  9722. });
  9723. return () => {
  9724. const imageSlots = {
  9725. loading: () => createVNode(Loading, {
  9726. "type": "spinner"
  9727. }, null)
  9728. };
  9729. return createVNode(SwipeItem, {
  9730. "ref": swipeItem,
  9731. "class": bem$z("swipe-item"),
  9732. "onTouchstartPassive": onTouchStart,
  9733. "onTouchend": onTouchEnd,
  9734. "onTouchcancel": onTouchEnd
  9735. }, {
  9736. default: () => [slots.image ? createVNode("div", {
  9737. "class": bem$z("image-wrap")
  9738. }, [slots.image({
  9739. src: props.src
  9740. })]) : createVNode(Image$1, {
  9741. "src": props.src,
  9742. "fit": "contain",
  9743. "class": bem$z("image", {
  9744. vertical: vertical.value
  9745. }),
  9746. "style": imageStyle.value,
  9747. "onLoad": onLoad
  9748. }, imageSlots)]
  9749. });
  9750. };
  9751. }
  9752. });
  9753. const [name$z, bem$y] = createNamespace("image-preview");
  9754. const popupProps$1 = ["show", "transition", "overlayStyle", "closeOnPopstate"];
  9755. const imagePreviewProps = {
  9756. show: Boolean,
  9757. loop: truthProp,
  9758. images: makeArrayProp(),
  9759. minZoom: makeNumericProp(1 / 3),
  9760. maxZoom: makeNumericProp(3),
  9761. overlay: truthProp,
  9762. closeable: Boolean,
  9763. showIndex: truthProp,
  9764. className: unknownProp,
  9765. closeIcon: makeStringProp("clear"),
  9766. transition: String,
  9767. beforeClose: Function,
  9768. overlayClass: unknownProp,
  9769. overlayStyle: Object,
  9770. swipeDuration: makeNumericProp(300),
  9771. startPosition: makeNumericProp(0),
  9772. showIndicators: Boolean,
  9773. closeOnPopstate: truthProp,
  9774. closeIconPosition: makeStringProp("top-right")
  9775. };
  9776. var stdin_default$E = defineComponent({
  9777. name: name$z,
  9778. props: imagePreviewProps,
  9779. emits: ["scale", "close", "closed", "change", "longPress", "update:show"],
  9780. setup(props, {
  9781. emit,
  9782. slots
  9783. }) {
  9784. const swipeRef = ref();
  9785. const state = reactive({
  9786. active: 0,
  9787. rootWidth: 0,
  9788. rootHeight: 0
  9789. });
  9790. const resize = () => {
  9791. if (swipeRef.value) {
  9792. const rect = useRect(swipeRef.value.$el);
  9793. state.rootWidth = rect.width;
  9794. state.rootHeight = rect.height;
  9795. swipeRef.value.resize();
  9796. }
  9797. };
  9798. const emitScale = (args) => emit("scale", args);
  9799. const updateShow = (show) => emit("update:show", show);
  9800. const emitClose = () => {
  9801. callInterceptor(props.beforeClose, {
  9802. args: [state.active],
  9803. done: () => updateShow(false)
  9804. });
  9805. };
  9806. const setActive = (active) => {
  9807. if (active !== state.active) {
  9808. state.active = active;
  9809. emit("change", active);
  9810. }
  9811. };
  9812. const renderIndex = () => {
  9813. if (props.showIndex) {
  9814. return createVNode("div", {
  9815. "class": bem$y("index")
  9816. }, [slots.index ? slots.index({
  9817. index: state.active
  9818. }) : `${state.active + 1} / ${props.images.length}`]);
  9819. }
  9820. };
  9821. const renderCover = () => {
  9822. if (slots.cover) {
  9823. return createVNode("div", {
  9824. "class": bem$y("cover")
  9825. }, [slots.cover()]);
  9826. }
  9827. };
  9828. const renderImages = () => createVNode(Swipe, {
  9829. "ref": swipeRef,
  9830. "lazyRender": true,
  9831. "loop": props.loop,
  9832. "class": bem$y("swipe"),
  9833. "duration": props.swipeDuration,
  9834. "initialSwipe": props.startPosition,
  9835. "showIndicators": props.showIndicators,
  9836. "indicatorColor": "white",
  9837. "onChange": setActive
  9838. }, {
  9839. default: () => [props.images.map((image, index) => createVNode(stdin_default$F, {
  9840. "src": image,
  9841. "show": props.show,
  9842. "active": state.active,
  9843. "maxZoom": props.maxZoom,
  9844. "minZoom": props.minZoom,
  9845. "rootWidth": state.rootWidth,
  9846. "rootHeight": state.rootHeight,
  9847. "onScale": emitScale,
  9848. "onClose": emitClose,
  9849. "onLongPress": () => emit("longPress", {
  9850. index
  9851. })
  9852. }, {
  9853. image: slots.image
  9854. }))]
  9855. });
  9856. const renderClose = () => {
  9857. if (props.closeable) {
  9858. return createVNode(Icon, {
  9859. "role": "button",
  9860. "name": props.closeIcon,
  9861. "class": [bem$y("close-icon", props.closeIconPosition), HAPTICS_FEEDBACK],
  9862. "onClick": emitClose
  9863. }, null);
  9864. }
  9865. };
  9866. const onClosed = () => emit("closed");
  9867. const swipeTo = (index, options) => {
  9868. var _a;
  9869. return (_a = swipeRef.value) == null ? void 0 : _a.swipeTo(index, options);
  9870. };
  9871. useExpose({
  9872. swipeTo
  9873. });
  9874. onMounted(resize);
  9875. watch([windowWidth, windowHeight], resize);
  9876. watch(() => props.startPosition, (value) => setActive(+value));
  9877. watch(() => props.show, (value) => {
  9878. const {
  9879. images,
  9880. startPosition
  9881. } = props;
  9882. if (value) {
  9883. setActive(+startPosition);
  9884. nextTick(() => {
  9885. resize();
  9886. swipeTo(+startPosition, {
  9887. immediate: true
  9888. });
  9889. });
  9890. } else {
  9891. emit("close", {
  9892. index: state.active,
  9893. url: images[state.active]
  9894. });
  9895. }
  9896. });
  9897. return () => createVNode(Popup, mergeProps({
  9898. "class": [bem$y(), props.className],
  9899. "overlayClass": [bem$y("overlay"), props.overlayClass],
  9900. "onClosed": onClosed,
  9901. "onUpdate:show": updateShow
  9902. }, pick(props, popupProps$1)), {
  9903. default: () => [renderClose(), renderImages(), renderIndex(), renderCover()]
  9904. });
  9905. }
  9906. });
  9907. let instance$1;
  9908. const defaultConfig = {
  9909. loop: true,
  9910. images: [],
  9911. maxZoom: 3,
  9912. minZoom: 1 / 3,
  9913. onScale: void 0,
  9914. onClose: void 0,
  9915. onChange: void 0,
  9916. teleport: "body",
  9917. className: "",
  9918. showIndex: true,
  9919. closeable: false,
  9920. closeIcon: "clear",
  9921. transition: void 0,
  9922. beforeClose: void 0,
  9923. overlayStyle: void 0,
  9924. overlayClass: void 0,
  9925. startPosition: 0,
  9926. swipeDuration: 300,
  9927. showIndicators: false,
  9928. closeOnPopstate: true,
  9929. closeIconPosition: "top-right"
  9930. };
  9931. function initInstance$1() {
  9932. ({
  9933. instance: instance$1
  9934. } = mountComponent({
  9935. setup() {
  9936. const {
  9937. state,
  9938. toggle
  9939. } = usePopupState();
  9940. const onClosed = () => {
  9941. state.images = [];
  9942. };
  9943. return () => createVNode(stdin_default$E, mergeProps(state, {
  9944. "onClosed": onClosed,
  9945. "onUpdate:show": toggle
  9946. }), null);
  9947. }
  9948. }));
  9949. }
  9950. const showImagePreview = (options, startPosition = 0) => {
  9951. if (!inBrowser) {
  9952. return;
  9953. }
  9954. if (!instance$1) {
  9955. initInstance$1();
  9956. }
  9957. options = Array.isArray(options) ? {
  9958. images: options,
  9959. startPosition
  9960. } : options;
  9961. instance$1.open(extend({}, defaultConfig, options));
  9962. return instance$1;
  9963. };
  9964. const ImagePreview = withInstall(stdin_default$E);
  9965. function genAlphabet() {
  9966. const charCodeOfA = "A".charCodeAt(0);
  9967. const indexList = Array(26).fill("").map((_, i) => String.fromCharCode(charCodeOfA + i));
  9968. return indexList;
  9969. }
  9970. const [name$y, bem$x] = createNamespace("index-bar");
  9971. const indexBarProps = {
  9972. sticky: truthProp,
  9973. zIndex: numericProp,
  9974. teleport: [String, Object],
  9975. highlightColor: String,
  9976. stickyOffsetTop: makeNumberProp(0),
  9977. indexList: {
  9978. type: Array,
  9979. default: genAlphabet
  9980. }
  9981. };
  9982. const INDEX_BAR_KEY = Symbol(name$y);
  9983. var stdin_default$D = defineComponent({
  9984. name: name$y,
  9985. props: indexBarProps,
  9986. emits: ["select", "change"],
  9987. setup(props, {
  9988. emit,
  9989. slots
  9990. }) {
  9991. const root = ref();
  9992. const sidebar = ref();
  9993. const activeAnchor = ref("");
  9994. const touch = useTouch();
  9995. const scrollParent = useScrollParent(root);
  9996. const {
  9997. children,
  9998. linkChildren
  9999. } = useChildren(INDEX_BAR_KEY);
  10000. let selectActiveIndex;
  10001. linkChildren({
  10002. props
  10003. });
  10004. const sidebarStyle = computed(() => {
  10005. if (isDef(props.zIndex)) {
  10006. return {
  10007. zIndex: +props.zIndex + 1
  10008. };
  10009. }
  10010. });
  10011. const highlightStyle = computed(() => {
  10012. if (props.highlightColor) {
  10013. return {
  10014. color: props.highlightColor
  10015. };
  10016. }
  10017. });
  10018. const getActiveAnchor = (scrollTop, rects) => {
  10019. for (let i = children.length - 1; i >= 0; i--) {
  10020. const prevHeight = i > 0 ? rects[i - 1].height : 0;
  10021. const reachTop = props.sticky ? prevHeight + props.stickyOffsetTop : 0;
  10022. if (scrollTop + reachTop >= rects[i].top) {
  10023. return i;
  10024. }
  10025. }
  10026. return -1;
  10027. };
  10028. const getMatchAnchor = (index) => children.find((item) => String(item.index) === index);
  10029. const onScroll = () => {
  10030. if (isHidden(root)) {
  10031. return;
  10032. }
  10033. const {
  10034. sticky,
  10035. indexList
  10036. } = props;
  10037. const scrollTop = getScrollTop(scrollParent.value);
  10038. const scrollParentRect = useRect(scrollParent);
  10039. const rects = children.map((item) => item.getRect(scrollParent.value, scrollParentRect));
  10040. let active = -1;
  10041. if (selectActiveIndex) {
  10042. const match = getMatchAnchor(selectActiveIndex);
  10043. if (match) {
  10044. const rect = match.getRect(scrollParent.value, scrollParentRect);
  10045. active = getActiveAnchor(rect.top, rects);
  10046. }
  10047. } else {
  10048. active = getActiveAnchor(scrollTop, rects);
  10049. }
  10050. activeAnchor.value = indexList[active];
  10051. if (sticky) {
  10052. children.forEach((item, index) => {
  10053. const {
  10054. state,
  10055. $el
  10056. } = item;
  10057. if (index === active || index === active - 1) {
  10058. const rect = $el.getBoundingClientRect();
  10059. state.left = rect.left;
  10060. state.width = rect.width;
  10061. } else {
  10062. state.left = null;
  10063. state.width = null;
  10064. }
  10065. if (index === active) {
  10066. state.active = true;
  10067. state.top = Math.max(props.stickyOffsetTop, rects[index].top - scrollTop) + scrollParentRect.top;
  10068. } else if (index === active - 1 && selectActiveIndex === "") {
  10069. const activeItemTop = rects[active].top - scrollTop;
  10070. state.active = activeItemTop > 0;
  10071. state.top = activeItemTop + scrollParentRect.top - rects[index].height;
  10072. } else {
  10073. state.active = false;
  10074. }
  10075. });
  10076. }
  10077. selectActiveIndex = "";
  10078. };
  10079. const init = () => {
  10080. nextTick(onScroll);
  10081. };
  10082. useEventListener("scroll", onScroll, {
  10083. target: scrollParent,
  10084. passive: true
  10085. });
  10086. onMounted(init);
  10087. watch(() => props.indexList, init);
  10088. watch(activeAnchor, (value) => {
  10089. if (value) {
  10090. emit("change", value);
  10091. }
  10092. });
  10093. const renderIndexes = () => props.indexList.map((index) => {
  10094. const active = index === activeAnchor.value;
  10095. return createVNode("span", {
  10096. "class": bem$x("index", {
  10097. active
  10098. }),
  10099. "style": active ? highlightStyle.value : void 0,
  10100. "data-index": index
  10101. }, [index]);
  10102. });
  10103. const scrollTo = (index) => {
  10104. selectActiveIndex = String(index);
  10105. const match = getMatchAnchor(selectActiveIndex);
  10106. if (match) {
  10107. const scrollTop = getScrollTop(scrollParent.value);
  10108. const scrollParentRect = useRect(scrollParent);
  10109. const {
  10110. offsetHeight
  10111. } = document.documentElement;
  10112. match.$el.scrollIntoView();
  10113. if (scrollTop === offsetHeight - scrollParentRect.height) {
  10114. onScroll();
  10115. return;
  10116. }
  10117. if (props.sticky && props.stickyOffsetTop) {
  10118. setRootScrollTop(getRootScrollTop() - props.stickyOffsetTop);
  10119. }
  10120. emit("select", match.index);
  10121. }
  10122. };
  10123. const scrollToElement = (element) => {
  10124. const {
  10125. index
  10126. } = element.dataset;
  10127. if (index) {
  10128. scrollTo(index);
  10129. }
  10130. };
  10131. const onClickSidebar = (event) => {
  10132. scrollToElement(event.target);
  10133. };
  10134. let touchActiveIndex;
  10135. const onTouchMove = (event) => {
  10136. touch.move(event);
  10137. if (touch.isVertical()) {
  10138. preventDefault(event);
  10139. const {
  10140. clientX,
  10141. clientY
  10142. } = event.touches[0];
  10143. const target = document.elementFromPoint(clientX, clientY);
  10144. if (target) {
  10145. const {
  10146. index
  10147. } = target.dataset;
  10148. if (index && touchActiveIndex !== index) {
  10149. touchActiveIndex = index;
  10150. scrollToElement(target);
  10151. }
  10152. }
  10153. }
  10154. };
  10155. const renderSidebar = () => createVNode("div", {
  10156. "ref": sidebar,
  10157. "class": bem$x("sidebar"),
  10158. "style": sidebarStyle.value,
  10159. "onClick": onClickSidebar,
  10160. "onTouchstartPassive": touch.start
  10161. }, [renderIndexes()]);
  10162. useExpose({
  10163. scrollTo
  10164. });
  10165. useEventListener("touchmove", onTouchMove, {
  10166. target: sidebar
  10167. });
  10168. return () => {
  10169. var _a;
  10170. return createVNode("div", {
  10171. "ref": root,
  10172. "class": bem$x()
  10173. }, [props.teleport ? createVNode(Teleport, {
  10174. "to": props.teleport
  10175. }, {
  10176. default: () => [renderSidebar()]
  10177. }) : renderSidebar(), (_a = slots.default) == null ? void 0 : _a.call(slots)]);
  10178. };
  10179. }
  10180. });
  10181. const [name$x, bem$w] = createNamespace("index-anchor");
  10182. const indexAnchorProps = {
  10183. index: numericProp
  10184. };
  10185. var stdin_default$C = defineComponent({
  10186. name: name$x,
  10187. props: indexAnchorProps,
  10188. setup(props, {
  10189. slots
  10190. }) {
  10191. const state = reactive({
  10192. top: 0,
  10193. left: null,
  10194. rect: {
  10195. top: 0,
  10196. height: 0
  10197. },
  10198. width: null,
  10199. active: false
  10200. });
  10201. const root = ref();
  10202. const {
  10203. parent
  10204. } = useParent(INDEX_BAR_KEY);
  10205. if (!parent) {
  10206. if (process.env.NODE_ENV !== "production") {
  10207. console.error("[Vant] <IndexAnchor> must be a child component of <IndexBar>.");
  10208. }
  10209. return;
  10210. }
  10211. const isSticky = () => state.active && parent.props.sticky;
  10212. const anchorStyle = computed(() => {
  10213. const {
  10214. zIndex,
  10215. highlightColor
  10216. } = parent.props;
  10217. if (isSticky()) {
  10218. return extend(getZIndexStyle(zIndex), {
  10219. left: state.left ? `${state.left}px` : void 0,
  10220. width: state.width ? `${state.width}px` : void 0,
  10221. transform: state.top ? `translate3d(0, ${state.top}px, 0)` : void 0,
  10222. color: highlightColor
  10223. });
  10224. }
  10225. });
  10226. const getRect = (scrollParent, scrollParentRect) => {
  10227. const rootRect = useRect(root);
  10228. state.rect.height = rootRect.height;
  10229. if (scrollParent === window || scrollParent === document.body) {
  10230. state.rect.top = rootRect.top + getRootScrollTop();
  10231. } else {
  10232. state.rect.top = rootRect.top + getScrollTop(scrollParent) - scrollParentRect.top;
  10233. }
  10234. return state.rect;
  10235. };
  10236. useExpose({
  10237. state,
  10238. getRect
  10239. });
  10240. return () => {
  10241. const sticky = isSticky();
  10242. return createVNode("div", {
  10243. "ref": root,
  10244. "style": {
  10245. height: sticky ? `${state.rect.height}px` : void 0
  10246. }
  10247. }, [createVNode("div", {
  10248. "style": anchorStyle.value,
  10249. "class": [bem$w({
  10250. sticky
  10251. }), {
  10252. [BORDER_BOTTOM]: sticky
  10253. }]
  10254. }, [slots.default ? slots.default() : props.index])]);
  10255. };
  10256. }
  10257. });
  10258. const IndexAnchor = withInstall(stdin_default$C);
  10259. const IndexBar = withInstall(stdin_default$D);
  10260. const [name$w, bem$v, t$6] = createNamespace("list");
  10261. const listProps = {
  10262. error: Boolean,
  10263. offset: makeNumericProp(300),
  10264. loading: Boolean,
  10265. disabled: Boolean,
  10266. finished: Boolean,
  10267. errorText: String,
  10268. direction: makeStringProp("down"),
  10269. loadingText: String,
  10270. finishedText: String,
  10271. immediateCheck: truthProp
  10272. };
  10273. var stdin_default$B = defineComponent({
  10274. name: name$w,
  10275. props: listProps,
  10276. emits: ["load", "update:error", "update:loading"],
  10277. setup(props, {
  10278. emit,
  10279. slots
  10280. }) {
  10281. const loading = ref(props.loading);
  10282. const root = ref();
  10283. const placeholder = ref();
  10284. const tabStatus = useTabStatus();
  10285. const scrollParent = useScrollParent(root);
  10286. const check = () => {
  10287. nextTick(() => {
  10288. if (loading.value || props.finished || props.disabled || props.error || (tabStatus == null ? void 0 : tabStatus.value) === false) {
  10289. return;
  10290. }
  10291. const {
  10292. offset,
  10293. direction
  10294. } = props;
  10295. const scrollParentRect = useRect(scrollParent);
  10296. if (!scrollParentRect.height || isHidden(root)) {
  10297. return;
  10298. }
  10299. let isReachEdge = false;
  10300. const placeholderRect = useRect(placeholder);
  10301. if (direction === "up") {
  10302. isReachEdge = scrollParentRect.top - placeholderRect.top <= offset;
  10303. } else {
  10304. isReachEdge = placeholderRect.bottom - scrollParentRect.bottom <= offset;
  10305. }
  10306. if (isReachEdge) {
  10307. loading.value = true;
  10308. emit("update:loading", true);
  10309. emit("load");
  10310. }
  10311. });
  10312. };
  10313. const renderFinishedText = () => {
  10314. if (props.finished) {
  10315. const text = slots.finished ? slots.finished() : props.finishedText;
  10316. if (text) {
  10317. return createVNode("div", {
  10318. "class": bem$v("finished-text")
  10319. }, [text]);
  10320. }
  10321. }
  10322. };
  10323. const clickErrorText = () => {
  10324. emit("update:error", false);
  10325. check();
  10326. };
  10327. const renderErrorText = () => {
  10328. if (props.error) {
  10329. const text = slots.error ? slots.error() : props.errorText;
  10330. if (text) {
  10331. return createVNode("div", {
  10332. "role": "button",
  10333. "class": bem$v("error-text"),
  10334. "tabindex": 0,
  10335. "onClick": clickErrorText
  10336. }, [text]);
  10337. }
  10338. }
  10339. };
  10340. const renderLoading = () => {
  10341. if (loading.value && !props.finished && !props.disabled) {
  10342. return createVNode("div", {
  10343. "class": bem$v("loading")
  10344. }, [slots.loading ? slots.loading() : createVNode(Loading, {
  10345. "class": bem$v("loading-icon")
  10346. }, {
  10347. default: () => [props.loadingText || t$6("loading")]
  10348. })]);
  10349. }
  10350. };
  10351. watch(() => [props.loading, props.finished, props.error], check);
  10352. if (tabStatus) {
  10353. watch(tabStatus, (tabActive) => {
  10354. if (tabActive) {
  10355. check();
  10356. }
  10357. });
  10358. }
  10359. onUpdated(() => {
  10360. loading.value = props.loading;
  10361. });
  10362. onMounted(() => {
  10363. if (props.immediateCheck) {
  10364. check();
  10365. }
  10366. });
  10367. useExpose({
  10368. check
  10369. });
  10370. useEventListener("scroll", check, {
  10371. target: scrollParent,
  10372. passive: true
  10373. });
  10374. return () => {
  10375. var _a;
  10376. const Content = (_a = slots.default) == null ? void 0 : _a.call(slots);
  10377. const Placeholder = createVNode("div", {
  10378. "ref": placeholder,
  10379. "class": bem$v("placeholder")
  10380. }, null);
  10381. return createVNode("div", {
  10382. "ref": root,
  10383. "role": "feed",
  10384. "class": bem$v(),
  10385. "aria-busy": loading.value
  10386. }, [props.direction === "down" ? Content : Placeholder, renderLoading(), renderFinishedText(), renderErrorText(), props.direction === "up" ? Content : Placeholder]);
  10387. };
  10388. }
  10389. });
  10390. const List = withInstall(stdin_default$B);
  10391. const [name$v, bem$u] = createNamespace("nav-bar");
  10392. const navBarProps = {
  10393. title: String,
  10394. fixed: Boolean,
  10395. zIndex: numericProp,
  10396. border: truthProp,
  10397. leftText: String,
  10398. rightText: String,
  10399. leftArrow: Boolean,
  10400. placeholder: Boolean,
  10401. safeAreaInsetTop: Boolean,
  10402. clickable: truthProp
  10403. };
  10404. var stdin_default$A = defineComponent({
  10405. name: name$v,
  10406. props: navBarProps,
  10407. emits: ["clickLeft", "clickRight"],
  10408. setup(props, {
  10409. emit,
  10410. slots
  10411. }) {
  10412. const navBarRef = ref();
  10413. const renderPlaceholder = usePlaceholder(navBarRef, bem$u);
  10414. const onClickLeft = (event) => emit("clickLeft", event);
  10415. const onClickRight = (event) => emit("clickRight", event);
  10416. const renderLeft = () => {
  10417. if (slots.left) {
  10418. return slots.left();
  10419. }
  10420. return [props.leftArrow && createVNode(Icon, {
  10421. "class": bem$u("arrow"),
  10422. "name": "arrow-left"
  10423. }, null), props.leftText && createVNode("span", {
  10424. "class": bem$u("text")
  10425. }, [props.leftText])];
  10426. };
  10427. const renderRight = () => {
  10428. if (slots.right) {
  10429. return slots.right();
  10430. }
  10431. return createVNode("span", {
  10432. "class": bem$u("text")
  10433. }, [props.rightText]);
  10434. };
  10435. const renderNavBar = () => {
  10436. const {
  10437. title,
  10438. fixed,
  10439. border,
  10440. zIndex
  10441. } = props;
  10442. const style = getZIndexStyle(zIndex);
  10443. const hasLeft = props.leftArrow || props.leftText || slots.left;
  10444. const hasRight = props.rightText || slots.right;
  10445. return createVNode("div", {
  10446. "ref": navBarRef,
  10447. "style": style,
  10448. "class": [bem$u({
  10449. fixed
  10450. }), {
  10451. [BORDER_BOTTOM]: border,
  10452. "van-safe-area-top": props.safeAreaInsetTop
  10453. }]
  10454. }, [createVNode("div", {
  10455. "class": bem$u("content")
  10456. }, [hasLeft && createVNode("div", {
  10457. "class": [bem$u("left"), props.clickable ? HAPTICS_FEEDBACK : ""],
  10458. "onClick": onClickLeft
  10459. }, [renderLeft()]), createVNode("div", {
  10460. "class": [bem$u("title"), "van-ellipsis"]
  10461. }, [slots.title ? slots.title() : title]), hasRight && createVNode("div", {
  10462. "class": [bem$u("right"), props.clickable ? HAPTICS_FEEDBACK : ""],
  10463. "onClick": onClickRight
  10464. }, [renderRight()])])]);
  10465. };
  10466. return () => {
  10467. if (props.fixed && props.placeholder) {
  10468. return renderPlaceholder(renderNavBar);
  10469. }
  10470. return renderNavBar();
  10471. };
  10472. }
  10473. });
  10474. const NavBar = withInstall(stdin_default$A);
  10475. const [name$u, bem$t] = createNamespace("notice-bar");
  10476. const noticeBarProps = {
  10477. text: String,
  10478. mode: String,
  10479. color: String,
  10480. delay: makeNumericProp(1),
  10481. speed: makeNumericProp(60),
  10482. leftIcon: String,
  10483. wrapable: Boolean,
  10484. background: String,
  10485. scrollable: {
  10486. type: Boolean,
  10487. default: null
  10488. }
  10489. };
  10490. var stdin_default$z = defineComponent({
  10491. name: name$u,
  10492. props: noticeBarProps,
  10493. emits: ["close", "replay"],
  10494. setup(props, {
  10495. emit,
  10496. slots
  10497. }) {
  10498. let wrapWidth = 0;
  10499. let contentWidth = 0;
  10500. let startTimer;
  10501. const wrapRef = ref();
  10502. const contentRef = ref();
  10503. const state = reactive({
  10504. show: true,
  10505. offset: 0,
  10506. duration: 0
  10507. });
  10508. const renderLeftIcon = () => {
  10509. if (slots["left-icon"]) {
  10510. return slots["left-icon"]();
  10511. }
  10512. if (props.leftIcon) {
  10513. return createVNode(Icon, {
  10514. "class": bem$t("left-icon"),
  10515. "name": props.leftIcon
  10516. }, null);
  10517. }
  10518. };
  10519. const getRightIconName = () => {
  10520. if (props.mode === "closeable") {
  10521. return "cross";
  10522. }
  10523. if (props.mode === "link") {
  10524. return "arrow";
  10525. }
  10526. };
  10527. const onClickRightIcon = (event) => {
  10528. if (props.mode === "closeable") {
  10529. state.show = false;
  10530. emit("close", event);
  10531. }
  10532. };
  10533. const renderRightIcon = () => {
  10534. if (slots["right-icon"]) {
  10535. return slots["right-icon"]();
  10536. }
  10537. const name2 = getRightIconName();
  10538. if (name2) {
  10539. return createVNode(Icon, {
  10540. "name": name2,
  10541. "class": bem$t("right-icon"),
  10542. "onClick": onClickRightIcon
  10543. }, null);
  10544. }
  10545. };
  10546. const onTransitionEnd = () => {
  10547. state.offset = wrapWidth;
  10548. state.duration = 0;
  10549. raf(() => {
  10550. doubleRaf(() => {
  10551. state.offset = -contentWidth;
  10552. state.duration = (contentWidth + wrapWidth) / +props.speed;
  10553. emit("replay");
  10554. });
  10555. });
  10556. };
  10557. const renderMarquee = () => {
  10558. const ellipsis = props.scrollable === false && !props.wrapable;
  10559. const style = {
  10560. transform: state.offset ? `translateX(${state.offset}px)` : "",
  10561. transitionDuration: `${state.duration}s`
  10562. };
  10563. return createVNode("div", {
  10564. "ref": wrapRef,
  10565. "role": "marquee",
  10566. "class": bem$t("wrap")
  10567. }, [createVNode("div", {
  10568. "ref": contentRef,
  10569. "style": style,
  10570. "class": [bem$t("content"), {
  10571. "van-ellipsis": ellipsis
  10572. }],
  10573. "onTransitionend": onTransitionEnd
  10574. }, [slots.default ? slots.default() : props.text])]);
  10575. };
  10576. const reset = () => {
  10577. const {
  10578. delay,
  10579. speed,
  10580. scrollable
  10581. } = props;
  10582. const ms = isDef(delay) ? +delay * 1e3 : 0;
  10583. wrapWidth = 0;
  10584. contentWidth = 0;
  10585. state.offset = 0;
  10586. state.duration = 0;
  10587. clearTimeout(startTimer);
  10588. startTimer = setTimeout(() => {
  10589. if (!wrapRef.value || !contentRef.value || scrollable === false) {
  10590. return;
  10591. }
  10592. const wrapRefWidth = useRect(wrapRef).width;
  10593. const contentRefWidth = useRect(contentRef).width;
  10594. if (scrollable || contentRefWidth > wrapRefWidth) {
  10595. doubleRaf(() => {
  10596. wrapWidth = wrapRefWidth;
  10597. contentWidth = contentRefWidth;
  10598. state.offset = -contentWidth;
  10599. state.duration = contentWidth / +speed;
  10600. });
  10601. }
  10602. }, ms);
  10603. };
  10604. onPopupReopen(reset);
  10605. onMountedOrActivated(reset);
  10606. useEventListener("pageshow", reset);
  10607. useExpose({
  10608. reset
  10609. });
  10610. watch(() => [props.text, props.scrollable], reset);
  10611. return () => {
  10612. const {
  10613. color,
  10614. wrapable,
  10615. background
  10616. } = props;
  10617. return withDirectives(createVNode("div", {
  10618. "role": "alert",
  10619. "class": bem$t({
  10620. wrapable
  10621. }),
  10622. "style": {
  10623. color,
  10624. background
  10625. }
  10626. }, [renderLeftIcon(), renderMarquee(), renderRightIcon()]), [[vShow, state.show]]);
  10627. };
  10628. }
  10629. });
  10630. const NoticeBar = withInstall(stdin_default$z);
  10631. const [name$t, bem$s] = createNamespace("notify");
  10632. const notifyProps = extend({}, popupSharedProps, {
  10633. type: makeStringProp("danger"),
  10634. color: String,
  10635. message: numericProp,
  10636. position: makeStringProp("top"),
  10637. className: unknownProp,
  10638. background: String,
  10639. lockScroll: Boolean
  10640. });
  10641. var stdin_default$y = defineComponent({
  10642. name: name$t,
  10643. props: notifyProps,
  10644. emits: ["update:show"],
  10645. setup(props, {
  10646. emit,
  10647. slots
  10648. }) {
  10649. const updateShow = (show) => emit("update:show", show);
  10650. return () => createVNode(Popup, {
  10651. "show": props.show,
  10652. "class": [bem$s([props.type]), props.className],
  10653. "style": {
  10654. color: props.color,
  10655. background: props.background
  10656. },
  10657. "overlay": false,
  10658. "zIndex": props.zIndex,
  10659. "position": props.position,
  10660. "duration": 0.2,
  10661. "lockScroll": props.lockScroll,
  10662. "onUpdate:show": updateShow
  10663. }, {
  10664. default: () => [slots.default ? slots.default() : props.message]
  10665. });
  10666. }
  10667. });
  10668. let timer;
  10669. let instance;
  10670. const parseOptions = (message) => isObject(message) ? message : {
  10671. message
  10672. };
  10673. function initInstance() {
  10674. ({
  10675. instance
  10676. } = mountComponent({
  10677. setup() {
  10678. const {
  10679. state,
  10680. toggle
  10681. } = usePopupState();
  10682. return () => createVNode(stdin_default$y, mergeProps(state, {
  10683. "onUpdate:show": toggle
  10684. }), null);
  10685. }
  10686. }));
  10687. }
  10688. const getDefaultOptions = () => ({
  10689. type: "danger",
  10690. color: void 0,
  10691. message: "",
  10692. onClose: void 0,
  10693. onClick: void 0,
  10694. onOpened: void 0,
  10695. duration: 3e3,
  10696. position: void 0,
  10697. className: "",
  10698. lockScroll: false,
  10699. background: void 0
  10700. });
  10701. let currentOptions = getDefaultOptions();
  10702. const closeNotify = () => {
  10703. if (instance) {
  10704. instance.toggle(false);
  10705. }
  10706. };
  10707. function showNotify(options) {
  10708. if (!inBrowser) {
  10709. return;
  10710. }
  10711. if (!instance) {
  10712. initInstance();
  10713. }
  10714. options = extend({}, currentOptions, parseOptions(options));
  10715. instance.open(options);
  10716. clearTimeout(timer);
  10717. if (options.duration > 0) {
  10718. timer = setTimeout(closeNotify, options.duration);
  10719. }
  10720. return instance;
  10721. }
  10722. const setNotifyDefaultOptions = (options) => extend(currentOptions, options);
  10723. const resetNotifyDefaultOptions = () => {
  10724. currentOptions = getDefaultOptions();
  10725. };
  10726. const Notify = withInstall(stdin_default$y);
  10727. const [name$s, bem$r] = createNamespace("key");
  10728. const CollapseIcon = createVNode("svg", {
  10729. "class": bem$r("collapse-icon"),
  10730. "viewBox": "0 0 30 24"
  10731. }, [createVNode("path", {
  10732. "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",
  10733. "fill": "currentColor"
  10734. }, null)]);
  10735. const DeleteIcon = createVNode("svg", {
  10736. "class": bem$r("delete-icon"),
  10737. "viewBox": "0 0 32 22"
  10738. }, [createVNode("path", {
  10739. "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",
  10740. "fill": "currentColor"
  10741. }, null)]);
  10742. var stdin_default$x = defineComponent({
  10743. name: name$s,
  10744. props: {
  10745. type: String,
  10746. text: numericProp,
  10747. color: String,
  10748. wider: Boolean,
  10749. large: Boolean,
  10750. loading: Boolean
  10751. },
  10752. emits: ["press"],
  10753. setup(props, {
  10754. emit,
  10755. slots
  10756. }) {
  10757. const active = ref(false);
  10758. const touch = useTouch();
  10759. const onTouchStart = (event) => {
  10760. touch.start(event);
  10761. active.value = true;
  10762. };
  10763. const onTouchMove = (event) => {
  10764. touch.move(event);
  10765. if (touch.direction.value) {
  10766. active.value = false;
  10767. }
  10768. };
  10769. const onTouchEnd = (event) => {
  10770. if (active.value) {
  10771. if (!slots.default) {
  10772. preventDefault(event);
  10773. }
  10774. active.value = false;
  10775. emit("press", props.text, props.type);
  10776. }
  10777. };
  10778. const renderContent = () => {
  10779. if (props.loading) {
  10780. return createVNode(Loading, {
  10781. "class": bem$r("loading-icon")
  10782. }, null);
  10783. }
  10784. const text = slots.default ? slots.default() : props.text;
  10785. switch (props.type) {
  10786. case "delete":
  10787. return text || DeleteIcon;
  10788. case "extra":
  10789. return text || CollapseIcon;
  10790. default:
  10791. return text;
  10792. }
  10793. };
  10794. return () => createVNode("div", {
  10795. "class": bem$r("wrapper", {
  10796. wider: props.wider
  10797. }),
  10798. "onTouchstartPassive": onTouchStart,
  10799. "onTouchmovePassive": onTouchMove,
  10800. "onTouchend": onTouchEnd,
  10801. "onTouchcancel": onTouchEnd
  10802. }, [createVNode("div", {
  10803. "role": "button",
  10804. "tabindex": 0,
  10805. "class": bem$r([props.color, {
  10806. large: props.large,
  10807. active: active.value,
  10808. delete: props.type === "delete"
  10809. }])
  10810. }, [renderContent()])]);
  10811. }
  10812. });
  10813. const [name$r, bem$q] = createNamespace("number-keyboard");
  10814. const numberKeyboardProps = {
  10815. show: Boolean,
  10816. title: String,
  10817. theme: makeStringProp("default"),
  10818. zIndex: numericProp,
  10819. teleport: [String, Object],
  10820. maxlength: makeNumericProp(Infinity),
  10821. modelValue: makeStringProp(""),
  10822. transition: truthProp,
  10823. blurOnClose: truthProp,
  10824. showDeleteKey: truthProp,
  10825. randomKeyOrder: Boolean,
  10826. closeButtonText: String,
  10827. deleteButtonText: String,
  10828. closeButtonLoading: Boolean,
  10829. hideOnClickOutside: truthProp,
  10830. safeAreaInsetBottom: truthProp,
  10831. extraKey: {
  10832. type: [String, Array],
  10833. default: ""
  10834. }
  10835. };
  10836. function shuffle(array) {
  10837. for (let i = array.length - 1; i > 0; i--) {
  10838. const j = Math.floor(Math.random() * (i + 1));
  10839. const temp = array[i];
  10840. array[i] = array[j];
  10841. array[j] = temp;
  10842. }
  10843. return array;
  10844. }
  10845. var stdin_default$w = defineComponent({
  10846. name: name$r,
  10847. inheritAttrs: false,
  10848. props: numberKeyboardProps,
  10849. emits: ["show", "hide", "blur", "input", "close", "delete", "update:modelValue"],
  10850. setup(props, {
  10851. emit,
  10852. slots,
  10853. attrs
  10854. }) {
  10855. const root = ref();
  10856. const genBasicKeys = () => {
  10857. const keys2 = Array(9).fill("").map((_, i) => ({
  10858. text: i + 1
  10859. }));
  10860. if (props.randomKeyOrder) {
  10861. shuffle(keys2);
  10862. }
  10863. return keys2;
  10864. };
  10865. const genDefaultKeys = () => [...genBasicKeys(), {
  10866. text: props.extraKey,
  10867. type: "extra"
  10868. }, {
  10869. text: 0
  10870. }, {
  10871. text: props.showDeleteKey ? props.deleteButtonText : "",
  10872. type: props.showDeleteKey ? "delete" : ""
  10873. }];
  10874. const genCustomKeys = () => {
  10875. const keys2 = genBasicKeys();
  10876. const {
  10877. extraKey
  10878. } = props;
  10879. const extraKeys = Array.isArray(extraKey) ? extraKey : [extraKey];
  10880. if (extraKeys.length === 1) {
  10881. keys2.push({
  10882. text: 0,
  10883. wider: true
  10884. }, {
  10885. text: extraKeys[0],
  10886. type: "extra"
  10887. });
  10888. } else if (extraKeys.length === 2) {
  10889. keys2.push({
  10890. text: extraKeys[0],
  10891. type: "extra"
  10892. }, {
  10893. text: 0
  10894. }, {
  10895. text: extraKeys[1],
  10896. type: "extra"
  10897. });
  10898. }
  10899. return keys2;
  10900. };
  10901. const keys = computed(() => props.theme === "custom" ? genCustomKeys() : genDefaultKeys());
  10902. const onBlur = () => {
  10903. if (props.show) {
  10904. emit("blur");
  10905. }
  10906. };
  10907. const onClose = () => {
  10908. emit("close");
  10909. if (props.blurOnClose) {
  10910. onBlur();
  10911. }
  10912. };
  10913. const onAnimationEnd = () => emit(props.show ? "show" : "hide");
  10914. const onPress = (text, type) => {
  10915. if (text === "") {
  10916. if (type === "extra") {
  10917. onBlur();
  10918. }
  10919. return;
  10920. }
  10921. const value = props.modelValue;
  10922. if (type === "delete") {
  10923. emit("delete");
  10924. emit("update:modelValue", value.slice(0, value.length - 1));
  10925. } else if (type === "close") {
  10926. onClose();
  10927. } else if (value.length < props.maxlength) {
  10928. emit("input", text);
  10929. emit("update:modelValue", value + text);
  10930. }
  10931. };
  10932. const renderTitle = () => {
  10933. const {
  10934. title,
  10935. theme,
  10936. closeButtonText
  10937. } = props;
  10938. const leftSlot = slots["title-left"];
  10939. const showClose = closeButtonText && theme === "default";
  10940. const showTitle = title || showClose || leftSlot;
  10941. if (!showTitle) {
  10942. return;
  10943. }
  10944. return createVNode("div", {
  10945. "class": bem$q("header")
  10946. }, [leftSlot && createVNode("span", {
  10947. "class": bem$q("title-left")
  10948. }, [leftSlot()]), title && createVNode("h2", {
  10949. "class": bem$q("title")
  10950. }, [title]), showClose && createVNode("button", {
  10951. "type": "button",
  10952. "class": [bem$q("close"), HAPTICS_FEEDBACK],
  10953. "onClick": onClose
  10954. }, [closeButtonText])]);
  10955. };
  10956. const renderKeys = () => keys.value.map((key) => {
  10957. const keySlots = {};
  10958. if (key.type === "delete") {
  10959. keySlots.default = slots.delete;
  10960. }
  10961. if (key.type === "extra") {
  10962. keySlots.default = slots["extra-key"];
  10963. }
  10964. return createVNode(stdin_default$x, {
  10965. "key": key.text,
  10966. "text": key.text,
  10967. "type": key.type,
  10968. "wider": key.wider,
  10969. "color": key.color,
  10970. "onPress": onPress
  10971. }, keySlots);
  10972. });
  10973. const renderSidebar = () => {
  10974. if (props.theme === "custom") {
  10975. return createVNode("div", {
  10976. "class": bem$q("sidebar")
  10977. }, [props.showDeleteKey && createVNode(stdin_default$x, {
  10978. "large": true,
  10979. "text": props.deleteButtonText,
  10980. "type": "delete",
  10981. "onPress": onPress
  10982. }, {
  10983. delete: slots.delete
  10984. }), createVNode(stdin_default$x, {
  10985. "large": true,
  10986. "text": props.closeButtonText,
  10987. "type": "close",
  10988. "color": "blue",
  10989. "loading": props.closeButtonLoading,
  10990. "onPress": onPress
  10991. }, null)]);
  10992. }
  10993. };
  10994. watch(() => props.show, (value) => {
  10995. if (!props.transition) {
  10996. emit(value ? "show" : "hide");
  10997. }
  10998. });
  10999. if (props.hideOnClickOutside) {
  11000. useClickAway(root, onBlur, {
  11001. eventName: "touchstart"
  11002. });
  11003. }
  11004. return () => {
  11005. const Title = renderTitle();
  11006. const Content = createVNode(Transition, {
  11007. "name": props.transition ? "van-slide-up" : ""
  11008. }, {
  11009. default: () => [withDirectives(createVNode("div", mergeProps({
  11010. "ref": root,
  11011. "style": getZIndexStyle(props.zIndex),
  11012. "class": bem$q({
  11013. unfit: !props.safeAreaInsetBottom,
  11014. "with-title": !!Title
  11015. }),
  11016. "onAnimationend": onAnimationEnd,
  11017. "onTouchstartPassive": stopPropagation
  11018. }, attrs), [Title, createVNode("div", {
  11019. "class": bem$q("body")
  11020. }, [createVNode("div", {
  11021. "class": bem$q("keys")
  11022. }, [renderKeys()]), renderSidebar()])]), [[vShow, props.show]])]
  11023. });
  11024. if (props.teleport) {
  11025. return createVNode(Teleport, {
  11026. "to": props.teleport
  11027. }, {
  11028. default: () => [Content]
  11029. });
  11030. }
  11031. return Content;
  11032. };
  11033. }
  11034. });
  11035. const NumberKeyboard = withInstall(stdin_default$w);
  11036. const [name$q, bem$p, t$5] = createNamespace("pagination");
  11037. const makePage = (number, text, active) => ({
  11038. number,
  11039. text,
  11040. active
  11041. });
  11042. const paginationProps = {
  11043. mode: makeStringProp("multi"),
  11044. prevText: String,
  11045. nextText: String,
  11046. pageCount: makeNumericProp(0),
  11047. modelValue: makeNumberProp(0),
  11048. totalItems: makeNumericProp(0),
  11049. showPageSize: makeNumericProp(5),
  11050. itemsPerPage: makeNumericProp(10),
  11051. forceEllipses: Boolean
  11052. };
  11053. var stdin_default$v = defineComponent({
  11054. name: name$q,
  11055. props: paginationProps,
  11056. emits: ["change", "update:modelValue"],
  11057. setup(props, {
  11058. emit,
  11059. slots
  11060. }) {
  11061. const count = computed(() => {
  11062. const {
  11063. pageCount,
  11064. totalItems,
  11065. itemsPerPage
  11066. } = props;
  11067. const count2 = +pageCount || Math.ceil(+totalItems / +itemsPerPage);
  11068. return Math.max(1, count2);
  11069. });
  11070. const pages = computed(() => {
  11071. const items = [];
  11072. const pageCount = count.value;
  11073. const showPageSize = +props.showPageSize;
  11074. const {
  11075. modelValue,
  11076. forceEllipses
  11077. } = props;
  11078. let startPage = 1;
  11079. let endPage = pageCount;
  11080. const isMaxSized = showPageSize < pageCount;
  11081. if (isMaxSized) {
  11082. startPage = Math.max(modelValue - Math.floor(showPageSize / 2), 1);
  11083. endPage = startPage + showPageSize - 1;
  11084. if (endPage > pageCount) {
  11085. endPage = pageCount;
  11086. startPage = endPage - showPageSize + 1;
  11087. }
  11088. }
  11089. for (let number = startPage; number <= endPage; number++) {
  11090. const page = makePage(number, number, number === modelValue);
  11091. items.push(page);
  11092. }
  11093. if (isMaxSized && showPageSize > 0 && forceEllipses) {
  11094. if (startPage > 1) {
  11095. const prevPages = makePage(startPage - 1, "...");
  11096. items.unshift(prevPages);
  11097. }
  11098. if (endPage < pageCount) {
  11099. const nextPages = makePage(endPage + 1, "...");
  11100. items.push(nextPages);
  11101. }
  11102. }
  11103. return items;
  11104. });
  11105. const updateModelValue = (value, emitChange) => {
  11106. value = clamp(value, 1, count.value);
  11107. if (props.modelValue !== value) {
  11108. emit("update:modelValue", value);
  11109. if (emitChange) {
  11110. emit("change", value);
  11111. }
  11112. }
  11113. };
  11114. watchEffect(() => updateModelValue(props.modelValue));
  11115. const renderDesc = () => createVNode("li", {
  11116. "class": bem$p("page-desc")
  11117. }, [slots.pageDesc ? slots.pageDesc() : `${props.modelValue}/${count.value}`]);
  11118. const renderPrevButton = () => {
  11119. const {
  11120. mode,
  11121. modelValue
  11122. } = props;
  11123. const slot = slots["prev-text"];
  11124. const disabled = modelValue === 1;
  11125. return createVNode("li", {
  11126. "class": [bem$p("item", {
  11127. disabled,
  11128. border: mode === "simple",
  11129. prev: true
  11130. }), BORDER_SURROUND]
  11131. }, [createVNode("button", {
  11132. "type": "button",
  11133. "disabled": disabled,
  11134. "onClick": () => updateModelValue(modelValue - 1, true)
  11135. }, [slot ? slot() : props.prevText || t$5("prev")])]);
  11136. };
  11137. const renderNextButton = () => {
  11138. const {
  11139. mode,
  11140. modelValue
  11141. } = props;
  11142. const slot = slots["next-text"];
  11143. const disabled = modelValue === count.value;
  11144. return createVNode("li", {
  11145. "class": [bem$p("item", {
  11146. disabled,
  11147. border: mode === "simple",
  11148. next: true
  11149. }), BORDER_SURROUND]
  11150. }, [createVNode("button", {
  11151. "type": "button",
  11152. "disabled": disabled,
  11153. "onClick": () => updateModelValue(modelValue + 1, true)
  11154. }, [slot ? slot() : props.nextText || t$5("next")])]);
  11155. };
  11156. const renderPages = () => pages.value.map((page) => createVNode("li", {
  11157. "class": [bem$p("item", {
  11158. active: page.active,
  11159. page: true
  11160. }), BORDER_SURROUND]
  11161. }, [createVNode("button", {
  11162. "type": "button",
  11163. "aria-current": page.active || void 0,
  11164. "onClick": () => updateModelValue(page.number, true)
  11165. }, [slots.page ? slots.page(page) : page.text])]));
  11166. return () => createVNode("nav", {
  11167. "role": "navigation",
  11168. "class": bem$p()
  11169. }, [createVNode("ul", {
  11170. "class": bem$p("items")
  11171. }, [renderPrevButton(), props.mode === "simple" ? renderDesc() : renderPages(), renderNextButton()])]);
  11172. }
  11173. });
  11174. const Pagination = withInstall(stdin_default$v);
  11175. const [name$p, bem$o] = createNamespace("password-input");
  11176. const passwordInputProps = {
  11177. info: String,
  11178. mask: truthProp,
  11179. value: makeStringProp(""),
  11180. gutter: numericProp,
  11181. length: makeNumericProp(6),
  11182. focused: Boolean,
  11183. errorInfo: String
  11184. };
  11185. var stdin_default$u = defineComponent({
  11186. name: name$p,
  11187. props: passwordInputProps,
  11188. emits: ["focus"],
  11189. setup(props, {
  11190. emit
  11191. }) {
  11192. const onTouchStart = (event) => {
  11193. event.stopPropagation();
  11194. emit("focus", event);
  11195. };
  11196. const renderPoints = () => {
  11197. const Points = [];
  11198. const {
  11199. mask,
  11200. value,
  11201. length,
  11202. gutter,
  11203. focused
  11204. } = props;
  11205. for (let i = 0; i < length; i++) {
  11206. const char = value[i];
  11207. const showBorder = i !== 0 && !gutter;
  11208. const showCursor = focused && i === value.length;
  11209. let style;
  11210. if (i !== 0 && gutter) {
  11211. style = {
  11212. marginLeft: addUnit(gutter)
  11213. };
  11214. }
  11215. Points.push(createVNode("li", {
  11216. "class": [{
  11217. [BORDER_LEFT]: showBorder
  11218. }, bem$o("item", {
  11219. focus: showCursor
  11220. })],
  11221. "style": style
  11222. }, [mask ? createVNode("i", {
  11223. "style": {
  11224. visibility: char ? "visible" : "hidden"
  11225. }
  11226. }, null) : char, showCursor && createVNode("div", {
  11227. "class": bem$o("cursor")
  11228. }, null)]));
  11229. }
  11230. return Points;
  11231. };
  11232. return () => {
  11233. const info = props.errorInfo || props.info;
  11234. return createVNode("div", {
  11235. "class": bem$o()
  11236. }, [createVNode("ul", {
  11237. "class": [bem$o("security"), {
  11238. [BORDER_SURROUND]: !props.gutter
  11239. }],
  11240. "onTouchstartPassive": onTouchStart
  11241. }, [renderPoints()]), info && createVNode("div", {
  11242. "class": bem$o(props.errorInfo ? "error-info" : "info")
  11243. }, [info])]);
  11244. };
  11245. }
  11246. });
  11247. const PasswordInput = withInstall(stdin_default$u);
  11248. const PickerGroup = withInstall(stdin_default$1o);
  11249. const useSyncPropRef = (getProp, setProp) => {
  11250. const propRef = ref(getProp());
  11251. watch(getProp, (value) => {
  11252. if (value !== propRef.value) {
  11253. propRef.value = value;
  11254. }
  11255. });
  11256. watch(propRef, (value) => {
  11257. if (value !== getProp()) {
  11258. setProp(value);
  11259. }
  11260. });
  11261. return propRef;
  11262. };
  11263. const [name$o, bem$n] = createNamespace("popover");
  11264. const popupProps = ["overlay", "duration", "teleport", "overlayStyle", "overlayClass", "closeOnClickOverlay"];
  11265. const popoverProps = {
  11266. show: Boolean,
  11267. theme: makeStringProp("light"),
  11268. overlay: Boolean,
  11269. actions: makeArrayProp(),
  11270. trigger: makeStringProp("click"),
  11271. duration: numericProp,
  11272. showArrow: truthProp,
  11273. placement: makeStringProp("bottom"),
  11274. iconPrefix: String,
  11275. overlayClass: unknownProp,
  11276. overlayStyle: Object,
  11277. closeOnClickAction: truthProp,
  11278. closeOnClickOverlay: truthProp,
  11279. closeOnClickOutside: truthProp,
  11280. offset: {
  11281. type: Array,
  11282. default: () => [0, 8]
  11283. },
  11284. teleport: {
  11285. type: [String, Object],
  11286. default: "body"
  11287. }
  11288. };
  11289. var stdin_default$t = defineComponent({
  11290. name: name$o,
  11291. props: popoverProps,
  11292. emits: ["select", "touchstart", "update:show"],
  11293. setup(props, {
  11294. emit,
  11295. slots,
  11296. attrs
  11297. }) {
  11298. let popper;
  11299. const popupRef = ref();
  11300. const wrapperRef = ref();
  11301. const popoverRef = ref();
  11302. const show = useSyncPropRef(() => props.show, (value) => emit("update:show", value));
  11303. const getPopoverOptions = () => ({
  11304. placement: props.placement,
  11305. modifiers: [{
  11306. name: "computeStyles",
  11307. options: {
  11308. adaptive: false,
  11309. gpuAcceleration: false
  11310. }
  11311. }, extend({}, offsetModifier, {
  11312. options: {
  11313. offset: props.offset
  11314. }
  11315. })]
  11316. });
  11317. const createPopperInstance = () => {
  11318. if (wrapperRef.value && popoverRef.value) {
  11319. return createPopper(wrapperRef.value, popoverRef.value.popupRef.value, getPopoverOptions());
  11320. }
  11321. return null;
  11322. };
  11323. const updateLocation = () => {
  11324. nextTick(() => {
  11325. if (!show.value) {
  11326. return;
  11327. }
  11328. if (!popper) {
  11329. popper = createPopperInstance();
  11330. } else {
  11331. popper.setOptions(getPopoverOptions());
  11332. }
  11333. });
  11334. };
  11335. const updateShow = (value) => {
  11336. show.value = value;
  11337. };
  11338. const onClickWrapper = () => {
  11339. if (props.trigger === "click") {
  11340. show.value = !show.value;
  11341. }
  11342. };
  11343. const onClickAction = (action, index) => {
  11344. if (action.disabled) {
  11345. return;
  11346. }
  11347. emit("select", action, index);
  11348. if (props.closeOnClickAction) {
  11349. show.value = false;
  11350. }
  11351. };
  11352. const onClickAway = () => {
  11353. if (show.value && props.closeOnClickOutside && (!props.overlay || props.closeOnClickOverlay)) {
  11354. show.value = false;
  11355. }
  11356. };
  11357. const renderActionContent = (action, index) => {
  11358. if (slots.action) {
  11359. return slots.action({
  11360. action,
  11361. index
  11362. });
  11363. }
  11364. return [action.icon && createVNode(Icon, {
  11365. "name": action.icon,
  11366. "classPrefix": props.iconPrefix,
  11367. "class": bem$n("action-icon")
  11368. }, null), createVNode("div", {
  11369. "class": [bem$n("action-text"), BORDER_BOTTOM]
  11370. }, [action.text])];
  11371. };
  11372. const renderAction = (action, index) => {
  11373. const {
  11374. icon,
  11375. color,
  11376. disabled,
  11377. className
  11378. } = action;
  11379. return createVNode("div", {
  11380. "role": "menuitem",
  11381. "class": [bem$n("action", {
  11382. disabled,
  11383. "with-icon": icon
  11384. }), className],
  11385. "style": {
  11386. color
  11387. },
  11388. "tabindex": disabled ? void 0 : 0,
  11389. "aria-disabled": disabled || void 0,
  11390. "onClick": () => onClickAction(action, index)
  11391. }, [renderActionContent(action, index)]);
  11392. };
  11393. onMounted(() => {
  11394. updateLocation();
  11395. watchEffect(() => {
  11396. var _a;
  11397. popupRef.value = (_a = popoverRef.value) == null ? void 0 : _a.popupRef.value;
  11398. });
  11399. });
  11400. onBeforeUnmount(() => {
  11401. if (popper) {
  11402. popper.destroy();
  11403. popper = null;
  11404. }
  11405. });
  11406. watch(() => [show.value, props.offset, props.placement], updateLocation);
  11407. useClickAway([wrapperRef, popupRef], onClickAway, {
  11408. eventName: "touchstart"
  11409. });
  11410. return () => {
  11411. var _a;
  11412. return createVNode(Fragment, null, [createVNode("span", {
  11413. "ref": wrapperRef,
  11414. "class": bem$n("wrapper"),
  11415. "onClick": onClickWrapper
  11416. }, [(_a = slots.reference) == null ? void 0 : _a.call(slots)]), createVNode(Popup, mergeProps({
  11417. "ref": popoverRef,
  11418. "show": show.value,
  11419. "class": bem$n([props.theme]),
  11420. "position": "",
  11421. "transition": "van-popover-zoom",
  11422. "lockScroll": false,
  11423. "onUpdate:show": updateShow
  11424. }, attrs, pick(props, popupProps)), {
  11425. default: () => [props.showArrow && createVNode("div", {
  11426. "class": bem$n("arrow")
  11427. }, null), createVNode("div", {
  11428. "role": "menu",
  11429. "class": bem$n("content")
  11430. }, [slots.default ? slots.default() : props.actions.map(renderAction)])]
  11431. })]);
  11432. };
  11433. }
  11434. });
  11435. const Popover = withInstall(stdin_default$t);
  11436. const [name$n, bem$m] = createNamespace("progress");
  11437. const progressProps = {
  11438. color: String,
  11439. inactive: Boolean,
  11440. pivotText: String,
  11441. textColor: String,
  11442. showPivot: truthProp,
  11443. pivotColor: String,
  11444. trackColor: String,
  11445. strokeWidth: numericProp,
  11446. percentage: {
  11447. type: numericProp,
  11448. default: 0,
  11449. validator: (value) => value >= 0 && value <= 100
  11450. }
  11451. };
  11452. var stdin_default$s = defineComponent({
  11453. name: name$n,
  11454. props: progressProps,
  11455. setup(props) {
  11456. const background = computed(() => props.inactive ? void 0 : props.color);
  11457. const renderPivot = () => {
  11458. const {
  11459. textColor,
  11460. pivotText,
  11461. pivotColor,
  11462. percentage
  11463. } = props;
  11464. const text = pivotText != null ? pivotText : `${percentage}%`;
  11465. if (props.showPivot && text) {
  11466. const style = {
  11467. color: textColor,
  11468. left: `${+percentage}%`,
  11469. transform: `translate(-${+percentage}%,-50%)`,
  11470. background: pivotColor || background.value
  11471. };
  11472. return createVNode("span", {
  11473. "style": style,
  11474. "class": bem$m("pivot", {
  11475. inactive: props.inactive
  11476. })
  11477. }, [text]);
  11478. }
  11479. };
  11480. return () => {
  11481. const {
  11482. trackColor,
  11483. percentage,
  11484. strokeWidth
  11485. } = props;
  11486. const rootStyle = {
  11487. background: trackColor,
  11488. height: addUnit(strokeWidth)
  11489. };
  11490. const portionStyle = {
  11491. width: `${percentage}%`,
  11492. background: background.value
  11493. };
  11494. return createVNode("div", {
  11495. "class": bem$m(),
  11496. "style": rootStyle
  11497. }, [createVNode("span", {
  11498. "class": bem$m("portion", {
  11499. inactive: props.inactive
  11500. }),
  11501. "style": portionStyle
  11502. }, null), renderPivot()]);
  11503. };
  11504. }
  11505. });
  11506. const Progress = withInstall(stdin_default$s);
  11507. const [name$m, bem$l, t$4] = createNamespace("pull-refresh");
  11508. const DEFAULT_HEAD_HEIGHT = 50;
  11509. const TEXT_STATUS = ["pulling", "loosing", "success"];
  11510. const pullRefreshProps = {
  11511. disabled: Boolean,
  11512. modelValue: Boolean,
  11513. headHeight: makeNumericProp(DEFAULT_HEAD_HEIGHT),
  11514. successText: String,
  11515. pullingText: String,
  11516. loosingText: String,
  11517. loadingText: String,
  11518. pullDistance: numericProp,
  11519. successDuration: makeNumericProp(500),
  11520. animationDuration: makeNumericProp(300)
  11521. };
  11522. var stdin_default$r = defineComponent({
  11523. name: name$m,
  11524. props: pullRefreshProps,
  11525. emits: ["change", "refresh", "update:modelValue"],
  11526. setup(props, {
  11527. emit,
  11528. slots
  11529. }) {
  11530. let reachTop;
  11531. const root = ref();
  11532. const track = ref();
  11533. const scrollParent = useScrollParent(root);
  11534. const state = reactive({
  11535. status: "normal",
  11536. distance: 0,
  11537. duration: 0
  11538. });
  11539. const touch = useTouch();
  11540. const getHeadStyle = () => {
  11541. if (props.headHeight !== DEFAULT_HEAD_HEIGHT) {
  11542. return {
  11543. height: `${props.headHeight}px`
  11544. };
  11545. }
  11546. };
  11547. const isTouchable = () => state.status !== "loading" && state.status !== "success" && !props.disabled;
  11548. const ease = (distance) => {
  11549. const pullDistance = +(props.pullDistance || props.headHeight);
  11550. if (distance > pullDistance) {
  11551. if (distance < pullDistance * 2) {
  11552. distance = pullDistance + (distance - pullDistance) / 2;
  11553. } else {
  11554. distance = pullDistance * 1.5 + (distance - pullDistance * 2) / 4;
  11555. }
  11556. }
  11557. return Math.round(distance);
  11558. };
  11559. const setStatus = (distance, isLoading) => {
  11560. const pullDistance = +(props.pullDistance || props.headHeight);
  11561. state.distance = distance;
  11562. if (isLoading) {
  11563. state.status = "loading";
  11564. } else if (distance === 0) {
  11565. state.status = "normal";
  11566. } else if (distance < pullDistance) {
  11567. state.status = "pulling";
  11568. } else {
  11569. state.status = "loosing";
  11570. }
  11571. emit("change", {
  11572. status: state.status,
  11573. distance
  11574. });
  11575. };
  11576. const getStatusText = () => {
  11577. const {
  11578. status
  11579. } = state;
  11580. if (status === "normal") {
  11581. return "";
  11582. }
  11583. return props[`${status}Text`] || t$4(status);
  11584. };
  11585. const renderStatus = () => {
  11586. const {
  11587. status,
  11588. distance
  11589. } = state;
  11590. if (slots[status]) {
  11591. return slots[status]({
  11592. distance
  11593. });
  11594. }
  11595. const nodes = [];
  11596. if (TEXT_STATUS.includes(status)) {
  11597. nodes.push(createVNode("div", {
  11598. "class": bem$l("text")
  11599. }, [getStatusText()]));
  11600. }
  11601. if (status === "loading") {
  11602. nodes.push(createVNode(Loading, {
  11603. "class": bem$l("loading")
  11604. }, {
  11605. default: getStatusText
  11606. }));
  11607. }
  11608. return nodes;
  11609. };
  11610. const showSuccessTip = () => {
  11611. state.status = "success";
  11612. setTimeout(() => {
  11613. setStatus(0);
  11614. }, +props.successDuration);
  11615. };
  11616. const checkPosition = (event) => {
  11617. reachTop = getScrollTop(scrollParent.value) === 0;
  11618. if (reachTop) {
  11619. state.duration = 0;
  11620. touch.start(event);
  11621. }
  11622. };
  11623. const onTouchStart = (event) => {
  11624. if (isTouchable()) {
  11625. checkPosition(event);
  11626. }
  11627. };
  11628. const onTouchMove = (event) => {
  11629. if (isTouchable()) {
  11630. if (!reachTop) {
  11631. checkPosition(event);
  11632. }
  11633. const {
  11634. deltaY
  11635. } = touch;
  11636. touch.move(event);
  11637. if (reachTop && deltaY.value >= 0 && touch.isVertical()) {
  11638. preventDefault(event);
  11639. setStatus(ease(deltaY.value));
  11640. }
  11641. }
  11642. };
  11643. const onTouchEnd = () => {
  11644. if (reachTop && touch.deltaY.value && isTouchable()) {
  11645. state.duration = +props.animationDuration;
  11646. if (state.status === "loosing") {
  11647. setStatus(+props.headHeight, true);
  11648. emit("update:modelValue", true);
  11649. nextTick(() => emit("refresh"));
  11650. } else {
  11651. setStatus(0);
  11652. }
  11653. }
  11654. };
  11655. watch(() => props.modelValue, (value) => {
  11656. state.duration = +props.animationDuration;
  11657. if (value) {
  11658. setStatus(+props.headHeight, true);
  11659. } else if (slots.success || props.successText) {
  11660. showSuccessTip();
  11661. } else {
  11662. setStatus(0, false);
  11663. }
  11664. });
  11665. useEventListener("touchmove", onTouchMove, {
  11666. target: track
  11667. });
  11668. return () => {
  11669. var _a;
  11670. const trackStyle = {
  11671. transitionDuration: `${state.duration}ms`,
  11672. transform: state.distance ? `translate3d(0,${state.distance}px, 0)` : ""
  11673. };
  11674. return createVNode("div", {
  11675. "ref": root,
  11676. "class": bem$l()
  11677. }, [createVNode("div", {
  11678. "ref": track,
  11679. "class": bem$l("track"),
  11680. "style": trackStyle,
  11681. "onTouchstartPassive": onTouchStart,
  11682. "onTouchend": onTouchEnd,
  11683. "onTouchcancel": onTouchEnd
  11684. }, [createVNode("div", {
  11685. "class": bem$l("head"),
  11686. "style": getHeadStyle()
  11687. }, [renderStatus()]), (_a = slots.default) == null ? void 0 : _a.call(slots)])]);
  11688. };
  11689. }
  11690. });
  11691. const PullRefresh = withInstall(stdin_default$r);
  11692. const [name$l, bem$k] = createNamespace("rate");
  11693. function getRateStatus(value, index, allowHalf, readonly) {
  11694. if (value >= index) {
  11695. return {
  11696. status: "full",
  11697. value: 1
  11698. };
  11699. }
  11700. if (value + 0.5 >= index && allowHalf && !readonly) {
  11701. return {
  11702. status: "half",
  11703. value: 0.5
  11704. };
  11705. }
  11706. if (value + 1 >= index && allowHalf && readonly) {
  11707. const cardinal = 10 ** 10;
  11708. return {
  11709. status: "half",
  11710. value: Math.round((value - index + 1) * cardinal) / cardinal
  11711. };
  11712. }
  11713. return {
  11714. status: "void",
  11715. value: 0
  11716. };
  11717. }
  11718. const rateProps = {
  11719. size: numericProp,
  11720. icon: makeStringProp("star"),
  11721. color: String,
  11722. count: makeNumericProp(5),
  11723. gutter: numericProp,
  11724. readonly: Boolean,
  11725. disabled: Boolean,
  11726. voidIcon: makeStringProp("star-o"),
  11727. allowHalf: Boolean,
  11728. voidColor: String,
  11729. touchable: truthProp,
  11730. iconPrefix: String,
  11731. modelValue: makeNumberProp(0),
  11732. disabledColor: String
  11733. };
  11734. var stdin_default$q = defineComponent({
  11735. name: name$l,
  11736. props: rateProps,
  11737. emits: ["change", "update:modelValue"],
  11738. setup(props, {
  11739. emit
  11740. }) {
  11741. const touch = useTouch();
  11742. const [itemRefs, setItemRefs] = useRefs();
  11743. const groupRef = ref();
  11744. const untouchable = () => props.readonly || props.disabled || !props.touchable;
  11745. const list = computed(() => Array(+props.count).fill("").map((_, i) => getRateStatus(props.modelValue, i + 1, props.allowHalf, props.readonly)));
  11746. let ranges;
  11747. let groupRefRect;
  11748. let minRectTop = Number.MAX_SAFE_INTEGER;
  11749. let maxRectTop = Number.MIN_SAFE_INTEGER;
  11750. const updateRanges = () => {
  11751. groupRefRect = useRect(groupRef);
  11752. const rects = itemRefs.value.map(useRect);
  11753. ranges = [];
  11754. rects.forEach((rect, index) => {
  11755. minRectTop = Math.min(rect.top, minRectTop);
  11756. maxRectTop = Math.max(rect.top, maxRectTop);
  11757. if (props.allowHalf) {
  11758. ranges.push({
  11759. score: index + 0.5,
  11760. left: rect.left,
  11761. top: rect.top,
  11762. height: rect.height
  11763. }, {
  11764. score: index + 1,
  11765. left: rect.left + rect.width / 2,
  11766. top: rect.top,
  11767. height: rect.height
  11768. });
  11769. } else {
  11770. ranges.push({
  11771. score: index + 1,
  11772. left: rect.left,
  11773. top: rect.top,
  11774. height: rect.height
  11775. });
  11776. }
  11777. });
  11778. };
  11779. const getScoreByPosition = (x, y) => {
  11780. for (let i = ranges.length - 1; i > 0; i--) {
  11781. if (y >= groupRefRect.top && y <= groupRefRect.bottom) {
  11782. if (x > ranges[i].left && y >= ranges[i].top && y <= ranges[i].top + ranges[i].height) {
  11783. return ranges[i].score;
  11784. }
  11785. } else {
  11786. const curTop = y < groupRefRect.top ? minRectTop : maxRectTop;
  11787. if (x > ranges[i].left && ranges[i].top === curTop) {
  11788. return ranges[i].score;
  11789. }
  11790. }
  11791. }
  11792. return props.allowHalf ? 0.5 : 1;
  11793. };
  11794. const select = (index) => {
  11795. if (!props.disabled && !props.readonly && index !== props.modelValue) {
  11796. emit("update:modelValue", index);
  11797. emit("change", index);
  11798. }
  11799. };
  11800. const onTouchStart = (event) => {
  11801. if (untouchable()) {
  11802. return;
  11803. }
  11804. touch.start(event);
  11805. updateRanges();
  11806. };
  11807. const onTouchMove = (event) => {
  11808. if (untouchable()) {
  11809. return;
  11810. }
  11811. touch.move(event);
  11812. if (touch.isHorizontal()) {
  11813. const {
  11814. clientX,
  11815. clientY
  11816. } = event.touches[0];
  11817. preventDefault(event);
  11818. select(getScoreByPosition(clientX, clientY));
  11819. }
  11820. };
  11821. const renderStar = (item, index) => {
  11822. const {
  11823. icon,
  11824. size,
  11825. color,
  11826. count,
  11827. gutter,
  11828. voidIcon,
  11829. disabled,
  11830. voidColor,
  11831. allowHalf,
  11832. iconPrefix,
  11833. disabledColor
  11834. } = props;
  11835. const score = index + 1;
  11836. const isFull = item.status === "full";
  11837. const isVoid = item.status === "void";
  11838. const renderHalf = allowHalf && item.value > 0 && item.value < 1;
  11839. let style;
  11840. if (gutter && score !== +count) {
  11841. style = {
  11842. paddingRight: addUnit(gutter)
  11843. };
  11844. }
  11845. const onClickItem = (event) => {
  11846. updateRanges();
  11847. select(allowHalf ? getScoreByPosition(event.clientX, event.clientY) : score);
  11848. };
  11849. return createVNode("div", {
  11850. "key": index,
  11851. "ref": setItemRefs(index),
  11852. "role": "radio",
  11853. "style": style,
  11854. "class": bem$k("item"),
  11855. "tabindex": disabled ? void 0 : 0,
  11856. "aria-setsize": count,
  11857. "aria-posinset": score,
  11858. "aria-checked": !isVoid,
  11859. "onClick": onClickItem
  11860. }, [createVNode(Icon, {
  11861. "size": size,
  11862. "name": isFull ? icon : voidIcon,
  11863. "class": bem$k("icon", {
  11864. disabled,
  11865. full: isFull
  11866. }),
  11867. "color": disabled ? disabledColor : isFull ? color : voidColor,
  11868. "classPrefix": iconPrefix
  11869. }, null), renderHalf && createVNode(Icon, {
  11870. "size": size,
  11871. "style": {
  11872. width: item.value + "em"
  11873. },
  11874. "name": isVoid ? voidIcon : icon,
  11875. "class": bem$k("icon", ["half", {
  11876. disabled,
  11877. full: !isVoid
  11878. }]),
  11879. "color": disabled ? disabledColor : isVoid ? voidColor : color,
  11880. "classPrefix": iconPrefix
  11881. }, null)]);
  11882. };
  11883. useCustomFieldValue(() => props.modelValue);
  11884. useEventListener("touchmove", onTouchMove, {
  11885. target: groupRef
  11886. });
  11887. return () => createVNode("div", {
  11888. "ref": groupRef,
  11889. "role": "radiogroup",
  11890. "class": bem$k({
  11891. readonly: props.readonly,
  11892. disabled: props.disabled
  11893. }),
  11894. "tabindex": props.disabled ? void 0 : 0,
  11895. "aria-disabled": props.disabled,
  11896. "aria-readonly": props.readonly,
  11897. "onTouchstartPassive": onTouchStart
  11898. }, [list.value.map(renderStar)]);
  11899. }
  11900. });
  11901. const Rate = withInstall(stdin_default$q);
  11902. const Row = withInstall(stdin_default$Y);
  11903. const [name$k, bem$j, t$3] = createNamespace("search");
  11904. const searchProps = extend({}, fieldSharedProps, {
  11905. label: String,
  11906. shape: makeStringProp("square"),
  11907. leftIcon: makeStringProp("search"),
  11908. clearable: truthProp,
  11909. actionText: String,
  11910. background: String,
  11911. showAction: Boolean
  11912. });
  11913. var stdin_default$p = defineComponent({
  11914. name: name$k,
  11915. props: searchProps,
  11916. emits: ["blur", "focus", "clear", "search", "cancel", "clickInput", "clickLeftIcon", "clickRightIcon", "update:modelValue"],
  11917. setup(props, {
  11918. emit,
  11919. slots,
  11920. attrs
  11921. }) {
  11922. const id = useId();
  11923. const filedRef = ref();
  11924. const onCancel = () => {
  11925. if (!slots.action) {
  11926. emit("update:modelValue", "");
  11927. emit("cancel");
  11928. }
  11929. };
  11930. const onKeypress = (event) => {
  11931. const ENTER_CODE = 13;
  11932. if (event.keyCode === ENTER_CODE) {
  11933. preventDefault(event);
  11934. emit("search", props.modelValue);
  11935. }
  11936. };
  11937. const getInputId = () => props.id || `${id}-input`;
  11938. const renderLabel = () => {
  11939. if (slots.label || props.label) {
  11940. return createVNode("label", {
  11941. "class": bem$j("label"),
  11942. "for": getInputId()
  11943. }, [slots.label ? slots.label() : props.label]);
  11944. }
  11945. };
  11946. const renderAction = () => {
  11947. if (props.showAction) {
  11948. const text = props.actionText || t$3("cancel");
  11949. return createVNode("div", {
  11950. "class": bem$j("action"),
  11951. "role": "button",
  11952. "tabindex": 0,
  11953. "onClick": onCancel
  11954. }, [slots.action ? slots.action() : text]);
  11955. }
  11956. };
  11957. const blur = () => {
  11958. var _a;
  11959. return (_a = filedRef.value) == null ? void 0 : _a.blur();
  11960. };
  11961. const focus = () => {
  11962. var _a;
  11963. return (_a = filedRef.value) == null ? void 0 : _a.focus();
  11964. };
  11965. const onBlur = (event) => emit("blur", event);
  11966. const onFocus = (event) => emit("focus", event);
  11967. const onClear = (event) => emit("clear", event);
  11968. const onClickInput = (event) => emit("clickInput", event);
  11969. const onClickLeftIcon = (event) => emit("clickLeftIcon", event);
  11970. const onClickRightIcon = (event) => emit("clickRightIcon", event);
  11971. const fieldPropNames = Object.keys(fieldSharedProps);
  11972. const renderField = () => {
  11973. const fieldAttrs = extend({}, attrs, pick(props, fieldPropNames), {
  11974. id: getInputId()
  11975. });
  11976. const onInput = (value) => emit("update:modelValue", value);
  11977. return createVNode(Field, mergeProps({
  11978. "ref": filedRef,
  11979. "type": "search",
  11980. "class": bem$j("field"),
  11981. "border": false,
  11982. "onBlur": onBlur,
  11983. "onFocus": onFocus,
  11984. "onClear": onClear,
  11985. "onKeypress": onKeypress,
  11986. "onClickInput": onClickInput,
  11987. "onClickLeftIcon": onClickLeftIcon,
  11988. "onClickRightIcon": onClickRightIcon,
  11989. "onUpdate:modelValue": onInput
  11990. }, fieldAttrs), pick(slots, ["left-icon", "right-icon"]));
  11991. };
  11992. useExpose({
  11993. focus,
  11994. blur
  11995. });
  11996. return () => {
  11997. var _a;
  11998. return createVNode("div", {
  11999. "class": bem$j({
  12000. "show-action": props.showAction
  12001. }),
  12002. "style": {
  12003. background: props.background
  12004. }
  12005. }, [(_a = slots.left) == null ? void 0 : _a.call(slots), createVNode("div", {
  12006. "class": bem$j("content", props.shape)
  12007. }, [renderLabel(), renderField()]), renderAction()]);
  12008. };
  12009. }
  12010. });
  12011. const Search = withInstall(stdin_default$p);
  12012. const popupInheritKeys = [...popupSharedPropKeys, "round", "closeOnPopstate", "safeAreaInsetBottom"];
  12013. const iconMap = {
  12014. qq: "qq",
  12015. link: "link-o",
  12016. weibo: "weibo",
  12017. qrcode: "qr",
  12018. poster: "photo-o",
  12019. wechat: "wechat",
  12020. "weapp-qrcode": "miniprogram-o",
  12021. "wechat-moments": "wechat-moments"
  12022. };
  12023. const [name$j, bem$i, t$2] = createNamespace("share-sheet");
  12024. const shareSheetProps = extend({}, popupSharedProps, {
  12025. title: String,
  12026. round: truthProp,
  12027. options: makeArrayProp(),
  12028. cancelText: String,
  12029. description: String,
  12030. closeOnPopstate: truthProp,
  12031. safeAreaInsetBottom: truthProp
  12032. });
  12033. var stdin_default$o = defineComponent({
  12034. name: name$j,
  12035. props: shareSheetProps,
  12036. emits: ["cancel", "select", "update:show"],
  12037. setup(props, {
  12038. emit,
  12039. slots
  12040. }) {
  12041. const updateShow = (value) => emit("update:show", value);
  12042. const onCancel = () => {
  12043. updateShow(false);
  12044. emit("cancel");
  12045. };
  12046. const onSelect = (option, index) => emit("select", option, index);
  12047. const renderHeader = () => {
  12048. const title = slots.title ? slots.title() : props.title;
  12049. const description = slots.description ? slots.description() : props.description;
  12050. if (title || description) {
  12051. return createVNode("div", {
  12052. "class": bem$i("header")
  12053. }, [title && createVNode("h2", {
  12054. "class": bem$i("title")
  12055. }, [title]), description && createVNode("span", {
  12056. "class": bem$i("description")
  12057. }, [description])]);
  12058. }
  12059. };
  12060. const renderIcon = (icon) => {
  12061. if (iconMap[icon]) {
  12062. return createVNode("div", {
  12063. "class": bem$i("icon", [icon])
  12064. }, [createVNode(Icon, {
  12065. "name": iconMap[icon] || icon
  12066. }, null)]);
  12067. }
  12068. return createVNode("img", {
  12069. "src": icon,
  12070. "class": bem$i("image-icon")
  12071. }, null);
  12072. };
  12073. const renderOption = (option, index) => {
  12074. const {
  12075. name: name2,
  12076. icon,
  12077. className,
  12078. description
  12079. } = option;
  12080. return createVNode("div", {
  12081. "role": "button",
  12082. "tabindex": 0,
  12083. "class": [bem$i("option"), className, HAPTICS_FEEDBACK],
  12084. "onClick": () => onSelect(option, index)
  12085. }, [renderIcon(icon), name2 && createVNode("span", {
  12086. "class": bem$i("name")
  12087. }, [name2]), description && createVNode("span", {
  12088. "class": bem$i("option-description")
  12089. }, [description])]);
  12090. };
  12091. const renderOptions = (options, border) => createVNode("div", {
  12092. "class": bem$i("options", {
  12093. border
  12094. })
  12095. }, [options.map(renderOption)]);
  12096. const renderRows = () => {
  12097. const {
  12098. options
  12099. } = props;
  12100. if (Array.isArray(options[0])) {
  12101. return options.map((item, index) => renderOptions(item, index !== 0));
  12102. }
  12103. return renderOptions(options);
  12104. };
  12105. const renderCancelButton = () => {
  12106. var _a;
  12107. const cancelText = (_a = props.cancelText) != null ? _a : t$2("cancel");
  12108. if (slots.cancel || cancelText) {
  12109. return createVNode("button", {
  12110. "type": "button",
  12111. "class": bem$i("cancel"),
  12112. "onClick": onCancel
  12113. }, [slots.cancel ? slots.cancel() : cancelText]);
  12114. }
  12115. };
  12116. return () => createVNode(Popup, mergeProps({
  12117. "class": bem$i(),
  12118. "position": "bottom",
  12119. "onUpdate:show": updateShow
  12120. }, pick(props, popupInheritKeys)), {
  12121. default: () => [renderHeader(), renderRows(), renderCancelButton()]
  12122. });
  12123. }
  12124. });
  12125. const ShareSheet = withInstall(stdin_default$o);
  12126. const [name$i, bem$h] = createNamespace("sidebar");
  12127. const SIDEBAR_KEY = Symbol(name$i);
  12128. const sidebarProps = {
  12129. modelValue: makeNumericProp(0)
  12130. };
  12131. var stdin_default$n = defineComponent({
  12132. name: name$i,
  12133. props: sidebarProps,
  12134. emits: ["change", "update:modelValue"],
  12135. setup(props, {
  12136. emit,
  12137. slots
  12138. }) {
  12139. const {
  12140. linkChildren
  12141. } = useChildren(SIDEBAR_KEY);
  12142. const getActive = () => +props.modelValue;
  12143. const setActive = (value) => {
  12144. if (value !== getActive()) {
  12145. emit("update:modelValue", value);
  12146. emit("change", value);
  12147. }
  12148. };
  12149. linkChildren({
  12150. getActive,
  12151. setActive
  12152. });
  12153. return () => {
  12154. var _a;
  12155. return createVNode("div", {
  12156. "role": "tablist",
  12157. "class": bem$h()
  12158. }, [(_a = slots.default) == null ? void 0 : _a.call(slots)]);
  12159. };
  12160. }
  12161. });
  12162. const Sidebar = withInstall(stdin_default$n);
  12163. const [name$h, bem$g] = createNamespace("sidebar-item");
  12164. const sidebarItemProps = extend({}, routeProps, {
  12165. dot: Boolean,
  12166. title: String,
  12167. badge: numericProp,
  12168. disabled: Boolean,
  12169. badgeProps: Object
  12170. });
  12171. var stdin_default$m = defineComponent({
  12172. name: name$h,
  12173. props: sidebarItemProps,
  12174. emits: ["click"],
  12175. setup(props, {
  12176. emit,
  12177. slots
  12178. }) {
  12179. const route2 = useRoute();
  12180. const {
  12181. parent,
  12182. index
  12183. } = useParent(SIDEBAR_KEY);
  12184. if (!parent) {
  12185. if (process.env.NODE_ENV !== "production") {
  12186. console.error("[Vant] <SidebarItem> must be a child component of <Sidebar>.");
  12187. }
  12188. return;
  12189. }
  12190. const onClick = () => {
  12191. if (props.disabled) {
  12192. return;
  12193. }
  12194. emit("click", index.value);
  12195. parent.setActive(index.value);
  12196. route2();
  12197. };
  12198. return () => {
  12199. const {
  12200. dot,
  12201. badge,
  12202. title,
  12203. disabled
  12204. } = props;
  12205. const selected = index.value === parent.getActive();
  12206. return createVNode("div", {
  12207. "role": "tab",
  12208. "class": bem$g({
  12209. select: selected,
  12210. disabled
  12211. }),
  12212. "tabindex": disabled ? void 0 : 0,
  12213. "aria-selected": selected,
  12214. "onClick": onClick
  12215. }, [createVNode(Badge, mergeProps({
  12216. "dot": dot,
  12217. "class": bem$g("text"),
  12218. "content": badge
  12219. }, props.badgeProps), {
  12220. default: () => [slots.title ? slots.title() : title]
  12221. })]);
  12222. };
  12223. }
  12224. });
  12225. const SidebarItem = withInstall(stdin_default$m);
  12226. const [name$g, bem$f] = createNamespace("skeleton-title");
  12227. const skeletonTitleProps = {
  12228. round: Boolean,
  12229. titleWidth: numericProp
  12230. };
  12231. var stdin_default$l = defineComponent({
  12232. name: name$g,
  12233. props: skeletonTitleProps,
  12234. setup(props) {
  12235. return () => createVNode("h3", {
  12236. "class": bem$f([{
  12237. round: props.round
  12238. }]),
  12239. "style": {
  12240. width: addUnit(props.titleWidth)
  12241. }
  12242. }, null);
  12243. }
  12244. });
  12245. const [name$f, bem$e] = createNamespace("skeleton-avatar");
  12246. const skeletonAvatarProps = {
  12247. avatarSize: numericProp,
  12248. avatarShape: makeStringProp("round")
  12249. };
  12250. var stdin_default$k = defineComponent({
  12251. name: name$f,
  12252. props: skeletonAvatarProps,
  12253. setup(props) {
  12254. return () => createVNode("div", {
  12255. "class": bem$e([props.avatarShape]),
  12256. "style": getSizeStyle(props.avatarSize)
  12257. }, null);
  12258. }
  12259. });
  12260. const DEFAULT_ROW_WIDTH = "100%";
  12261. const skeletonParagraphProps = {
  12262. round: Boolean,
  12263. rowWidth: {
  12264. type: numericProp,
  12265. default: DEFAULT_ROW_WIDTH
  12266. }
  12267. };
  12268. const [name$e, bem$d] = createNamespace("skeleton-paragraph");
  12269. var stdin_default$j = defineComponent({
  12270. name: name$e,
  12271. props: skeletonParagraphProps,
  12272. setup(props) {
  12273. return () => createVNode("div", {
  12274. "class": bem$d([{
  12275. round: props.round
  12276. }]),
  12277. "style": {
  12278. width: props.rowWidth
  12279. }
  12280. }, null);
  12281. }
  12282. });
  12283. const [name$d, bem$c] = createNamespace("skeleton");
  12284. const DEFAULT_LAST_ROW_WIDTH = "60%";
  12285. const skeletonProps = {
  12286. row: makeNumericProp(0),
  12287. round: Boolean,
  12288. title: Boolean,
  12289. titleWidth: numericProp,
  12290. avatar: Boolean,
  12291. avatarSize: numericProp,
  12292. avatarShape: makeStringProp("round"),
  12293. loading: truthProp,
  12294. animate: truthProp,
  12295. rowWidth: {
  12296. type: [Number, String, Array],
  12297. default: DEFAULT_ROW_WIDTH
  12298. }
  12299. };
  12300. var stdin_default$i = defineComponent({
  12301. name: name$d,
  12302. inheritAttrs: false,
  12303. props: skeletonProps,
  12304. setup(props, {
  12305. slots,
  12306. attrs
  12307. }) {
  12308. const renderAvatar = () => {
  12309. if (props.avatar) {
  12310. return createVNode(stdin_default$k, {
  12311. "avatarShape": props.avatarShape,
  12312. "avatarSize": props.avatarSize
  12313. }, null);
  12314. }
  12315. };
  12316. const renderTitle = () => {
  12317. if (props.title) {
  12318. return createVNode(stdin_default$l, {
  12319. "round": props.round,
  12320. "titleWidth": props.titleWidth
  12321. }, null);
  12322. }
  12323. };
  12324. const getRowWidth = (index) => {
  12325. const {
  12326. rowWidth
  12327. } = props;
  12328. if (rowWidth === DEFAULT_ROW_WIDTH && index === +props.row - 1) {
  12329. return DEFAULT_LAST_ROW_WIDTH;
  12330. }
  12331. if (Array.isArray(rowWidth)) {
  12332. return rowWidth[index];
  12333. }
  12334. return rowWidth;
  12335. };
  12336. const renderRows = () => Array(+props.row).fill("").map((_, i) => createVNode(stdin_default$j, {
  12337. "key": i,
  12338. "round": props.round,
  12339. "rowWidth": addUnit(getRowWidth(i))
  12340. }, null));
  12341. const renderContents = () => {
  12342. if (slots.template) {
  12343. return slots.template();
  12344. }
  12345. return createVNode(Fragment, null, [renderAvatar(), createVNode("div", {
  12346. "class": bem$c("content")
  12347. }, [renderTitle(), renderRows()])]);
  12348. };
  12349. return () => {
  12350. var _a;
  12351. if (!props.loading) {
  12352. return (_a = slots.default) == null ? void 0 : _a.call(slots);
  12353. }
  12354. return createVNode("div", mergeProps({
  12355. "class": bem$c({
  12356. animate: props.animate,
  12357. round: props.round
  12358. })
  12359. }, attrs), [renderContents()]);
  12360. };
  12361. }
  12362. });
  12363. const [name$c, bem$b] = createNamespace("skeleton-image");
  12364. const skeletonImageProps = {
  12365. imageSize: numericProp,
  12366. imageShape: makeStringProp("square")
  12367. };
  12368. var stdin_default$h = defineComponent({
  12369. name: name$c,
  12370. props: skeletonImageProps,
  12371. setup(props) {
  12372. return () => createVNode("div", {
  12373. "class": bem$b([props.imageShape]),
  12374. "style": getSizeStyle(props.imageSize)
  12375. }, [createVNode(Icon, {
  12376. "name": "photo",
  12377. "class": bem$b("icon")
  12378. }, null)]);
  12379. }
  12380. });
  12381. const SkeletonImage = withInstall(stdin_default$h);
  12382. const SkeletonTitle = withInstall(stdin_default$l);
  12383. const SkeletonAvatar = withInstall(stdin_default$k);
  12384. const SkeletonParagraph = withInstall(stdin_default$j);
  12385. const Skeleton = withInstall(stdin_default$i);
  12386. const [name$b, bem$a] = createNamespace("slider");
  12387. const sliderProps = {
  12388. min: makeNumericProp(0),
  12389. max: makeNumericProp(100),
  12390. step: makeNumericProp(1),
  12391. range: Boolean,
  12392. reverse: Boolean,
  12393. disabled: Boolean,
  12394. readonly: Boolean,
  12395. vertical: Boolean,
  12396. barHeight: numericProp,
  12397. buttonSize: numericProp,
  12398. activeColor: String,
  12399. inactiveColor: String,
  12400. modelValue: {
  12401. type: [Number, Array],
  12402. default: 0
  12403. }
  12404. };
  12405. var stdin_default$g = defineComponent({
  12406. name: name$b,
  12407. props: sliderProps,
  12408. emits: ["change", "dragEnd", "dragStart", "update:modelValue"],
  12409. setup(props, {
  12410. emit,
  12411. slots
  12412. }) {
  12413. let buttonIndex;
  12414. let current2;
  12415. let startValue;
  12416. const root = ref();
  12417. const slider = ref();
  12418. const dragStatus = ref();
  12419. const touch = useTouch();
  12420. const scope = computed(() => Number(props.max) - Number(props.min));
  12421. const wrapperStyle = computed(() => {
  12422. const crossAxis = props.vertical ? "width" : "height";
  12423. return {
  12424. background: props.inactiveColor,
  12425. [crossAxis]: addUnit(props.barHeight)
  12426. };
  12427. });
  12428. const isRange = (val) => props.range && Array.isArray(val);
  12429. const calcMainAxis = () => {
  12430. const {
  12431. modelValue,
  12432. min
  12433. } = props;
  12434. if (isRange(modelValue)) {
  12435. return `${(modelValue[1] - modelValue[0]) * 100 / scope.value}%`;
  12436. }
  12437. return `${(modelValue - Number(min)) * 100 / scope.value}%`;
  12438. };
  12439. const calcOffset = () => {
  12440. const {
  12441. modelValue,
  12442. min
  12443. } = props;
  12444. if (isRange(modelValue)) {
  12445. return `${(modelValue[0] - Number(min)) * 100 / scope.value}%`;
  12446. }
  12447. return "0%";
  12448. };
  12449. const barStyle = computed(() => {
  12450. const mainAxis = props.vertical ? "height" : "width";
  12451. const style = {
  12452. [mainAxis]: calcMainAxis(),
  12453. background: props.activeColor
  12454. };
  12455. if (dragStatus.value) {
  12456. style.transition = "none";
  12457. }
  12458. const getPositionKey = () => {
  12459. if (props.vertical) {
  12460. return props.reverse ? "bottom" : "top";
  12461. }
  12462. return props.reverse ? "right" : "left";
  12463. };
  12464. style[getPositionKey()] = calcOffset();
  12465. return style;
  12466. });
  12467. const format2 = (value) => {
  12468. const min = +props.min;
  12469. const max = +props.max;
  12470. const step = +props.step;
  12471. value = clamp(value, min, max);
  12472. const diff = Math.round((value - min) / step) * step;
  12473. return addNumber(min, diff);
  12474. };
  12475. const handleRangeValue = (value) => {
  12476. var _a, _b;
  12477. const left = (_a = value[0]) != null ? _a : Number(props.min);
  12478. const right = (_b = value[1]) != null ? _b : Number(props.max);
  12479. return left > right ? [right, left] : [left, right];
  12480. };
  12481. const updateValue = (value, end) => {
  12482. if (isRange(value)) {
  12483. value = handleRangeValue(value).map(format2);
  12484. } else {
  12485. value = format2(value);
  12486. }
  12487. if (!isSameValue(value, props.modelValue)) {
  12488. emit("update:modelValue", value);
  12489. }
  12490. if (end && !isSameValue(value, startValue)) {
  12491. emit("change", value);
  12492. }
  12493. };
  12494. const onClick = (event) => {
  12495. event.stopPropagation();
  12496. if (props.disabled || props.readonly) {
  12497. return;
  12498. }
  12499. const {
  12500. min,
  12501. reverse,
  12502. vertical,
  12503. modelValue
  12504. } = props;
  12505. const rect = useRect(root);
  12506. const getDelta = () => {
  12507. if (vertical) {
  12508. if (reverse) {
  12509. return rect.bottom - event.clientY;
  12510. }
  12511. return event.clientY - rect.top;
  12512. }
  12513. if (reverse) {
  12514. return rect.right - event.clientX;
  12515. }
  12516. return event.clientX - rect.left;
  12517. };
  12518. const total = vertical ? rect.height : rect.width;
  12519. const value = Number(min) + getDelta() / total * scope.value;
  12520. if (isRange(modelValue)) {
  12521. const [left, right] = modelValue;
  12522. const middle = (left + right) / 2;
  12523. if (value <= middle) {
  12524. updateValue([value, right], true);
  12525. } else {
  12526. updateValue([left, value], true);
  12527. }
  12528. } else {
  12529. updateValue(value, true);
  12530. }
  12531. };
  12532. const onTouchStart = (event) => {
  12533. if (props.disabled || props.readonly) {
  12534. return;
  12535. }
  12536. touch.start(event);
  12537. current2 = props.modelValue;
  12538. if (isRange(current2)) {
  12539. startValue = current2.map(format2);
  12540. } else {
  12541. startValue = format2(current2);
  12542. }
  12543. dragStatus.value = "start";
  12544. };
  12545. const onTouchMove = (event) => {
  12546. if (props.disabled || props.readonly) {
  12547. return;
  12548. }
  12549. if (dragStatus.value === "start") {
  12550. emit("dragStart", event);
  12551. }
  12552. preventDefault(event, true);
  12553. touch.move(event);
  12554. dragStatus.value = "dragging";
  12555. const rect = useRect(root);
  12556. const delta = props.vertical ? touch.deltaY.value : touch.deltaX.value;
  12557. const total = props.vertical ? rect.height : rect.width;
  12558. let diff = delta / total * scope.value;
  12559. if (props.reverse) {
  12560. diff = -diff;
  12561. }
  12562. if (isRange(startValue)) {
  12563. const index = props.reverse ? 1 - buttonIndex : buttonIndex;
  12564. current2[index] = startValue[index] + diff;
  12565. } else {
  12566. current2 = startValue + diff;
  12567. }
  12568. updateValue(current2);
  12569. };
  12570. const onTouchEnd = (event) => {
  12571. if (props.disabled || props.readonly) {
  12572. return;
  12573. }
  12574. if (dragStatus.value === "dragging") {
  12575. updateValue(current2, true);
  12576. emit("dragEnd", event);
  12577. }
  12578. dragStatus.value = "";
  12579. };
  12580. const getButtonClassName = (index) => {
  12581. if (typeof index === "number") {
  12582. const position = ["left", "right"];
  12583. return bem$a(`button-wrapper`, position[index]);
  12584. }
  12585. return bem$a("button-wrapper", props.reverse ? "left" : "right");
  12586. };
  12587. const renderButtonContent = (value, index) => {
  12588. if (typeof index === "number") {
  12589. const slot = slots[index === 0 ? "left-button" : "right-button"];
  12590. if (slot) {
  12591. return slot({
  12592. value
  12593. });
  12594. }
  12595. }
  12596. if (slots.button) {
  12597. return slots.button({
  12598. value
  12599. });
  12600. }
  12601. return createVNode("div", {
  12602. "class": bem$a("button"),
  12603. "style": getSizeStyle(props.buttonSize)
  12604. }, null);
  12605. };
  12606. const renderButton = (index) => {
  12607. const current22 = typeof index === "number" ? props.modelValue[index] : props.modelValue;
  12608. return createVNode("div", {
  12609. "ref": slider,
  12610. "role": "slider",
  12611. "class": getButtonClassName(index),
  12612. "tabindex": props.disabled ? void 0 : 0,
  12613. "aria-valuemin": props.min,
  12614. "aria-valuenow": current22,
  12615. "aria-valuemax": props.max,
  12616. "aria-disabled": props.disabled || void 0,
  12617. "aria-readonly": props.readonly || void 0,
  12618. "aria-orientation": props.vertical ? "vertical" : "horizontal",
  12619. "onTouchstartPassive": (event) => {
  12620. if (typeof index === "number") {
  12621. buttonIndex = index;
  12622. }
  12623. onTouchStart(event);
  12624. },
  12625. "onTouchend": onTouchEnd,
  12626. "onTouchcancel": onTouchEnd,
  12627. "onClick": stopPropagation
  12628. }, [renderButtonContent(current22, index)]);
  12629. };
  12630. updateValue(props.modelValue);
  12631. useCustomFieldValue(() => props.modelValue);
  12632. useEventListener("touchmove", onTouchMove, {
  12633. target: slider
  12634. });
  12635. return () => createVNode("div", {
  12636. "ref": root,
  12637. "style": wrapperStyle.value,
  12638. "class": bem$a({
  12639. vertical: props.vertical,
  12640. disabled: props.disabled
  12641. }),
  12642. "onClick": onClick
  12643. }, [createVNode("div", {
  12644. "class": bem$a("bar"),
  12645. "style": barStyle.value
  12646. }, [props.range ? [renderButton(0), renderButton(1)] : renderButton()])]);
  12647. }
  12648. });
  12649. const Slider = withInstall(stdin_default$g);
  12650. const [name$a, bem$9] = createNamespace("space");
  12651. const spaceProps = {
  12652. align: String,
  12653. direction: {
  12654. type: String,
  12655. default: "horizontal"
  12656. },
  12657. size: {
  12658. type: [Number, String, Array],
  12659. default: 8
  12660. },
  12661. wrap: Boolean,
  12662. fill: Boolean
  12663. };
  12664. function filterEmpty(children = []) {
  12665. const nodes = [];
  12666. children.forEach((child) => {
  12667. if (Array.isArray(child)) {
  12668. nodes.push(...child);
  12669. } else if (child.type === Fragment) {
  12670. nodes.push(...filterEmpty(child.children));
  12671. } else {
  12672. nodes.push(child);
  12673. }
  12674. });
  12675. return nodes.filter((c) => {
  12676. var _a;
  12677. return !(c && (typeof Comment !== "undefined" && c.type === Comment || c.type === Fragment && ((_a = c.children) == null ? void 0 : _a.length) === 0 || c.type === Text && c.children.trim() === ""));
  12678. });
  12679. }
  12680. var stdin_default$f = defineComponent({
  12681. name: name$a,
  12682. props: spaceProps,
  12683. setup(props, {
  12684. slots
  12685. }) {
  12686. const mergedAlign = computed(() => {
  12687. var _a;
  12688. return (_a = props.align) != null ? _a : props.direction === "horizontal" ? "center" : "";
  12689. });
  12690. const getMargin = (size) => {
  12691. if (typeof size === "number") {
  12692. return size + "px";
  12693. }
  12694. return size;
  12695. };
  12696. const getMarginStyle = (isLast) => {
  12697. const style = {};
  12698. const marginRight = `${getMargin(Array.isArray(props.size) ? props.size[0] : props.size)}`;
  12699. const marginBottom = `${getMargin(Array.isArray(props.size) ? props.size[1] : props.size)}`;
  12700. if (isLast) {
  12701. return props.wrap ? {
  12702. marginBottom
  12703. } : {};
  12704. }
  12705. if (props.direction === "horizontal") {
  12706. style.marginRight = marginRight;
  12707. }
  12708. if (props.direction === "vertical" || props.wrap) {
  12709. style.marginBottom = marginBottom;
  12710. }
  12711. return style;
  12712. };
  12713. return () => {
  12714. var _a;
  12715. const children = filterEmpty((_a = slots.default) == null ? void 0 : _a.call(slots));
  12716. return createVNode("div", {
  12717. "class": [bem$9({
  12718. [props.direction]: props.direction,
  12719. [`align-${mergedAlign.value}`]: mergedAlign.value,
  12720. wrap: props.wrap,
  12721. fill: props.fill
  12722. })]
  12723. }, [children.map((c, i) => createVNode("div", {
  12724. "key": `item-${i}`,
  12725. "class": `${name$a}-item`,
  12726. "style": getMarginStyle(i === children.length - 1)
  12727. }, [c]))]);
  12728. };
  12729. }
  12730. });
  12731. const Space = withInstall(stdin_default$f);
  12732. const [name$9, bem$8] = createNamespace("steps");
  12733. const stepsProps = {
  12734. active: makeNumericProp(0),
  12735. direction: makeStringProp("horizontal"),
  12736. activeIcon: makeStringProp("checked"),
  12737. iconPrefix: String,
  12738. finishIcon: String,
  12739. activeColor: String,
  12740. inactiveIcon: String,
  12741. inactiveColor: String
  12742. };
  12743. const STEPS_KEY = Symbol(name$9);
  12744. var stdin_default$e = defineComponent({
  12745. name: name$9,
  12746. props: stepsProps,
  12747. emits: ["clickStep"],
  12748. setup(props, {
  12749. emit,
  12750. slots
  12751. }) {
  12752. const {
  12753. linkChildren
  12754. } = useChildren(STEPS_KEY);
  12755. const onClickStep = (index) => emit("clickStep", index);
  12756. linkChildren({
  12757. props,
  12758. onClickStep
  12759. });
  12760. return () => {
  12761. var _a;
  12762. return createVNode("div", {
  12763. "class": bem$8([props.direction])
  12764. }, [createVNode("div", {
  12765. "class": bem$8("items")
  12766. }, [(_a = slots.default) == null ? void 0 : _a.call(slots)])]);
  12767. };
  12768. }
  12769. });
  12770. const [name$8, bem$7] = createNamespace("step");
  12771. var stdin_default$d = defineComponent({
  12772. name: name$8,
  12773. setup(props, {
  12774. slots
  12775. }) {
  12776. const {
  12777. parent,
  12778. index
  12779. } = useParent(STEPS_KEY);
  12780. if (!parent) {
  12781. if (process.env.NODE_ENV !== "production") {
  12782. console.error("[Vant] <Step> must be a child component of <Steps>.");
  12783. }
  12784. return;
  12785. }
  12786. const parentProps = parent.props;
  12787. const getStatus = () => {
  12788. const active = +parentProps.active;
  12789. if (index.value < active) {
  12790. return "finish";
  12791. }
  12792. return index.value === active ? "process" : "waiting";
  12793. };
  12794. const isActive = () => getStatus() === "process";
  12795. const lineStyle = computed(() => ({
  12796. background: getStatus() === "finish" ? parentProps.activeColor : parentProps.inactiveColor
  12797. }));
  12798. const titleStyle = computed(() => {
  12799. if (isActive()) {
  12800. return {
  12801. color: parentProps.activeColor
  12802. };
  12803. }
  12804. if (getStatus() === "waiting") {
  12805. return {
  12806. color: parentProps.inactiveColor
  12807. };
  12808. }
  12809. });
  12810. const onClickStep = () => parent.onClickStep(index.value);
  12811. const renderCircle = () => {
  12812. const {
  12813. iconPrefix,
  12814. finishIcon,
  12815. activeIcon,
  12816. activeColor,
  12817. inactiveIcon
  12818. } = parentProps;
  12819. if (isActive()) {
  12820. if (slots["active-icon"]) {
  12821. return slots["active-icon"]();
  12822. }
  12823. return createVNode(Icon, {
  12824. "class": bem$7("icon", "active"),
  12825. "name": activeIcon,
  12826. "color": activeColor,
  12827. "classPrefix": iconPrefix
  12828. }, null);
  12829. }
  12830. if (getStatus() === "finish" && (finishIcon || slots["finish-icon"])) {
  12831. if (slots["finish-icon"]) {
  12832. return slots["finish-icon"]();
  12833. }
  12834. return createVNode(Icon, {
  12835. "class": bem$7("icon", "finish"),
  12836. "name": finishIcon,
  12837. "color": activeColor,
  12838. "classPrefix": iconPrefix
  12839. }, null);
  12840. }
  12841. if (slots["inactive-icon"]) {
  12842. return slots["inactive-icon"]();
  12843. }
  12844. if (inactiveIcon) {
  12845. return createVNode(Icon, {
  12846. "class": bem$7("icon"),
  12847. "name": inactiveIcon,
  12848. "classPrefix": iconPrefix
  12849. }, null);
  12850. }
  12851. return createVNode("i", {
  12852. "class": bem$7("circle"),
  12853. "style": lineStyle.value
  12854. }, null);
  12855. };
  12856. return () => {
  12857. var _a;
  12858. const status = getStatus();
  12859. return createVNode("div", {
  12860. "class": [BORDER, bem$7([parentProps.direction, {
  12861. [status]: status
  12862. }])]
  12863. }, [createVNode("div", {
  12864. "class": bem$7("title", {
  12865. active: isActive()
  12866. }),
  12867. "style": titleStyle.value,
  12868. "onClick": onClickStep
  12869. }, [(_a = slots.default) == null ? void 0 : _a.call(slots)]), createVNode("div", {
  12870. "class": bem$7("circle-container"),
  12871. "onClick": onClickStep
  12872. }, [renderCircle()]), createVNode("div", {
  12873. "class": bem$7("line"),
  12874. "style": lineStyle.value
  12875. }, null)]);
  12876. };
  12877. }
  12878. });
  12879. const Step = withInstall(stdin_default$d);
  12880. const [name$7, bem$6] = createNamespace("stepper");
  12881. const LONG_PRESS_INTERVAL = 200;
  12882. const isEqual = (value1, value2) => String(value1) === String(value2);
  12883. const stepperProps = {
  12884. min: makeNumericProp(1),
  12885. max: makeNumericProp(Infinity),
  12886. name: makeNumericProp(""),
  12887. step: makeNumericProp(1),
  12888. theme: String,
  12889. integer: Boolean,
  12890. disabled: Boolean,
  12891. showPlus: truthProp,
  12892. showMinus: truthProp,
  12893. showInput: truthProp,
  12894. longPress: truthProp,
  12895. autoFixed: truthProp,
  12896. allowEmpty: Boolean,
  12897. modelValue: numericProp,
  12898. inputWidth: numericProp,
  12899. buttonSize: numericProp,
  12900. placeholder: String,
  12901. disablePlus: Boolean,
  12902. disableMinus: Boolean,
  12903. disableInput: Boolean,
  12904. beforeChange: Function,
  12905. defaultValue: makeNumericProp(1),
  12906. decimalLength: numericProp
  12907. };
  12908. var stdin_default$c = defineComponent({
  12909. name: name$7,
  12910. props: stepperProps,
  12911. emits: ["plus", "blur", "minus", "focus", "change", "overlimit", "update:modelValue"],
  12912. setup(props, {
  12913. emit
  12914. }) {
  12915. const format2 = (value, autoFixed = true) => {
  12916. const {
  12917. min,
  12918. max,
  12919. allowEmpty,
  12920. decimalLength
  12921. } = props;
  12922. if (allowEmpty && value === "") {
  12923. return value;
  12924. }
  12925. value = formatNumber(String(value), !props.integer);
  12926. value = value === "" ? 0 : +value;
  12927. value = Number.isNaN(value) ? +min : value;
  12928. value = autoFixed ? Math.max(Math.min(+max, value), +min) : value;
  12929. if (isDef(decimalLength)) {
  12930. value = value.toFixed(+decimalLength);
  12931. }
  12932. return value;
  12933. };
  12934. const getInitialValue = () => {
  12935. var _a;
  12936. const defaultValue = (_a = props.modelValue) != null ? _a : props.defaultValue;
  12937. const value = format2(defaultValue);
  12938. if (!isEqual(value, props.modelValue)) {
  12939. emit("update:modelValue", value);
  12940. }
  12941. return value;
  12942. };
  12943. let actionType;
  12944. const inputRef = ref();
  12945. const current2 = ref(getInitialValue());
  12946. const minusDisabled = computed(() => props.disabled || props.disableMinus || current2.value <= +props.min);
  12947. const plusDisabled = computed(() => props.disabled || props.disablePlus || current2.value >= +props.max);
  12948. const inputStyle = computed(() => ({
  12949. width: addUnit(props.inputWidth),
  12950. height: addUnit(props.buttonSize)
  12951. }));
  12952. const buttonStyle = computed(() => getSizeStyle(props.buttonSize));
  12953. const check = () => {
  12954. const value = format2(current2.value);
  12955. if (!isEqual(value, current2.value)) {
  12956. current2.value = value;
  12957. }
  12958. };
  12959. const setValue = (value) => {
  12960. if (props.beforeChange) {
  12961. callInterceptor(props.beforeChange, {
  12962. args: [value],
  12963. done() {
  12964. current2.value = value;
  12965. }
  12966. });
  12967. } else {
  12968. current2.value = value;
  12969. }
  12970. };
  12971. const onChange = () => {
  12972. if (actionType === "plus" && plusDisabled.value || actionType === "minus" && minusDisabled.value) {
  12973. emit("overlimit", actionType);
  12974. return;
  12975. }
  12976. const diff = actionType === "minus" ? -props.step : +props.step;
  12977. const value = format2(addNumber(+current2.value, diff));
  12978. setValue(value);
  12979. emit(actionType);
  12980. };
  12981. const onInput = (event) => {
  12982. const input = event.target;
  12983. const {
  12984. value
  12985. } = input;
  12986. const {
  12987. decimalLength
  12988. } = props;
  12989. let formatted = formatNumber(String(value), !props.integer);
  12990. if (isDef(decimalLength) && formatted.includes(".")) {
  12991. const pair = formatted.split(".");
  12992. formatted = `${pair[0]}.${pair[1].slice(0, +decimalLength)}`;
  12993. }
  12994. if (props.beforeChange) {
  12995. input.value = String(current2.value);
  12996. } else if (!isEqual(value, formatted)) {
  12997. input.value = formatted;
  12998. }
  12999. const isNumeric2 = formatted === String(+formatted);
  13000. setValue(isNumeric2 ? +formatted : formatted);
  13001. };
  13002. const onFocus = (event) => {
  13003. var _a;
  13004. if (props.disableInput) {
  13005. (_a = inputRef.value) == null ? void 0 : _a.blur();
  13006. } else {
  13007. emit("focus", event);
  13008. }
  13009. };
  13010. const onBlur = (event) => {
  13011. const input = event.target;
  13012. const value = format2(input.value, props.autoFixed);
  13013. input.value = String(value);
  13014. current2.value = value;
  13015. nextTick(() => {
  13016. emit("blur", event);
  13017. resetScroll();
  13018. });
  13019. };
  13020. let isLongPress;
  13021. let longPressTimer;
  13022. const longPressStep = () => {
  13023. longPressTimer = setTimeout(() => {
  13024. onChange();
  13025. longPressStep();
  13026. }, LONG_PRESS_INTERVAL);
  13027. };
  13028. const onTouchStart = () => {
  13029. if (props.longPress) {
  13030. isLongPress = false;
  13031. clearTimeout(longPressTimer);
  13032. longPressTimer = setTimeout(() => {
  13033. isLongPress = true;
  13034. onChange();
  13035. longPressStep();
  13036. }, LONG_PRESS_START_TIME);
  13037. }
  13038. };
  13039. const onTouchEnd = (event) => {
  13040. if (props.longPress) {
  13041. clearTimeout(longPressTimer);
  13042. if (isLongPress) {
  13043. preventDefault(event);
  13044. }
  13045. }
  13046. };
  13047. const onMousedown = (event) => {
  13048. if (props.disableInput) {
  13049. preventDefault(event);
  13050. }
  13051. };
  13052. const createListeners = (type) => ({
  13053. onClick: (event) => {
  13054. preventDefault(event);
  13055. actionType = type;
  13056. onChange();
  13057. },
  13058. onTouchstartPassive: () => {
  13059. actionType = type;
  13060. onTouchStart();
  13061. },
  13062. onTouchend: onTouchEnd,
  13063. onTouchcancel: onTouchEnd
  13064. });
  13065. watch(() => [props.max, props.min, props.integer, props.decimalLength], check);
  13066. watch(() => props.modelValue, (value) => {
  13067. if (!isEqual(value, current2.value)) {
  13068. current2.value = format2(value);
  13069. }
  13070. });
  13071. watch(current2, (value) => {
  13072. emit("update:modelValue", value);
  13073. emit("change", value, {
  13074. name: props.name
  13075. });
  13076. });
  13077. useCustomFieldValue(() => props.modelValue);
  13078. return () => createVNode("div", {
  13079. "role": "group",
  13080. "class": bem$6([props.theme])
  13081. }, [withDirectives(createVNode("button", mergeProps({
  13082. "type": "button",
  13083. "style": buttonStyle.value,
  13084. "class": [bem$6("minus", {
  13085. disabled: minusDisabled.value
  13086. }), {
  13087. [HAPTICS_FEEDBACK]: !minusDisabled.value
  13088. }],
  13089. "aria-disabled": minusDisabled.value || void 0
  13090. }, createListeners("minus")), null), [[vShow, props.showMinus]]), withDirectives(createVNode("input", {
  13091. "ref": inputRef,
  13092. "type": props.integer ? "tel" : "text",
  13093. "role": "spinbutton",
  13094. "class": bem$6("input"),
  13095. "value": current2.value,
  13096. "style": inputStyle.value,
  13097. "disabled": props.disabled,
  13098. "readonly": props.disableInput,
  13099. "inputmode": props.integer ? "numeric" : "decimal",
  13100. "placeholder": props.placeholder,
  13101. "aria-valuemax": props.max,
  13102. "aria-valuemin": props.min,
  13103. "aria-valuenow": current2.value,
  13104. "onBlur": onBlur,
  13105. "onInput": onInput,
  13106. "onFocus": onFocus,
  13107. "onMousedown": onMousedown
  13108. }, null), [[vShow, props.showInput]]), withDirectives(createVNode("button", mergeProps({
  13109. "type": "button",
  13110. "style": buttonStyle.value,
  13111. "class": [bem$6("plus", {
  13112. disabled: plusDisabled.value
  13113. }), {
  13114. [HAPTICS_FEEDBACK]: !plusDisabled.value
  13115. }],
  13116. "aria-disabled": plusDisabled.value || void 0
  13117. }, createListeners("plus")), null), [[vShow, props.showPlus]])]);
  13118. }
  13119. });
  13120. const Stepper = withInstall(stdin_default$c);
  13121. const Steps = withInstall(stdin_default$e);
  13122. const [name$6, bem$5, t$1] = createNamespace("submit-bar");
  13123. const submitBarProps = {
  13124. tip: String,
  13125. label: String,
  13126. price: Number,
  13127. tipIcon: String,
  13128. loading: Boolean,
  13129. currency: makeStringProp("\xA5"),
  13130. disabled: Boolean,
  13131. textAlign: String,
  13132. buttonText: String,
  13133. buttonType: makeStringProp("danger"),
  13134. buttonColor: String,
  13135. suffixLabel: String,
  13136. placeholder: Boolean,
  13137. decimalLength: makeNumericProp(2),
  13138. safeAreaInsetBottom: truthProp
  13139. };
  13140. var stdin_default$b = defineComponent({
  13141. name: name$6,
  13142. props: submitBarProps,
  13143. emits: ["submit"],
  13144. setup(props, {
  13145. emit,
  13146. slots
  13147. }) {
  13148. const root = ref();
  13149. const renderPlaceholder = usePlaceholder(root, bem$5);
  13150. const renderText = () => {
  13151. const {
  13152. price,
  13153. label,
  13154. currency,
  13155. textAlign,
  13156. suffixLabel,
  13157. decimalLength
  13158. } = props;
  13159. if (typeof price === "number") {
  13160. const pricePair = (price / 100).toFixed(+decimalLength).split(".");
  13161. const decimal = decimalLength ? `.${pricePair[1]}` : "";
  13162. return createVNode("div", {
  13163. "class": bem$5("text"),
  13164. "style": {
  13165. textAlign
  13166. }
  13167. }, [createVNode("span", null, [label || t$1("label")]), createVNode("span", {
  13168. "class": bem$5("price")
  13169. }, [currency, createVNode("span", {
  13170. "class": bem$5("price-integer")
  13171. }, [pricePair[0]]), decimal]), suffixLabel && createVNode("span", {
  13172. "class": bem$5("suffix-label")
  13173. }, [suffixLabel])]);
  13174. }
  13175. };
  13176. const renderTip = () => {
  13177. var _a;
  13178. const {
  13179. tip,
  13180. tipIcon
  13181. } = props;
  13182. if (slots.tip || tip) {
  13183. return createVNode("div", {
  13184. "class": bem$5("tip")
  13185. }, [tipIcon && createVNode(Icon, {
  13186. "class": bem$5("tip-icon"),
  13187. "name": tipIcon
  13188. }, null), tip && createVNode("span", {
  13189. "class": bem$5("tip-text")
  13190. }, [tip]), (_a = slots.tip) == null ? void 0 : _a.call(slots)]);
  13191. }
  13192. };
  13193. const onClickButton = () => emit("submit");
  13194. const renderButton = () => {
  13195. if (slots.button) {
  13196. return slots.button();
  13197. }
  13198. return createVNode(Button, {
  13199. "round": true,
  13200. "type": props.buttonType,
  13201. "text": props.buttonText,
  13202. "class": bem$5("button", props.buttonType),
  13203. "color": props.buttonColor,
  13204. "loading": props.loading,
  13205. "disabled": props.disabled,
  13206. "onClick": onClickButton
  13207. }, null);
  13208. };
  13209. const renderSubmitBar = () => {
  13210. var _a, _b;
  13211. return createVNode("div", {
  13212. "ref": root,
  13213. "class": [bem$5(), {
  13214. "van-safe-area-bottom": props.safeAreaInsetBottom
  13215. }]
  13216. }, [(_a = slots.top) == null ? void 0 : _a.call(slots), renderTip(), createVNode("div", {
  13217. "class": bem$5("bar")
  13218. }, [(_b = slots.default) == null ? void 0 : _b.call(slots), renderText(), renderButton()])]);
  13219. };
  13220. return () => {
  13221. if (props.placeholder) {
  13222. return renderPlaceholder(renderSubmitBar);
  13223. }
  13224. return renderSubmitBar();
  13225. };
  13226. }
  13227. });
  13228. const SubmitBar = withInstall(stdin_default$b);
  13229. const [name$5, bem$4] = createNamespace("swipe-cell");
  13230. const swipeCellProps = {
  13231. name: makeNumericProp(""),
  13232. disabled: Boolean,
  13233. leftWidth: numericProp,
  13234. rightWidth: numericProp,
  13235. beforeClose: Function,
  13236. stopPropagation: Boolean
  13237. };
  13238. var stdin_default$a = defineComponent({
  13239. name: name$5,
  13240. props: swipeCellProps,
  13241. emits: ["open", "close", "click"],
  13242. setup(props, {
  13243. emit,
  13244. slots
  13245. }) {
  13246. let opened;
  13247. let lockClick2;
  13248. let startOffset;
  13249. const root = ref();
  13250. const leftRef = ref();
  13251. const rightRef = ref();
  13252. const state = reactive({
  13253. offset: 0,
  13254. dragging: false
  13255. });
  13256. const touch = useTouch();
  13257. const getWidthByRef = (ref2) => ref2.value ? useRect(ref2).width : 0;
  13258. const leftWidth = computed(() => isDef(props.leftWidth) ? +props.leftWidth : getWidthByRef(leftRef));
  13259. const rightWidth = computed(() => isDef(props.rightWidth) ? +props.rightWidth : getWidthByRef(rightRef));
  13260. const open = (side) => {
  13261. state.offset = side === "left" ? leftWidth.value : -rightWidth.value;
  13262. if (!opened) {
  13263. opened = true;
  13264. emit("open", {
  13265. name: props.name,
  13266. position: side
  13267. });
  13268. }
  13269. };
  13270. const close = (position) => {
  13271. state.offset = 0;
  13272. if (opened) {
  13273. opened = false;
  13274. emit("close", {
  13275. name: props.name,
  13276. position
  13277. });
  13278. }
  13279. };
  13280. const toggle = (side) => {
  13281. const offset = Math.abs(state.offset);
  13282. const THRESHOLD = 0.15;
  13283. const threshold = opened ? 1 - THRESHOLD : THRESHOLD;
  13284. const width = side === "left" ? leftWidth.value : rightWidth.value;
  13285. if (width && offset > width * threshold) {
  13286. open(side);
  13287. } else {
  13288. close(side);
  13289. }
  13290. };
  13291. const onTouchStart = (event) => {
  13292. if (!props.disabled) {
  13293. startOffset = state.offset;
  13294. touch.start(event);
  13295. }
  13296. };
  13297. const onTouchMove = (event) => {
  13298. if (props.disabled) {
  13299. return;
  13300. }
  13301. const {
  13302. deltaX
  13303. } = touch;
  13304. touch.move(event);
  13305. if (touch.isHorizontal()) {
  13306. lockClick2 = true;
  13307. state.dragging = true;
  13308. const isEdge = !opened || deltaX.value * startOffset < 0;
  13309. if (isEdge) {
  13310. preventDefault(event, props.stopPropagation);
  13311. }
  13312. state.offset = clamp(deltaX.value + startOffset, -rightWidth.value, leftWidth.value);
  13313. }
  13314. };
  13315. const onTouchEnd = () => {
  13316. if (state.dragging) {
  13317. state.dragging = false;
  13318. toggle(state.offset > 0 ? "left" : "right");
  13319. setTimeout(() => {
  13320. lockClick2 = false;
  13321. }, 0);
  13322. }
  13323. };
  13324. const onClick = (position = "outside") => {
  13325. emit("click", position);
  13326. if (opened && !lockClick2) {
  13327. callInterceptor(props.beforeClose, {
  13328. args: [{
  13329. name: props.name,
  13330. position
  13331. }],
  13332. done: () => close(position)
  13333. });
  13334. }
  13335. };
  13336. const getClickHandler = (position, stop) => (event) => {
  13337. if (stop) {
  13338. event.stopPropagation();
  13339. }
  13340. onClick(position);
  13341. };
  13342. const renderSideContent = (side, ref2) => {
  13343. const contentSlot = slots[side];
  13344. if (contentSlot) {
  13345. return createVNode("div", {
  13346. "ref": ref2,
  13347. "class": bem$4(side),
  13348. "onClick": getClickHandler(side, true)
  13349. }, [contentSlot()]);
  13350. }
  13351. };
  13352. useExpose({
  13353. open,
  13354. close
  13355. });
  13356. useClickAway(root, () => onClick("outside"), {
  13357. eventName: "touchstart"
  13358. });
  13359. useEventListener("touchmove", onTouchMove, {
  13360. target: root
  13361. });
  13362. return () => {
  13363. var _a;
  13364. const wrapperStyle = {
  13365. transform: `translate3d(${state.offset}px, 0, 0)`,
  13366. transitionDuration: state.dragging ? "0s" : ".6s"
  13367. };
  13368. return createVNode("div", {
  13369. "ref": root,
  13370. "class": bem$4(),
  13371. "onClick": getClickHandler("cell", lockClick2),
  13372. "onTouchstartPassive": onTouchStart,
  13373. "onTouchend": onTouchEnd,
  13374. "onTouchcancel": onTouchEnd
  13375. }, [createVNode("div", {
  13376. "class": bem$4("wrapper"),
  13377. "style": wrapperStyle
  13378. }, [renderSideContent("left", leftRef), (_a = slots.default) == null ? void 0 : _a.call(slots), renderSideContent("right", rightRef)])]);
  13379. };
  13380. }
  13381. });
  13382. const SwipeCell = withInstall(stdin_default$a);
  13383. const [name$4, bem$3] = createNamespace("tabbar");
  13384. const tabbarProps = {
  13385. route: Boolean,
  13386. fixed: truthProp,
  13387. border: truthProp,
  13388. zIndex: numericProp,
  13389. placeholder: Boolean,
  13390. activeColor: String,
  13391. beforeChange: Function,
  13392. inactiveColor: String,
  13393. modelValue: makeNumericProp(0),
  13394. safeAreaInsetBottom: {
  13395. type: Boolean,
  13396. default: null
  13397. }
  13398. };
  13399. const TABBAR_KEY = Symbol(name$4);
  13400. var stdin_default$9 = defineComponent({
  13401. name: name$4,
  13402. props: tabbarProps,
  13403. emits: ["change", "update:modelValue"],
  13404. setup(props, {
  13405. emit,
  13406. slots
  13407. }) {
  13408. const root = ref();
  13409. const {
  13410. linkChildren
  13411. } = useChildren(TABBAR_KEY);
  13412. const renderPlaceholder = usePlaceholder(root, bem$3);
  13413. const enableSafeArea = () => {
  13414. var _a;
  13415. return (_a = props.safeAreaInsetBottom) != null ? _a : props.fixed;
  13416. };
  13417. const renderTabbar = () => {
  13418. var _a;
  13419. const {
  13420. fixed,
  13421. zIndex,
  13422. border
  13423. } = props;
  13424. return createVNode("div", {
  13425. "ref": root,
  13426. "role": "tablist",
  13427. "style": getZIndexStyle(zIndex),
  13428. "class": [bem$3({
  13429. fixed
  13430. }), {
  13431. [BORDER_TOP_BOTTOM]: border,
  13432. "van-safe-area-bottom": enableSafeArea()
  13433. }]
  13434. }, [(_a = slots.default) == null ? void 0 : _a.call(slots)]);
  13435. };
  13436. const setActive = (active, afterChange) => {
  13437. callInterceptor(props.beforeChange, {
  13438. args: [active],
  13439. done() {
  13440. emit("update:modelValue", active);
  13441. emit("change", active);
  13442. afterChange();
  13443. }
  13444. });
  13445. };
  13446. linkChildren({
  13447. props,
  13448. setActive
  13449. });
  13450. return () => {
  13451. if (props.fixed && props.placeholder) {
  13452. return renderPlaceholder(renderTabbar);
  13453. }
  13454. return renderTabbar();
  13455. };
  13456. }
  13457. });
  13458. const Tabbar = withInstall(stdin_default$9);
  13459. const [name$3, bem$2] = createNamespace("tabbar-item");
  13460. const tabbarItemProps = extend({}, routeProps, {
  13461. dot: Boolean,
  13462. icon: String,
  13463. name: numericProp,
  13464. badge: numericProp,
  13465. badgeProps: Object,
  13466. iconPrefix: String
  13467. });
  13468. var stdin_default$8 = defineComponent({
  13469. name: name$3,
  13470. props: tabbarItemProps,
  13471. emits: ["click"],
  13472. setup(props, {
  13473. emit,
  13474. slots
  13475. }) {
  13476. const route2 = useRoute();
  13477. const vm = getCurrentInstance().proxy;
  13478. const {
  13479. parent,
  13480. index
  13481. } = useParent(TABBAR_KEY);
  13482. if (!parent) {
  13483. if (process.env.NODE_ENV !== "production") {
  13484. console.error("[Vant] <TabbarItem> must be a child component of <Tabbar>.");
  13485. }
  13486. return;
  13487. }
  13488. const active = computed(() => {
  13489. var _a;
  13490. const {
  13491. route: route22,
  13492. modelValue
  13493. } = parent.props;
  13494. if (route22 && "$route" in vm) {
  13495. const {
  13496. $route
  13497. } = vm;
  13498. const {
  13499. to
  13500. } = props;
  13501. const config = isObject(to) ? to : {
  13502. path: to
  13503. };
  13504. return !!$route.matched.find((val) => {
  13505. const pathMatched = "path" in config && config.path === val.path;
  13506. const nameMatched = "name" in config && config.name === val.name;
  13507. return pathMatched || nameMatched;
  13508. });
  13509. }
  13510. return ((_a = props.name) != null ? _a : index.value) === modelValue;
  13511. });
  13512. const onClick = (event) => {
  13513. var _a;
  13514. if (!active.value) {
  13515. parent.setActive((_a = props.name) != null ? _a : index.value, route2);
  13516. }
  13517. emit("click", event);
  13518. };
  13519. const renderIcon = () => {
  13520. if (slots.icon) {
  13521. return slots.icon({
  13522. active: active.value
  13523. });
  13524. }
  13525. if (props.icon) {
  13526. return createVNode(Icon, {
  13527. "name": props.icon,
  13528. "classPrefix": props.iconPrefix
  13529. }, null);
  13530. }
  13531. };
  13532. return () => {
  13533. var _a;
  13534. const {
  13535. dot,
  13536. badge
  13537. } = props;
  13538. const {
  13539. activeColor,
  13540. inactiveColor
  13541. } = parent.props;
  13542. const color = active.value ? activeColor : inactiveColor;
  13543. return createVNode("div", {
  13544. "role": "tab",
  13545. "class": bem$2({
  13546. active: active.value
  13547. }),
  13548. "style": {
  13549. color
  13550. },
  13551. "tabindex": 0,
  13552. "aria-selected": active.value,
  13553. "onClick": onClick
  13554. }, [createVNode(Badge, mergeProps({
  13555. "dot": dot,
  13556. "class": bem$2("icon"),
  13557. "content": badge
  13558. }, props.badgeProps), {
  13559. default: renderIcon
  13560. }), createVNode("div", {
  13561. "class": bem$2("text")
  13562. }, [(_a = slots.default) == null ? void 0 : _a.call(slots, {
  13563. active: active.value
  13564. })])]);
  13565. };
  13566. }
  13567. });
  13568. const TabbarItem = withInstall(stdin_default$8);
  13569. const [name$2] = createNamespace("time-picker");
  13570. const timePickerProps = extend({}, sharedProps, {
  13571. minHour: makeNumericProp(0),
  13572. maxHour: makeNumericProp(23),
  13573. minMinute: makeNumericProp(0),
  13574. maxMinute: makeNumericProp(59),
  13575. minSecond: makeNumericProp(0),
  13576. maxSecond: makeNumericProp(59),
  13577. columnsType: {
  13578. type: Array,
  13579. default: () => ["hour", "minute"]
  13580. }
  13581. });
  13582. var stdin_default$7 = defineComponent({
  13583. name: name$2,
  13584. props: timePickerProps,
  13585. emits: ["confirm", "cancel", "change", "update:modelValue"],
  13586. setup(props, {
  13587. emit,
  13588. slots
  13589. }) {
  13590. const currentValues = ref(props.modelValue);
  13591. const columns = computed(() => props.columnsType.map((type) => {
  13592. const {
  13593. filter,
  13594. formatter
  13595. } = props;
  13596. switch (type) {
  13597. case "hour":
  13598. return genOptions(+props.minHour, +props.maxHour, type, formatter, filter);
  13599. case "minute":
  13600. return genOptions(+props.minMinute, +props.maxMinute, type, formatter, filter);
  13601. case "second":
  13602. return genOptions(+props.minSecond, +props.maxSecond, type, formatter, filter);
  13603. default:
  13604. if (process.env.NODE_ENV !== "production") {
  13605. throw new Error(`[Vant] DatePicker: unsupported columns type: ${type}`);
  13606. }
  13607. return [];
  13608. }
  13609. }));
  13610. watch(currentValues, (newValues) => {
  13611. if (!isSameValue(newValues, props.modelValue)) {
  13612. emit("update:modelValue", newValues);
  13613. }
  13614. });
  13615. watch(() => props.modelValue, (newValues) => {
  13616. newValues = formatValueRange(newValues, columns.value);
  13617. if (!isSameValue(newValues, currentValues.value)) {
  13618. currentValues.value = newValues;
  13619. }
  13620. }, {
  13621. immediate: true
  13622. });
  13623. const onChange = (...args) => emit("change", ...args);
  13624. const onCancel = (...args) => emit("cancel", ...args);
  13625. const onConfirm = (...args) => emit("confirm", ...args);
  13626. return () => createVNode(Picker, mergeProps({
  13627. "modelValue": currentValues.value,
  13628. "onUpdate:modelValue": ($event) => currentValues.value = $event,
  13629. "columns": columns.value,
  13630. "onChange": onChange,
  13631. "onCancel": onCancel,
  13632. "onConfirm": onConfirm
  13633. }, pick(props, pickerInheritKeys)), slots);
  13634. }
  13635. });
  13636. const TimePicker = withInstall(stdin_default$7);
  13637. const [name$1, bem$1] = createNamespace("tree-select");
  13638. const treeSelectProps = {
  13639. max: makeNumericProp(Infinity),
  13640. items: makeArrayProp(),
  13641. height: makeNumericProp(300),
  13642. selectedIcon: makeStringProp("success"),
  13643. mainActiveIndex: makeNumericProp(0),
  13644. activeId: {
  13645. type: [Number, String, Array],
  13646. default: 0
  13647. }
  13648. };
  13649. var stdin_default$6 = defineComponent({
  13650. name: name$1,
  13651. props: treeSelectProps,
  13652. emits: ["clickNav", "clickItem", "update:activeId", "update:mainActiveIndex"],
  13653. setup(props, {
  13654. emit,
  13655. slots
  13656. }) {
  13657. const isActiveItem = (id) => Array.isArray(props.activeId) ? props.activeId.includes(id) : props.activeId === id;
  13658. const renderSubItem = (item) => {
  13659. const onClick = () => {
  13660. if (item.disabled) {
  13661. return;
  13662. }
  13663. let activeId;
  13664. if (Array.isArray(props.activeId)) {
  13665. activeId = props.activeId.slice();
  13666. const index = activeId.indexOf(item.id);
  13667. if (index !== -1) {
  13668. activeId.splice(index, 1);
  13669. } else if (activeId.length < props.max) {
  13670. activeId.push(item.id);
  13671. }
  13672. } else {
  13673. activeId = item.id;
  13674. }
  13675. emit("update:activeId", activeId);
  13676. emit("clickItem", item);
  13677. };
  13678. return createVNode("div", {
  13679. "key": item.id,
  13680. "class": ["van-ellipsis", bem$1("item", {
  13681. active: isActiveItem(item.id),
  13682. disabled: item.disabled
  13683. })],
  13684. "onClick": onClick
  13685. }, [item.text, isActiveItem(item.id) && createVNode(Icon, {
  13686. "name": props.selectedIcon,
  13687. "class": bem$1("selected")
  13688. }, null)]);
  13689. };
  13690. const onSidebarChange = (index) => {
  13691. emit("update:mainActiveIndex", index);
  13692. };
  13693. const onClickSidebarItem = (index) => emit("clickNav", index);
  13694. const renderSidebar = () => {
  13695. const Items = props.items.map((item) => createVNode(SidebarItem, {
  13696. "dot": item.dot,
  13697. "title": item.text,
  13698. "badge": item.badge,
  13699. "class": [bem$1("nav-item"), item.className],
  13700. "disabled": item.disabled,
  13701. "onClick": onClickSidebarItem
  13702. }, null));
  13703. return createVNode(Sidebar, {
  13704. "class": bem$1("nav"),
  13705. "modelValue": props.mainActiveIndex,
  13706. "onChange": onSidebarChange
  13707. }, {
  13708. default: () => [Items]
  13709. });
  13710. };
  13711. const renderContent = () => {
  13712. if (slots.content) {
  13713. return slots.content();
  13714. }
  13715. const selected = props.items[+props.mainActiveIndex] || {};
  13716. if (selected.children) {
  13717. return selected.children.map(renderSubItem);
  13718. }
  13719. };
  13720. return () => createVNode("div", {
  13721. "class": bem$1(),
  13722. "style": {
  13723. height: addUnit(props.height)
  13724. }
  13725. }, [renderSidebar(), createVNode("div", {
  13726. "class": bem$1("content")
  13727. }, [renderContent()])]);
  13728. }
  13729. });
  13730. const TreeSelect = withInstall(stdin_default$6);
  13731. const [name, bem, t] = createNamespace("uploader");
  13732. function readFileContent(file, resultType) {
  13733. return new Promise((resolve) => {
  13734. if (resultType === "file") {
  13735. resolve();
  13736. return;
  13737. }
  13738. const reader = new FileReader();
  13739. reader.onload = (event) => {
  13740. resolve(event.target.result);
  13741. };
  13742. if (resultType === "dataUrl") {
  13743. reader.readAsDataURL(file);
  13744. } else if (resultType === "text") {
  13745. reader.readAsText(file);
  13746. }
  13747. });
  13748. }
  13749. function isOversize(items, maxSize) {
  13750. return toArray(items).some((item) => {
  13751. if (item.file) {
  13752. if (isFunction(maxSize)) {
  13753. return maxSize(item.file);
  13754. }
  13755. return item.file.size > maxSize;
  13756. }
  13757. return false;
  13758. });
  13759. }
  13760. function filterFiles(items, maxSize) {
  13761. const valid = [];
  13762. const invalid = [];
  13763. items.forEach((item) => {
  13764. if (isOversize(item, maxSize)) {
  13765. invalid.push(item);
  13766. } else {
  13767. valid.push(item);
  13768. }
  13769. });
  13770. return { valid, invalid };
  13771. }
  13772. const IMAGE_REGEXP = /\.(jpeg|jpg|gif|png|svg|webp|jfif|bmp|dpg)/i;
  13773. const isImageUrl = (url) => IMAGE_REGEXP.test(url);
  13774. function isImageFile(item) {
  13775. if (item.isImage) {
  13776. return true;
  13777. }
  13778. if (item.file && item.file.type) {
  13779. return item.file.type.indexOf("image") === 0;
  13780. }
  13781. if (item.url) {
  13782. return isImageUrl(item.url);
  13783. }
  13784. if (typeof item.content === "string") {
  13785. return item.content.indexOf("data:image") === 0;
  13786. }
  13787. return false;
  13788. }
  13789. var stdin_default$5 = defineComponent({
  13790. props: {
  13791. name: numericProp,
  13792. item: makeRequiredProp(Object),
  13793. index: Number,
  13794. imageFit: String,
  13795. lazyLoad: Boolean,
  13796. deletable: Boolean,
  13797. previewSize: [Number, String, Array],
  13798. beforeDelete: Function
  13799. },
  13800. emits: ["delete", "preview"],
  13801. setup(props, {
  13802. emit,
  13803. slots
  13804. }) {
  13805. const renderMask = () => {
  13806. const {
  13807. status,
  13808. message
  13809. } = props.item;
  13810. if (status === "uploading" || status === "failed") {
  13811. const MaskIcon = status === "failed" ? createVNode(Icon, {
  13812. "name": "close",
  13813. "class": bem("mask-icon")
  13814. }, null) : createVNode(Loading, {
  13815. "class": bem("loading")
  13816. }, null);
  13817. const showMessage = isDef(message) && message !== "";
  13818. return createVNode("div", {
  13819. "class": bem("mask")
  13820. }, [MaskIcon, showMessage && createVNode("div", {
  13821. "class": bem("mask-message")
  13822. }, [message])]);
  13823. }
  13824. };
  13825. const onDelete = (event) => {
  13826. const {
  13827. name: name2,
  13828. item,
  13829. index,
  13830. beforeDelete
  13831. } = props;
  13832. event.stopPropagation();
  13833. callInterceptor(beforeDelete, {
  13834. args: [item, {
  13835. name: name2,
  13836. index
  13837. }],
  13838. done: () => emit("delete")
  13839. });
  13840. };
  13841. const onPreview = () => emit("preview");
  13842. const renderDeleteIcon = () => {
  13843. if (props.deletable && props.item.status !== "uploading") {
  13844. const slot = slots["preview-delete"];
  13845. return createVNode("div", {
  13846. "role": "button",
  13847. "class": bem("preview-delete", {
  13848. shadow: !slot
  13849. }),
  13850. "tabindex": 0,
  13851. "aria-label": t("delete"),
  13852. "onClick": onDelete
  13853. }, [slot ? slot() : createVNode(Icon, {
  13854. "name": "cross",
  13855. "class": bem("preview-delete-icon")
  13856. }, null)]);
  13857. }
  13858. };
  13859. const renderCover = () => {
  13860. if (slots["preview-cover"]) {
  13861. const {
  13862. index,
  13863. item
  13864. } = props;
  13865. return createVNode("div", {
  13866. "class": bem("preview-cover")
  13867. }, [slots["preview-cover"](extend({
  13868. index
  13869. }, item))]);
  13870. }
  13871. };
  13872. const renderPreview = () => {
  13873. const {
  13874. item,
  13875. lazyLoad,
  13876. imageFit,
  13877. previewSize
  13878. } = props;
  13879. if (isImageFile(item)) {
  13880. return createVNode(Image$1, {
  13881. "fit": imageFit,
  13882. "src": item.content || item.url,
  13883. "class": bem("preview-image"),
  13884. "width": Array.isArray(previewSize) ? previewSize[0] : previewSize,
  13885. "height": Array.isArray(previewSize) ? previewSize[1] : previewSize,
  13886. "lazyLoad": lazyLoad,
  13887. "onClick": onPreview
  13888. }, {
  13889. default: renderCover
  13890. });
  13891. }
  13892. return createVNode("div", {
  13893. "class": bem("file"),
  13894. "style": getSizeStyle(props.previewSize)
  13895. }, [createVNode(Icon, {
  13896. "class": bem("file-icon"),
  13897. "name": "description"
  13898. }, null), createVNode("div", {
  13899. "class": [bem("file-name"), "van-ellipsis"]
  13900. }, [item.file ? item.file.name : item.url]), renderCover()]);
  13901. };
  13902. return () => createVNode("div", {
  13903. "class": bem("preview")
  13904. }, [renderPreview(), renderMask(), renderDeleteIcon()]);
  13905. }
  13906. });
  13907. const uploaderProps = {
  13908. name: makeNumericProp(""),
  13909. accept: makeStringProp("image/*"),
  13910. capture: String,
  13911. multiple: Boolean,
  13912. disabled: Boolean,
  13913. readonly: Boolean,
  13914. lazyLoad: Boolean,
  13915. maxCount: makeNumericProp(Infinity),
  13916. imageFit: makeStringProp("cover"),
  13917. resultType: makeStringProp("dataUrl"),
  13918. uploadIcon: makeStringProp("photograph"),
  13919. uploadText: String,
  13920. deletable: truthProp,
  13921. afterRead: Function,
  13922. showUpload: truthProp,
  13923. modelValue: makeArrayProp(),
  13924. beforeRead: Function,
  13925. beforeDelete: Function,
  13926. previewSize: [Number, String, Array],
  13927. previewImage: truthProp,
  13928. previewOptions: Object,
  13929. previewFullImage: truthProp,
  13930. maxSize: {
  13931. type: [Number, String, Function],
  13932. default: Infinity
  13933. }
  13934. };
  13935. var stdin_default$4 = defineComponent({
  13936. name,
  13937. props: uploaderProps,
  13938. emits: ["delete", "oversize", "clickUpload", "closePreview", "clickPreview", "update:modelValue"],
  13939. setup(props, {
  13940. emit,
  13941. slots
  13942. }) {
  13943. const inputRef = ref();
  13944. const urls = [];
  13945. const getDetail = (index = props.modelValue.length) => ({
  13946. name: props.name,
  13947. index
  13948. });
  13949. const resetInput = () => {
  13950. if (inputRef.value) {
  13951. inputRef.value.value = "";
  13952. }
  13953. };
  13954. const onAfterRead = (items) => {
  13955. resetInput();
  13956. if (isOversize(items, props.maxSize)) {
  13957. if (Array.isArray(items)) {
  13958. const result = filterFiles(items, props.maxSize);
  13959. items = result.valid;
  13960. emit("oversize", result.invalid, getDetail());
  13961. if (!items.length) {
  13962. return;
  13963. }
  13964. } else {
  13965. emit("oversize", items, getDetail());
  13966. return;
  13967. }
  13968. }
  13969. items = reactive(items);
  13970. emit("update:modelValue", [...props.modelValue, ...toArray(items)]);
  13971. if (props.afterRead) {
  13972. props.afterRead(items, getDetail());
  13973. }
  13974. };
  13975. const readFile = (files) => {
  13976. const {
  13977. maxCount,
  13978. modelValue,
  13979. resultType
  13980. } = props;
  13981. if (Array.isArray(files)) {
  13982. const remainCount = +maxCount - modelValue.length;
  13983. if (files.length > remainCount) {
  13984. files = files.slice(0, remainCount);
  13985. }
  13986. Promise.all(files.map((file) => readFileContent(file, resultType))).then((contents) => {
  13987. const fileList = files.map((file, index) => {
  13988. const result = {
  13989. file,
  13990. status: "",
  13991. message: ""
  13992. };
  13993. if (contents[index]) {
  13994. result.content = contents[index];
  13995. }
  13996. return result;
  13997. });
  13998. onAfterRead(fileList);
  13999. });
  14000. } else {
  14001. readFileContent(files, resultType).then((content) => {
  14002. const result = {
  14003. file: files,
  14004. status: "",
  14005. message: ""
  14006. };
  14007. if (content) {
  14008. result.content = content;
  14009. }
  14010. onAfterRead(result);
  14011. });
  14012. }
  14013. };
  14014. const onChange = (event) => {
  14015. const {
  14016. files
  14017. } = event.target;
  14018. if (props.disabled || !files || !files.length) {
  14019. return;
  14020. }
  14021. const file = files.length === 1 ? files[0] : [].slice.call(files);
  14022. if (props.beforeRead) {
  14023. const response = props.beforeRead(file, getDetail());
  14024. if (!response) {
  14025. resetInput();
  14026. return;
  14027. }
  14028. if (isPromise(response)) {
  14029. response.then((data) => {
  14030. if (data) {
  14031. readFile(data);
  14032. } else {
  14033. readFile(file);
  14034. }
  14035. }).catch(resetInput);
  14036. return;
  14037. }
  14038. }
  14039. readFile(file);
  14040. };
  14041. let imagePreview;
  14042. const onClosePreview = () => emit("closePreview");
  14043. const previewImage = (item) => {
  14044. if (props.previewFullImage) {
  14045. const imageFiles = props.modelValue.filter(isImageFile);
  14046. const images = imageFiles.map((item2) => {
  14047. if (item2.file && !item2.url && item2.status !== "failed") {
  14048. item2.url = URL.createObjectURL(item2.file);
  14049. urls.push(item2.url);
  14050. }
  14051. return item2.url;
  14052. }).filter(Boolean);
  14053. imagePreview = showImagePreview(extend({
  14054. images,
  14055. startPosition: imageFiles.indexOf(item),
  14056. onClose: onClosePreview
  14057. }, props.previewOptions));
  14058. }
  14059. };
  14060. const closeImagePreview = () => {
  14061. if (imagePreview) {
  14062. imagePreview.close();
  14063. }
  14064. };
  14065. const deleteFile = (item, index) => {
  14066. const fileList = props.modelValue.slice(0);
  14067. fileList.splice(index, 1);
  14068. emit("update:modelValue", fileList);
  14069. emit("delete", item, getDetail(index));
  14070. };
  14071. const renderPreviewItem = (item, index) => {
  14072. const needPickData = ["imageFit", "deletable", "previewSize", "beforeDelete"];
  14073. const previewData = extend(pick(props, needPickData), pick(item, needPickData, true));
  14074. return createVNode(stdin_default$5, mergeProps({
  14075. "item": item,
  14076. "index": index,
  14077. "onClick": () => emit("clickPreview", item, getDetail(index)),
  14078. "onDelete": () => deleteFile(item, index),
  14079. "onPreview": () => previewImage(item)
  14080. }, pick(props, ["name", "lazyLoad"]), previewData), pick(slots, ["preview-cover", "preview-delete"]));
  14081. };
  14082. const renderPreviewList = () => {
  14083. if (props.previewImage) {
  14084. return props.modelValue.map(renderPreviewItem);
  14085. }
  14086. };
  14087. const onClickUpload = (event) => emit("clickUpload", event);
  14088. const renderUpload = () => {
  14089. if (props.modelValue.length >= props.maxCount) {
  14090. return;
  14091. }
  14092. const Input = props.readonly ? null : createVNode("input", {
  14093. "ref": inputRef,
  14094. "type": "file",
  14095. "class": bem("input"),
  14096. "accept": props.accept,
  14097. "capture": props.capture,
  14098. "multiple": props.multiple,
  14099. "disabled": props.disabled,
  14100. "onChange": onChange
  14101. }, null);
  14102. if (slots.default) {
  14103. return createVNode("div", {
  14104. "class": bem("input-wrapper"),
  14105. "onClick": onClickUpload
  14106. }, [slots.default(), Input]);
  14107. }
  14108. return withDirectives(createVNode("div", {
  14109. "class": bem("upload", {
  14110. readonly: props.readonly
  14111. }),
  14112. "style": getSizeStyle(props.previewSize),
  14113. "onClick": onClickUpload
  14114. }, [createVNode(Icon, {
  14115. "name": props.uploadIcon,
  14116. "class": bem("upload-icon")
  14117. }, null), props.uploadText && createVNode("span", {
  14118. "class": bem("upload-text")
  14119. }, [props.uploadText]), Input]), [[vShow, props.showUpload]]);
  14120. };
  14121. const chooseFile = () => {
  14122. if (inputRef.value && !props.disabled) {
  14123. inputRef.value.click();
  14124. }
  14125. };
  14126. onBeforeUnmount(() => {
  14127. urls.forEach((url) => URL.revokeObjectURL(url));
  14128. });
  14129. useExpose({
  14130. chooseFile,
  14131. closeImagePreview
  14132. });
  14133. useCustomFieldValue(() => props.modelValue);
  14134. return () => createVNode("div", {
  14135. "class": bem()
  14136. }, [createVNode("div", {
  14137. "class": bem("wrapper", {
  14138. disabled: props.disabled
  14139. })
  14140. }, [renderPreviewList(), renderUpload()])]);
  14141. }
  14142. });
  14143. const Uploader = withInstall(stdin_default$4);
  14144. class ReactiveListener {
  14145. constructor({
  14146. el,
  14147. src,
  14148. error,
  14149. loading,
  14150. bindType,
  14151. $parent,
  14152. options,
  14153. cors,
  14154. elRenderer,
  14155. imageCache
  14156. }) {
  14157. this.el = el;
  14158. this.src = src;
  14159. this.error = error;
  14160. this.loading = loading;
  14161. this.bindType = bindType;
  14162. this.attempt = 0;
  14163. this.cors = cors;
  14164. this.naturalHeight = 0;
  14165. this.naturalWidth = 0;
  14166. this.options = options;
  14167. this.$parent = $parent;
  14168. this.elRenderer = elRenderer;
  14169. this.imageCache = imageCache;
  14170. this.performanceData = {
  14171. loadStart: 0,
  14172. loadEnd: 0
  14173. };
  14174. this.filter();
  14175. this.initState();
  14176. this.render("loading", false);
  14177. }
  14178. initState() {
  14179. if ("dataset" in this.el) {
  14180. this.el.dataset.src = this.src;
  14181. } else {
  14182. this.el.setAttribute("data-src", this.src);
  14183. }
  14184. this.state = {
  14185. loading: false,
  14186. error: false,
  14187. loaded: false,
  14188. rendered: false
  14189. };
  14190. }
  14191. record(event) {
  14192. this.performanceData[event] = Date.now();
  14193. }
  14194. update({ src, loading, error }) {
  14195. const oldSrc = this.src;
  14196. this.src = src;
  14197. this.loading = loading;
  14198. this.error = error;
  14199. this.filter();
  14200. if (oldSrc !== this.src) {
  14201. this.attempt = 0;
  14202. this.initState();
  14203. }
  14204. }
  14205. checkInView() {
  14206. const rect = useRect(this.el);
  14207. return rect.top < window.innerHeight * this.options.preLoad && rect.bottom > this.options.preLoadTop && rect.left < window.innerWidth * this.options.preLoad && rect.right > 0;
  14208. }
  14209. filter() {
  14210. Object.keys(this.options.filter).forEach((key) => {
  14211. this.options.filter[key](this, this.options);
  14212. });
  14213. }
  14214. renderLoading(cb) {
  14215. this.state.loading = true;
  14216. loadImageAsync(
  14217. {
  14218. src: this.loading,
  14219. cors: this.cors
  14220. },
  14221. () => {
  14222. this.render("loading", false);
  14223. this.state.loading = false;
  14224. cb();
  14225. },
  14226. () => {
  14227. cb();
  14228. this.state.loading = false;
  14229. if (process.env.NODE_ENV !== "production" && !this.options.silent)
  14230. console.warn(
  14231. `[@vant/lazyload] load failed with loading image(${this.loading})`
  14232. );
  14233. }
  14234. );
  14235. }
  14236. load(onFinish = noop) {
  14237. if (this.attempt > this.options.attempt - 1 && this.state.error) {
  14238. if (process.env.NODE_ENV !== "production" && !this.options.silent) {
  14239. console.log(
  14240. `[@vant/lazyload] ${this.src} tried too more than ${this.options.attempt} times`
  14241. );
  14242. }
  14243. onFinish();
  14244. return;
  14245. }
  14246. if (this.state.rendered && this.state.loaded)
  14247. return;
  14248. if (this.imageCache.has(this.src)) {
  14249. this.state.loaded = true;
  14250. this.render("loaded", true);
  14251. this.state.rendered = true;
  14252. return onFinish();
  14253. }
  14254. this.renderLoading(() => {
  14255. var _a, _b;
  14256. this.attempt++;
  14257. (_b = (_a = this.options.adapter).beforeLoad) == null ? void 0 : _b.call(_a, this, this.options);
  14258. this.record("loadStart");
  14259. loadImageAsync(
  14260. {
  14261. src: this.src,
  14262. cors: this.cors
  14263. },
  14264. (data) => {
  14265. this.naturalHeight = data.naturalHeight;
  14266. this.naturalWidth = data.naturalWidth;
  14267. this.state.loaded = true;
  14268. this.state.error = false;
  14269. this.record("loadEnd");
  14270. this.render("loaded", false);
  14271. this.state.rendered = true;
  14272. this.imageCache.add(this.src);
  14273. onFinish();
  14274. },
  14275. (err) => {
  14276. !this.options.silent && console.error(err);
  14277. this.state.error = true;
  14278. this.state.loaded = false;
  14279. this.render("error", false);
  14280. }
  14281. );
  14282. });
  14283. }
  14284. render(state, cache) {
  14285. this.elRenderer(this, state, cache);
  14286. }
  14287. performance() {
  14288. let state = "loading";
  14289. let time = 0;
  14290. if (this.state.loaded) {
  14291. state = "loaded";
  14292. time = (this.performanceData.loadEnd - this.performanceData.loadStart) / 1e3;
  14293. }
  14294. if (this.state.error)
  14295. state = "error";
  14296. return {
  14297. src: this.src,
  14298. state,
  14299. time
  14300. };
  14301. }
  14302. $destroy() {
  14303. this.el = null;
  14304. this.src = null;
  14305. this.error = null;
  14306. this.loading = null;
  14307. this.bindType = null;
  14308. this.attempt = 0;
  14309. }
  14310. }
  14311. const DEFAULT_URL = "data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7";
  14312. const DEFAULT_EVENTS = [
  14313. "scroll",
  14314. "wheel",
  14315. "mousewheel",
  14316. "resize",
  14317. "animationend",
  14318. "transitionend",
  14319. "touchmove"
  14320. ];
  14321. const DEFAULT_OBSERVER_OPTIONS = {
  14322. rootMargin: "0px",
  14323. threshold: 0
  14324. };
  14325. function stdin_default$3() {
  14326. return class Lazy {
  14327. constructor({
  14328. preLoad,
  14329. error,
  14330. throttleWait,
  14331. preLoadTop,
  14332. dispatchEvent,
  14333. loading,
  14334. attempt,
  14335. silent = true,
  14336. scale,
  14337. listenEvents,
  14338. filter,
  14339. adapter,
  14340. observer,
  14341. observerOptions
  14342. }) {
  14343. this.mode = modeType.event;
  14344. this.listeners = [];
  14345. this.targetIndex = 0;
  14346. this.targets = [];
  14347. this.options = {
  14348. silent,
  14349. dispatchEvent: !!dispatchEvent,
  14350. throttleWait: throttleWait || 200,
  14351. preLoad: preLoad || 1.3,
  14352. preLoadTop: preLoadTop || 0,
  14353. error: error || DEFAULT_URL,
  14354. loading: loading || DEFAULT_URL,
  14355. attempt: attempt || 3,
  14356. scale: scale || getDPR(scale),
  14357. ListenEvents: listenEvents || DEFAULT_EVENTS,
  14358. supportWebp: supportWebp(),
  14359. filter: filter || {},
  14360. adapter: adapter || {},
  14361. observer: !!observer,
  14362. observerOptions: observerOptions || DEFAULT_OBSERVER_OPTIONS
  14363. };
  14364. this.initEvent();
  14365. this.imageCache = new ImageCache({ max: 200 });
  14366. this.lazyLoadHandler = throttle(
  14367. this.lazyLoadHandler.bind(this),
  14368. this.options.throttleWait
  14369. );
  14370. this.setMode(this.options.observer ? modeType.observer : modeType.event);
  14371. }
  14372. config(options = {}) {
  14373. Object.assign(this.options, options);
  14374. }
  14375. performance() {
  14376. return this.listeners.map((item) => item.performance());
  14377. }
  14378. addLazyBox(vm) {
  14379. this.listeners.push(vm);
  14380. if (inBrowser$1) {
  14381. this.addListenerTarget(window);
  14382. this.observer && this.observer.observe(vm.el);
  14383. if (vm.$el && vm.$el.parentNode) {
  14384. this.addListenerTarget(vm.$el.parentNode);
  14385. }
  14386. }
  14387. }
  14388. add(el, binding, vnode) {
  14389. if (this.listeners.some((item) => item.el === el)) {
  14390. this.update(el, binding);
  14391. return nextTick(this.lazyLoadHandler);
  14392. }
  14393. const value = this.valueFormatter(binding.value);
  14394. let { src } = value;
  14395. nextTick(() => {
  14396. src = getBestSelectionFromSrcset(el, this.options.scale) || src;
  14397. this.observer && this.observer.observe(el);
  14398. const container = Object.keys(binding.modifiers)[0];
  14399. let $parent;
  14400. if (container) {
  14401. $parent = vnode.context.$refs[container];
  14402. $parent = $parent ? $parent.$el || $parent : document.getElementById(container);
  14403. }
  14404. if (!$parent) {
  14405. $parent = getScrollParent(el);
  14406. }
  14407. const newListener = new ReactiveListener({
  14408. bindType: binding.arg,
  14409. $parent,
  14410. el,
  14411. src,
  14412. loading: value.loading,
  14413. error: value.error,
  14414. cors: value.cors,
  14415. elRenderer: this.elRenderer.bind(this),
  14416. options: this.options,
  14417. imageCache: this.imageCache
  14418. });
  14419. this.listeners.push(newListener);
  14420. if (inBrowser$1) {
  14421. this.addListenerTarget(window);
  14422. this.addListenerTarget($parent);
  14423. }
  14424. this.lazyLoadHandler();
  14425. nextTick(() => this.lazyLoadHandler());
  14426. });
  14427. }
  14428. update(el, binding, vnode) {
  14429. const value = this.valueFormatter(binding.value);
  14430. let { src } = value;
  14431. src = getBestSelectionFromSrcset(el, this.options.scale) || src;
  14432. const exist = this.listeners.find((item) => item.el === el);
  14433. if (!exist) {
  14434. this.add(el, binding, vnode);
  14435. } else {
  14436. exist.update({
  14437. src,
  14438. error: value.error,
  14439. loading: value.loading
  14440. });
  14441. }
  14442. if (this.observer) {
  14443. this.observer.unobserve(el);
  14444. this.observer.observe(el);
  14445. }
  14446. this.lazyLoadHandler();
  14447. nextTick(() => this.lazyLoadHandler());
  14448. }
  14449. remove(el) {
  14450. if (!el)
  14451. return;
  14452. this.observer && this.observer.unobserve(el);
  14453. const existItem = this.listeners.find((item) => item.el === el);
  14454. if (existItem) {
  14455. this.removeListenerTarget(existItem.$parent);
  14456. this.removeListenerTarget(window);
  14457. remove(this.listeners, existItem);
  14458. existItem.$destroy();
  14459. }
  14460. }
  14461. removeComponent(vm) {
  14462. if (!vm)
  14463. return;
  14464. remove(this.listeners, vm);
  14465. this.observer && this.observer.unobserve(vm.el);
  14466. if (vm.$parent && vm.$el.parentNode) {
  14467. this.removeListenerTarget(vm.$el.parentNode);
  14468. }
  14469. this.removeListenerTarget(window);
  14470. }
  14471. setMode(mode) {
  14472. if (!hasIntersectionObserver && mode === modeType.observer) {
  14473. mode = modeType.event;
  14474. }
  14475. this.mode = mode;
  14476. if (mode === modeType.event) {
  14477. if (this.observer) {
  14478. this.listeners.forEach((listener) => {
  14479. this.observer.unobserve(listener.el);
  14480. });
  14481. this.observer = null;
  14482. }
  14483. this.targets.forEach((target) => {
  14484. this.initListen(target.el, true);
  14485. });
  14486. } else {
  14487. this.targets.forEach((target) => {
  14488. this.initListen(target.el, false);
  14489. });
  14490. this.initIntersectionObserver();
  14491. }
  14492. }
  14493. addListenerTarget(el) {
  14494. if (!el)
  14495. return;
  14496. let target = this.targets.find((target2) => target2.el === el);
  14497. if (!target) {
  14498. target = {
  14499. el,
  14500. id: ++this.targetIndex,
  14501. childrenCount: 1,
  14502. listened: true
  14503. };
  14504. this.mode === modeType.event && this.initListen(target.el, true);
  14505. this.targets.push(target);
  14506. } else {
  14507. target.childrenCount++;
  14508. }
  14509. return this.targetIndex;
  14510. }
  14511. removeListenerTarget(el) {
  14512. this.targets.forEach((target, index) => {
  14513. if (target.el === el) {
  14514. target.childrenCount--;
  14515. if (!target.childrenCount) {
  14516. this.initListen(target.el, false);
  14517. this.targets.splice(index, 1);
  14518. target = null;
  14519. }
  14520. }
  14521. });
  14522. }
  14523. initListen(el, start) {
  14524. this.options.ListenEvents.forEach(
  14525. (evt) => (start ? on : off)(el, evt, this.lazyLoadHandler)
  14526. );
  14527. }
  14528. initEvent() {
  14529. this.Event = {
  14530. listeners: {
  14531. loading: [],
  14532. loaded: [],
  14533. error: []
  14534. }
  14535. };
  14536. this.$on = (event, func) => {
  14537. if (!this.Event.listeners[event])
  14538. this.Event.listeners[event] = [];
  14539. this.Event.listeners[event].push(func);
  14540. };
  14541. this.$once = (event, func) => {
  14542. const on2 = (...args) => {
  14543. this.$off(event, on2);
  14544. func.apply(this, args);
  14545. };
  14546. this.$on(event, on2);
  14547. };
  14548. this.$off = (event, func) => {
  14549. if (!func) {
  14550. if (!this.Event.listeners[event])
  14551. return;
  14552. this.Event.listeners[event].length = 0;
  14553. return;
  14554. }
  14555. remove(this.Event.listeners[event], func);
  14556. };
  14557. this.$emit = (event, context, inCache) => {
  14558. if (!this.Event.listeners[event])
  14559. return;
  14560. this.Event.listeners[event].forEach((func) => func(context, inCache));
  14561. };
  14562. }
  14563. lazyLoadHandler() {
  14564. const freeList = [];
  14565. this.listeners.forEach((listener) => {
  14566. if (!listener.el || !listener.el.parentNode) {
  14567. freeList.push(listener);
  14568. }
  14569. const catIn = listener.checkInView();
  14570. if (!catIn)
  14571. return;
  14572. listener.load();
  14573. });
  14574. freeList.forEach((item) => {
  14575. remove(this.listeners, item);
  14576. item.$destroy();
  14577. });
  14578. }
  14579. initIntersectionObserver() {
  14580. if (!hasIntersectionObserver) {
  14581. return;
  14582. }
  14583. this.observer = new IntersectionObserver(
  14584. this.observerHandler.bind(this),
  14585. this.options.observerOptions
  14586. );
  14587. if (this.listeners.length) {
  14588. this.listeners.forEach((listener) => {
  14589. this.observer.observe(listener.el);
  14590. });
  14591. }
  14592. }
  14593. observerHandler(entries) {
  14594. entries.forEach((entry) => {
  14595. if (entry.isIntersecting) {
  14596. this.listeners.forEach((listener) => {
  14597. if (listener.el === entry.target) {
  14598. if (listener.state.loaded)
  14599. return this.observer.unobserve(listener.el);
  14600. listener.load();
  14601. }
  14602. });
  14603. }
  14604. });
  14605. }
  14606. elRenderer(listener, state, cache) {
  14607. if (!listener.el)
  14608. return;
  14609. const { el, bindType } = listener;
  14610. let src;
  14611. switch (state) {
  14612. case "loading":
  14613. src = listener.loading;
  14614. break;
  14615. case "error":
  14616. src = listener.error;
  14617. break;
  14618. default:
  14619. ({ src } = listener);
  14620. break;
  14621. }
  14622. if (bindType) {
  14623. el.style[bindType] = 'url("' + src + '")';
  14624. } else if (el.getAttribute("src") !== src) {
  14625. el.setAttribute("src", src);
  14626. }
  14627. el.setAttribute("lazy", state);
  14628. this.$emit(state, listener, cache);
  14629. this.options.adapter[state] && this.options.adapter[state](listener, this.options);
  14630. if (this.options.dispatchEvent) {
  14631. const event = new CustomEvent(state, {
  14632. detail: listener
  14633. });
  14634. el.dispatchEvent(event);
  14635. }
  14636. }
  14637. valueFormatter(value) {
  14638. let src = value;
  14639. let { loading, error } = this.options;
  14640. if (isObject(value)) {
  14641. if (process.env.NODE_ENV !== "production" && !value.src && !this.options.silent) {
  14642. console.error("[@vant/lazyload] miss src with " + value);
  14643. }
  14644. ({ src } = value);
  14645. loading = value.loading || this.options.loading;
  14646. error = value.error || this.options.error;
  14647. }
  14648. return {
  14649. src,
  14650. loading,
  14651. error
  14652. };
  14653. }
  14654. };
  14655. }
  14656. var stdin_default$2 = (lazy) => ({
  14657. props: {
  14658. tag: {
  14659. type: String,
  14660. default: "div"
  14661. }
  14662. },
  14663. emits: ["show"],
  14664. render() {
  14665. return h(
  14666. this.tag,
  14667. this.show && this.$slots.default ? this.$slots.default() : null
  14668. );
  14669. },
  14670. data() {
  14671. return {
  14672. el: null,
  14673. state: {
  14674. loaded: false
  14675. },
  14676. show: false
  14677. };
  14678. },
  14679. mounted() {
  14680. this.el = this.$el;
  14681. lazy.addLazyBox(this);
  14682. lazy.lazyLoadHandler();
  14683. },
  14684. beforeUnmount() {
  14685. lazy.removeComponent(this);
  14686. },
  14687. methods: {
  14688. checkInView() {
  14689. const rect = useRect(this.$el);
  14690. return inBrowser$1 && rect.top < window.innerHeight * lazy.options.preLoad && rect.bottom > 0 && rect.left < window.innerWidth * lazy.options.preLoad && rect.right > 0;
  14691. },
  14692. load() {
  14693. this.show = true;
  14694. this.state.loaded = true;
  14695. this.$emit("show", this);
  14696. },
  14697. destroy() {
  14698. return this.$destroy;
  14699. }
  14700. }
  14701. });
  14702. const defaultOptions = {
  14703. selector: "img"
  14704. };
  14705. class LazyContainer {
  14706. constructor({ el, binding, vnode, lazy }) {
  14707. this.el = null;
  14708. this.vnode = vnode;
  14709. this.binding = binding;
  14710. this.options = {};
  14711. this.lazy = lazy;
  14712. this.queue = [];
  14713. this.update({ el, binding });
  14714. }
  14715. update({ el, binding }) {
  14716. this.el = el;
  14717. this.options = Object.assign({}, defaultOptions, binding.value);
  14718. const imgs = this.getImgs();
  14719. imgs.forEach((el2) => {
  14720. this.lazy.add(
  14721. el2,
  14722. Object.assign({}, this.binding, {
  14723. value: {
  14724. src: "dataset" in el2 ? el2.dataset.src : el2.getAttribute("data-src"),
  14725. error: ("dataset" in el2 ? el2.dataset.error : el2.getAttribute("data-error")) || this.options.error,
  14726. loading: ("dataset" in el2 ? el2.dataset.loading : el2.getAttribute("data-loading")) || this.options.loading
  14727. }
  14728. }),
  14729. this.vnode
  14730. );
  14731. });
  14732. }
  14733. getImgs() {
  14734. return Array.from(this.el.querySelectorAll(this.options.selector));
  14735. }
  14736. clear() {
  14737. const imgs = this.getImgs();
  14738. imgs.forEach((el) => this.lazy.remove(el));
  14739. this.vnode = null;
  14740. this.binding = null;
  14741. this.lazy = null;
  14742. }
  14743. }
  14744. class LazyContainerManager {
  14745. constructor({ lazy }) {
  14746. this.lazy = lazy;
  14747. this.queue = [];
  14748. }
  14749. bind(el, binding, vnode) {
  14750. const container = new LazyContainer({
  14751. el,
  14752. binding,
  14753. vnode,
  14754. lazy: this.lazy
  14755. });
  14756. this.queue.push(container);
  14757. }
  14758. update(el, binding, vnode) {
  14759. const container = this.queue.find((item) => item.el === el);
  14760. if (!container)
  14761. return;
  14762. container.update({ el, binding, vnode });
  14763. }
  14764. unbind(el) {
  14765. const container = this.queue.find((item) => item.el === el);
  14766. if (!container)
  14767. return;
  14768. container.clear();
  14769. remove(this.queue, container);
  14770. }
  14771. }
  14772. var stdin_default$1 = (lazyManager) => ({
  14773. props: {
  14774. src: [String, Object],
  14775. tag: {
  14776. type: String,
  14777. default: "img"
  14778. }
  14779. },
  14780. render() {
  14781. var _a, _b;
  14782. return h(
  14783. this.tag,
  14784. {
  14785. src: this.renderSrc
  14786. },
  14787. (_b = (_a = this.$slots).default) == null ? void 0 : _b.call(_a)
  14788. );
  14789. },
  14790. data() {
  14791. return {
  14792. el: null,
  14793. options: {
  14794. src: "",
  14795. error: "",
  14796. loading: "",
  14797. attempt: lazyManager.options.attempt
  14798. },
  14799. state: {
  14800. loaded: false,
  14801. error: false,
  14802. attempt: 0
  14803. },
  14804. renderSrc: ""
  14805. };
  14806. },
  14807. watch: {
  14808. src() {
  14809. this.init();
  14810. lazyManager.addLazyBox(this);
  14811. lazyManager.lazyLoadHandler();
  14812. }
  14813. },
  14814. created() {
  14815. this.init();
  14816. this.renderSrc = this.options.loading;
  14817. },
  14818. mounted() {
  14819. this.el = this.$el;
  14820. lazyManager.addLazyBox(this);
  14821. lazyManager.lazyLoadHandler();
  14822. },
  14823. beforeUnmount() {
  14824. lazyManager.removeComponent(this);
  14825. },
  14826. methods: {
  14827. init() {
  14828. const { src, loading, error } = lazyManager.valueFormatter(this.src);
  14829. this.state.loaded = false;
  14830. this.options.src = src;
  14831. this.options.error = error;
  14832. this.options.loading = loading;
  14833. this.renderSrc = this.options.loading;
  14834. },
  14835. checkInView() {
  14836. const rect = useRect(this.$el);
  14837. return rect.top < window.innerHeight * lazyManager.options.preLoad && rect.bottom > 0 && rect.left < window.innerWidth * lazyManager.options.preLoad && rect.right > 0;
  14838. },
  14839. load(onFinish = noop) {
  14840. if (this.state.attempt > this.options.attempt - 1 && this.state.error) {
  14841. if (process.env.NODE_ENV !== "production" && !lazyManager.options.silent) {
  14842. console.log(
  14843. `[@vant/lazyload] ${this.options.src} tried too more than ${this.options.attempt} times`
  14844. );
  14845. }
  14846. onFinish();
  14847. return;
  14848. }
  14849. const { src } = this.options;
  14850. loadImageAsync(
  14851. { src },
  14852. ({ src: src2 }) => {
  14853. this.renderSrc = src2;
  14854. this.state.loaded = true;
  14855. },
  14856. () => {
  14857. this.state.attempt++;
  14858. this.renderSrc = this.options.error;
  14859. this.state.error = true;
  14860. }
  14861. );
  14862. }
  14863. }
  14864. });
  14865. const Lazyload = {
  14866. install(app, options = {}) {
  14867. const LazyClass = stdin_default$3();
  14868. const lazy = new LazyClass(options);
  14869. const lazyContainer = new LazyContainerManager({ lazy });
  14870. app.config.globalProperties.$Lazyload = lazy;
  14871. if (options.lazyComponent) {
  14872. app.component("LazyComponent", stdin_default$2(lazy));
  14873. }
  14874. if (options.lazyImage) {
  14875. app.component("LazyImage", stdin_default$1(lazy));
  14876. }
  14877. app.directive("lazy", {
  14878. beforeMount: lazy.add.bind(lazy),
  14879. updated: lazy.update.bind(lazy),
  14880. unmounted: lazy.remove.bind(lazy)
  14881. });
  14882. app.directive("lazy-container", {
  14883. beforeMount: lazyContainer.bind.bind(lazyContainer),
  14884. updated: lazyContainer.update.bind(lazyContainer),
  14885. unmounted: lazyContainer.unbind.bind(lazyContainer)
  14886. });
  14887. }
  14888. };
  14889. const version = "4.0.4";
  14890. function install(app) {
  14891. const components = [
  14892. ActionBar,
  14893. ActionBarButton,
  14894. ActionBarIcon,
  14895. ActionSheet,
  14896. AddressEdit,
  14897. AddressList,
  14898. Area,
  14899. BackTop,
  14900. Badge,
  14901. Button,
  14902. Calendar,
  14903. Card,
  14904. Cascader,
  14905. Cell,
  14906. CellGroup,
  14907. Checkbox,
  14908. CheckboxGroup,
  14909. Circle,
  14910. Col,
  14911. Collapse,
  14912. CollapseItem,
  14913. ConfigProvider,
  14914. ContactCard,
  14915. ContactEdit,
  14916. ContactList,
  14917. CountDown,
  14918. Coupon,
  14919. CouponCell,
  14920. CouponList,
  14921. DatePicker,
  14922. Dialog,
  14923. Divider,
  14924. DropdownItem,
  14925. DropdownMenu,
  14926. Empty,
  14927. Field,
  14928. Form,
  14929. Grid,
  14930. GridItem,
  14931. Icon,
  14932. Image$1,
  14933. ImagePreview,
  14934. IndexAnchor,
  14935. IndexBar,
  14936. List,
  14937. Loading,
  14938. Locale,
  14939. NavBar,
  14940. NoticeBar,
  14941. Notify,
  14942. NumberKeyboard,
  14943. Overlay,
  14944. Pagination,
  14945. PasswordInput,
  14946. Picker,
  14947. PickerGroup,
  14948. Popover,
  14949. Popup,
  14950. Progress,
  14951. PullRefresh,
  14952. Radio,
  14953. RadioGroup,
  14954. Rate,
  14955. Row,
  14956. Search,
  14957. ShareSheet,
  14958. Sidebar,
  14959. SidebarItem,
  14960. Skeleton,
  14961. Slider,
  14962. Space,
  14963. Step,
  14964. Stepper,
  14965. Steps,
  14966. Sticky,
  14967. SubmitBar,
  14968. Swipe,
  14969. SwipeCell,
  14970. SwipeItem,
  14971. Switch,
  14972. Tab,
  14973. Tabbar,
  14974. TabbarItem,
  14975. Tabs,
  14976. Tag,
  14977. TimePicker,
  14978. Toast,
  14979. TreeSelect,
  14980. Uploader
  14981. ];
  14982. components.forEach((item) => {
  14983. if (item.install) {
  14984. app.use(item);
  14985. } else if (item.name) {
  14986. app.component(item.name, item);
  14987. }
  14988. });
  14989. }
  14990. var stdin_default = {
  14991. install,
  14992. version
  14993. };
  14994. export {
  14995. ActionBar,
  14996. ActionBarButton,
  14997. ActionBarIcon,
  14998. ActionSheet,
  14999. AddressEdit,
  15000. AddressList,
  15001. Area,
  15002. BackTop,
  15003. Badge,
  15004. Button,
  15005. Calendar,
  15006. Card,
  15007. Cascader,
  15008. Cell,
  15009. CellGroup,
  15010. Checkbox,
  15011. CheckboxGroup,
  15012. Circle,
  15013. Col,
  15014. Collapse,
  15015. CollapseItem,
  15016. ConfigProvider,
  15017. ContactCard,
  15018. ContactEdit,
  15019. ContactList,
  15020. CountDown,
  15021. Coupon,
  15022. CouponCell,
  15023. CouponList,
  15024. DatePicker,
  15025. Dialog,
  15026. Divider,
  15027. DropdownItem,
  15028. DropdownMenu,
  15029. Empty,
  15030. Field,
  15031. Form,
  15032. Grid,
  15033. GridItem,
  15034. Icon,
  15035. Image$1 as Image,
  15036. ImagePreview,
  15037. IndexAnchor,
  15038. IndexBar,
  15039. Lazyload,
  15040. List,
  15041. Loading,
  15042. Locale,
  15043. NavBar,
  15044. NoticeBar,
  15045. Notify,
  15046. NumberKeyboard,
  15047. Overlay,
  15048. Pagination,
  15049. PasswordInput,
  15050. Picker,
  15051. PickerGroup,
  15052. Popover,
  15053. Popup,
  15054. Progress,
  15055. PullRefresh,
  15056. Radio,
  15057. RadioGroup,
  15058. Rate,
  15059. Row,
  15060. Search,
  15061. ShareSheet,
  15062. Sidebar,
  15063. SidebarItem,
  15064. Skeleton,
  15065. SkeletonAvatar,
  15066. SkeletonImage,
  15067. SkeletonParagraph,
  15068. SkeletonTitle,
  15069. Slider,
  15070. Space,
  15071. Step,
  15072. Stepper,
  15073. Steps,
  15074. Sticky,
  15075. SubmitBar,
  15076. Swipe,
  15077. SwipeCell,
  15078. SwipeItem,
  15079. Switch,
  15080. Tab,
  15081. Tabbar,
  15082. TabbarItem,
  15083. Tabs,
  15084. Tag,
  15085. TimePicker,
  15086. Toast,
  15087. TreeSelect,
  15088. Uploader,
  15089. actionBarButtonProps,
  15090. actionBarIconProps,
  15091. actionBarProps,
  15092. actionSheetProps,
  15093. addressEditProps,
  15094. addressListProps,
  15095. allowMultipleToast,
  15096. areaProps,
  15097. backTopProps,
  15098. badgeProps,
  15099. buttonProps,
  15100. calendarProps,
  15101. cardProps,
  15102. cascaderProps,
  15103. cellGroupProps,
  15104. cellProps,
  15105. checkboxGroupProps,
  15106. checkboxProps,
  15107. circleProps,
  15108. closeDialog,
  15109. closeNotify,
  15110. closeToast,
  15111. colProps,
  15112. collapseItemProps,
  15113. collapseProps,
  15114. configProviderProps,
  15115. contactCardProps,
  15116. contactEditProps,
  15117. contactListProps,
  15118. countDownProps,
  15119. couponCellProps,
  15120. couponListProps,
  15121. datePickerProps,
  15122. stdin_default as default,
  15123. dialogProps,
  15124. dividerProps,
  15125. dropdownItemProps,
  15126. dropdownMenuProps,
  15127. emptyProps,
  15128. fieldProps,
  15129. formProps,
  15130. gridItemProps,
  15131. gridProps,
  15132. iconProps,
  15133. imagePreviewProps,
  15134. imageProps,
  15135. indexAnchorProps,
  15136. indexBarProps,
  15137. install,
  15138. listProps,
  15139. loadingProps,
  15140. navBarProps,
  15141. noticeBarProps,
  15142. notifyProps,
  15143. numberKeyboardProps,
  15144. overlayProps,
  15145. paginationProps,
  15146. passwordInputProps,
  15147. pickerGroupProps,
  15148. pickerProps,
  15149. popoverProps,
  15150. popupProps$2 as popupProps,
  15151. progressProps,
  15152. pullRefreshProps,
  15153. radioGroupProps,
  15154. radioProps,
  15155. rateProps,
  15156. resetDialogDefaultOptions,
  15157. resetNotifyDefaultOptions,
  15158. resetToastDefaultOptions,
  15159. rowProps,
  15160. searchProps,
  15161. setDialogDefaultOptions,
  15162. setNotifyDefaultOptions,
  15163. setToastDefaultOptions,
  15164. shareSheetProps,
  15165. showConfirmDialog,
  15166. showDialog,
  15167. showFailToast,
  15168. showImagePreview,
  15169. showLoadingToast,
  15170. showNotify,
  15171. showSuccessToast,
  15172. showToast,
  15173. sidebarItemProps,
  15174. sidebarProps,
  15175. skeletonAvatarProps,
  15176. skeletonImageProps,
  15177. skeletonParagraphProps,
  15178. skeletonProps,
  15179. skeletonTitleProps,
  15180. sliderProps,
  15181. spaceProps,
  15182. stepperProps,
  15183. stepsProps,
  15184. stickyProps,
  15185. submitBarProps,
  15186. swipeCellProps,
  15187. swipeProps,
  15188. switchProps,
  15189. tabProps,
  15190. tabbarItemProps,
  15191. tabbarProps,
  15192. tabsProps,
  15193. tagProps,
  15194. timePickerProps,
  15195. toastProps,
  15196. treeSelectProps,
  15197. uploaderProps,
  15198. version
  15199. };