1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161 |
- import { useWindowSize, useRect, useChildren, useParent, onMountedOrActivated, getScrollParent, useEventListener, CUSTOM_FIELD_INJECTION_KEY, useCustomFieldValue, useToggle, raf, useScrollParent, usePageVisibility, doubleRaf, cancelRaf, useCountDown, useClickAway, inBrowser as inBrowser$1 } from "@vant/use";
- import { unref, ref, reactive, inject, watch, onMounted, nextTick, createVNode, defineComponent, getCurrentInstance, computed, provide, watchEffect, mergeProps, onDeactivated, onBeforeUnmount, Transition, withDirectives, vShow, onActivated, Teleport, Fragment, createTextVNode, createApp, onUnmounted, onBeforeUpdate, resolveDirective, withKeys, onUpdated, h } from "vue";
- import { offsetModifier, createPopper } from "@vant/popperjs";
- const isDef = (val) => val !== void 0 && val !== null;
- const isFunction = (val) => typeof val === "function";
- const isObject = (val) => val !== null && typeof val === "object";
- const isPromise = (val) => isObject(val) && isFunction(val.then) && isFunction(val.catch);
- const isDate = (val) => Object.prototype.toString.call(val) === "[object Date]" && !Number.isNaN(val.getTime());
- function isMobile(value) {
- value = value.replace(/[^-|\d]/g, "");
- return /^((\+86)|(86))?(1)\d{10}$/.test(value) || /^0[0-9-]{10,13}$/.test(value);
- }
- const isNumeric = (val) => typeof val === "number" || /^\d+(\.\d+)?$/.test(val);
- const isIOS$1 = () => inBrowser ? /ios|iphone|ipad|ipod/.test(navigator.userAgent.toLowerCase()) : false;
- function noop() {
- }
- const extend = Object.assign;
- const inBrowser = typeof window !== "undefined";
- function get(object, path) {
- const keys = path.split(".");
- let result = object;
- keys.forEach((key) => {
- var _a;
- result = isObject(result) ? (_a = result[key]) != null ? _a : "" : "";
- });
- return result;
- }
- function pick(obj, keys, ignoreUndefined) {
- return keys.reduce((ret, key) => {
- if (!ignoreUndefined || obj[key] !== void 0) {
- ret[key] = obj[key];
- }
- return ret;
- }, {});
- }
- const toArray = (item) => Array.isArray(item) ? item : [item];
- const unknownProp = null;
- const numericProp = [Number, String];
- const truthProp = {
- type: Boolean,
- default: true
- };
- const makeRequiredProp = (type) => ({
- type,
- required: true
- });
- const makeArrayProp = () => ({
- type: Array,
- default: () => []
- });
- const makeNumberProp = (defaultVal) => ({
- type: Number,
- default: defaultVal
- });
- const makeNumericProp = (defaultVal) => ({
- type: numericProp,
- default: defaultVal
- });
- const makeStringProp = (defaultVal) => ({
- type: String,
- default: defaultVal
- });
- function getScrollTop(el) {
- const top = "scrollTop" in el ? el.scrollTop : el.pageYOffset;
- return Math.max(top, 0);
- }
- function setScrollTop(el, value) {
- if ("scrollTop" in el) {
- el.scrollTop = value;
- } else {
- el.scrollTo(el.scrollX, value);
- }
- }
- function getRootScrollTop() {
- return window.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop || 0;
- }
- function setRootScrollTop(value) {
- setScrollTop(window, value);
- setScrollTop(document.body, value);
- }
- function getElementTop(el, scroller) {
- if (el === window) {
- return 0;
- }
- const scrollTop = scroller ? getScrollTop(scroller) : getRootScrollTop();
- return useRect(el).top + scrollTop;
- }
- const isIOS = isIOS$1();
- function resetScroll() {
- if (isIOS) {
- setRootScrollTop(getRootScrollTop());
- }
- }
- const stopPropagation = (event) => event.stopPropagation();
- function preventDefault(event, isStopPropagation) {
- if (typeof event.cancelable !== "boolean" || event.cancelable) {
- event.preventDefault();
- }
- if (isStopPropagation) {
- stopPropagation(event);
- }
- }
- function isHidden(elementRef) {
- const el = unref(elementRef);
- if (!el) {
- return false;
- }
- const style = window.getComputedStyle(el);
- const hidden = style.display === "none";
- const parentHidden = el.offsetParent === null && style.position !== "fixed";
- return hidden || parentHidden;
- }
- const { width: windowWidth, height: windowHeight } = useWindowSize();
- function addUnit(value) {
- if (isDef(value)) {
- return isNumeric(value) ? `${value}px` : String(value);
- }
- return void 0;
- }
- function getSizeStyle(originSize) {
- if (isDef(originSize)) {
- if (Array.isArray(originSize)) {
- return {
- width: addUnit(originSize[0]),
- height: addUnit(originSize[1])
- };
- }
- const size = addUnit(originSize);
- return {
- width: size,
- height: size
- };
- }
- }
- function getZIndexStyle(zIndex) {
- const style = {};
- if (zIndex !== void 0) {
- style.zIndex = +zIndex;
- }
- return style;
- }
- let rootFontSize;
- function getRootFontSize() {
- if (!rootFontSize) {
- const doc = document.documentElement;
- const fontSize = doc.style.fontSize || window.getComputedStyle(doc).fontSize;
- rootFontSize = parseFloat(fontSize);
- }
- return rootFontSize;
- }
- function convertRem(value) {
- value = value.replace(/rem/g, "");
- return +value * getRootFontSize();
- }
- function convertVw(value) {
- value = value.replace(/vw/g, "");
- return +value * windowWidth.value / 100;
- }
- function convertVh(value) {
- value = value.replace(/vh/g, "");
- return +value * windowHeight.value / 100;
- }
- function unitToPx(value) {
- if (typeof value === "number") {
- return value;
- }
- if (inBrowser) {
- if (value.includes("rem")) {
- return convertRem(value);
- }
- if (value.includes("vw")) {
- return convertVw(value);
- }
- if (value.includes("vh")) {
- return convertVh(value);
- }
- }
- return parseFloat(value);
- }
- const camelizeRE = /-(\w)/g;
- const camelize = (str) => str.replace(camelizeRE, (_, c) => c.toUpperCase());
- const kebabCase = (str) => str.replace(/([A-Z])/g, "-$1").toLowerCase().replace(/^-/, "");
- function padZero(num, targetLength = 2) {
- let str = num + "";
- while (str.length < targetLength) {
- str = "0" + str;
- }
- return str;
- }
- const clamp = (num, min, max) => Math.min(Math.max(num, min), max);
- function trimExtraChar(value, char, regExp) {
- const index = value.indexOf(char);
- if (index === -1) {
- return value;
- }
- if (char === "-" && index !== 0) {
- return value.slice(0, index);
- }
- return value.slice(0, index + 1) + value.slice(index).replace(regExp, "");
- }
- function formatNumber(value, allowDot = true, allowMinus = true) {
- if (allowDot) {
- value = trimExtraChar(value, ".", /\./g);
- } else {
- value = value.split(".")[0];
- }
- if (allowMinus) {
- value = trimExtraChar(value, "-", /-/g);
- } else {
- value = value.replace(/-/, "");
- }
- const regExp = allowDot ? /[^-0-9.]/g : /[^-0-9]/g;
- return value.replace(regExp, "");
- }
- function addNumber(num1, num2) {
- const cardinal = 10 ** 10;
- return Math.round((num1 + num2) * cardinal) / cardinal;
- }
- const { hasOwnProperty } = Object.prototype;
- function assignKey(to, from, key) {
- const val = from[key];
- if (!isDef(val)) {
- return;
- }
- if (!hasOwnProperty.call(to, key) || !isObject(val)) {
- to[key] = val;
- } else {
- to[key] = deepAssign(Object(to[key]), val);
- }
- }
- function deepAssign(to, from) {
- Object.keys(from).forEach((key) => {
- assignKey(to, from, key);
- });
- return to;
- }
- var stdin_default$1E = {
- name: "\u59D3\u540D",
- tel: "\u7535\u8BDD",
- save: "\u4FDD\u5B58",
- confirm: "\u786E\u8BA4",
- cancel: "\u53D6\u6D88",
- delete: "\u5220\u9664",
- loading: "\u52A0\u8F7D\u4E2D...",
- noCoupon: "\u6682\u65E0\u4F18\u60E0\u5238",
- nameEmpty: "\u8BF7\u586B\u5199\u59D3\u540D",
- addContact: "\u6DFB\u52A0\u8054\u7CFB\u4EBA",
- telInvalid: "\u8BF7\u586B\u5199\u6B63\u786E\u7684\u7535\u8BDD",
- vanCalendar: {
- end: "\u7ED3\u675F",
- start: "\u5F00\u59CB",
- title: "\u65E5\u671F\u9009\u62E9",
- weekdays: ["\u65E5", "\u4E00", "\u4E8C", "\u4E09", "\u56DB", "\u4E94", "\u516D"],
- monthTitle: (year, month) => `${year}\u5E74${month}\u6708`,
- rangePrompt: (maxRange) => `\u6700\u591A\u9009\u62E9 ${maxRange} \u5929`
- },
- vanCascader: {
- select: "\u8BF7\u9009\u62E9"
- },
- vanPagination: {
- prev: "\u4E0A\u4E00\u9875",
- next: "\u4E0B\u4E00\u9875"
- },
- vanPullRefresh: {
- pulling: "\u4E0B\u62C9\u5373\u53EF\u5237\u65B0...",
- loosing: "\u91CA\u653E\u5373\u53EF\u5237\u65B0..."
- },
- vanSubmitBar: {
- label: "\u5408\u8BA1:"
- },
- vanCoupon: {
- unlimited: "\u65E0\u95E8\u69DB",
- discount: (discount) => `${discount}\u6298`,
- condition: (condition) => `\u6EE1${condition}\u5143\u53EF\u7528`
- },
- vanCouponCell: {
- title: "\u4F18\u60E0\u5238",
- count: (count) => `${count}\u5F20\u53EF\u7528`
- },
- vanCouponList: {
- exchange: "\u5151\u6362",
- close: "\u4E0D\u4F7F\u7528",
- enable: "\u53EF\u7528",
- disabled: "\u4E0D\u53EF\u7528",
- placeholder: "\u8F93\u5165\u4F18\u60E0\u7801"
- },
- vanAddressEdit: {
- area: "\u5730\u533A",
- postal: "\u90AE\u653F\u7F16\u7801",
- areaEmpty: "\u8BF7\u9009\u62E9\u5730\u533A",
- addressEmpty: "\u8BF7\u586B\u5199\u8BE6\u7EC6\u5730\u5740",
- postalEmpty: "\u90AE\u653F\u7F16\u7801\u4E0D\u6B63\u786E",
- addressDetail: "\u8BE6\u7EC6\u5730\u5740",
- defaultAddress: "\u8BBE\u4E3A\u9ED8\u8BA4\u6536\u8D27\u5730\u5740"
- },
- vanAddressList: {
- add: "\u65B0\u589E\u5730\u5740"
- }
- };
- const lang = ref("zh-CN");
- const messages = reactive({
- "zh-CN": stdin_default$1E
- });
- const Locale = {
- messages() {
- return messages[lang.value];
- },
- use(newLang, newMessages) {
- lang.value = newLang;
- this.add({ [newLang]: newMessages });
- },
- add(newMessages = {}) {
- deepAssign(messages, newMessages);
- }
- };
- var stdin_default$1D = Locale;
- function createTranslate(name2) {
- const prefix = camelize(name2) + ".";
- return (path, ...args) => {
- const messages2 = stdin_default$1D.messages();
- const message = get(messages2, prefix + path) || get(messages2, path);
- return isFunction(message) ? message(...args) : message;
- };
- }
- function genBem(name2, mods) {
- if (!mods) {
- return "";
- }
- if (typeof mods === "string") {
- return ` ${name2}--${mods}`;
- }
- if (Array.isArray(mods)) {
- return mods.reduce(
- (ret, item) => ret + genBem(name2, item),
- ""
- );
- }
- return Object.keys(mods).reduce(
- (ret, key) => ret + (mods[key] ? genBem(name2, key) : ""),
- ""
- );
- }
- function createBEM(name2) {
- return (el, mods) => {
- if (el && typeof el !== "string") {
- mods = el;
- el = "";
- }
- el = el ? `${name2}__${el}` : name2;
- return `${el}${genBem(el, mods)}`;
- };
- }
- function createNamespace(name2) {
- const prefixedName = `van-${name2}`;
- return [
- prefixedName,
- createBEM(prefixedName),
- createTranslate(prefixedName)
- ];
- }
- const BORDER = "van-hairline";
- const BORDER_TOP = `${BORDER}--top`;
- const BORDER_LEFT = `${BORDER}--left`;
- const BORDER_BOTTOM = `${BORDER}--bottom`;
- const BORDER_SURROUND = `${BORDER}--surround`;
- const BORDER_TOP_BOTTOM = `${BORDER}--top-bottom`;
- const BORDER_UNSET_TOP_BOTTOM = `${BORDER}-unset--top-bottom`;
- const HAPTICS_FEEDBACK = "van-haptics-feedback";
- const FORM_KEY = Symbol("van-form");
- function callInterceptor(interceptor, {
- args = [],
- done,
- canceled
- }) {
- if (interceptor) {
- const returnVal = interceptor.apply(null, args);
- if (isPromise(returnVal)) {
- returnVal.then((value) => {
- if (value) {
- done();
- } else if (canceled) {
- canceled();
- }
- }).catch(noop);
- } else if (returnVal) {
- done();
- } else if (canceled) {
- canceled();
- }
- } else {
- done();
- }
- }
- function withInstall(options) {
- options.install = (app) => {
- const { name: name2 } = options;
- if (name2) {
- app.component(name2, options);
- app.component(camelize(`-${name2}`), options);
- }
- };
- return options;
- }
- const POPUP_TOGGLE_KEY = Symbol();
- function onPopupReopen(callback) {
- const popupToggleStatus = inject(POPUP_TOGGLE_KEY, null);
- if (popupToggleStatus) {
- watch(popupToggleStatus, (show) => {
- if (show) {
- callback();
- }
- });
- }
- }
- const useHeight = (element, withSafeArea) => {
- const height = ref();
- const setHeight = () => {
- height.value = useRect(element).height;
- };
- onMounted(() => {
- nextTick(setHeight);
- if (withSafeArea) {
- for (let i = 1; i <= 3; i++) {
- setTimeout(setHeight, 100 * i);
- }
- }
- });
- onPopupReopen(() => nextTick(setHeight));
- return height;
- };
- function usePlaceholder(contentRef, bem2) {
- const height = useHeight(contentRef, true);
- return (renderContent) => createVNode("div", {
- "class": bem2("placeholder"),
- "style": {
- height: height.value ? `${height.value}px` : void 0
- }
- }, [renderContent()]);
- }
- const [name$1v, bem$1r] = createNamespace("action-bar");
- const ACTION_BAR_KEY = Symbol(name$1v);
- const actionBarProps = {
- placeholder: Boolean,
- safeAreaInsetBottom: truthProp
- };
- var stdin_default$1C = defineComponent({
- name: name$1v,
- props: actionBarProps,
- setup(props, {
- slots
- }) {
- const root = ref();
- const renderPlaceholder = usePlaceholder(root, bem$1r);
- const {
- linkChildren
- } = useChildren(ACTION_BAR_KEY);
- linkChildren();
- const renderActionBar = () => {
- var _a;
- return createVNode("div", {
- "ref": root,
- "class": [bem$1r(), {
- "van-safe-area-bottom": props.safeAreaInsetBottom
- }]
- }, [(_a = slots.default) == null ? void 0 : _a.call(slots)]);
- };
- return () => {
- if (props.placeholder) {
- return renderPlaceholder(renderActionBar);
- }
- return renderActionBar();
- };
- }
- });
- const ActionBar = withInstall(stdin_default$1C);
- function useExpose(apis) {
- const instance2 = getCurrentInstance();
- if (instance2) {
- extend(instance2.proxy, apis);
- }
- }
- const routeProps = {
- to: [String, Object],
- url: String,
- replace: Boolean
- };
- function route({
- to,
- url,
- replace,
- $router: router
- }) {
- if (to && router) {
- router[replace ? "replace" : "push"](to);
- } else if (url) {
- replace ? location.replace(url) : location.href = url;
- }
- }
- function useRoute() {
- const vm = getCurrentInstance().proxy;
- return () => route(vm);
- }
- const [name$1u, bem$1q] = createNamespace("badge");
- const badgeProps = {
- dot: Boolean,
- max: numericProp,
- tag: makeStringProp("div"),
- color: String,
- offset: Array,
- content: numericProp,
- showZero: truthProp,
- position: makeStringProp("top-right")
- };
- var stdin_default$1B = defineComponent({
- name: name$1u,
- props: badgeProps,
- setup(props, {
- slots
- }) {
- const hasContent = () => {
- if (slots.content) {
- return true;
- }
- const {
- content,
- showZero
- } = props;
- return isDef(content) && content !== "" && (showZero || content !== 0 && content !== "0");
- };
- const renderContent = () => {
- const {
- dot,
- max,
- content
- } = props;
- if (!dot && hasContent()) {
- if (slots.content) {
- return slots.content();
- }
- if (isDef(max) && isNumeric(content) && +content > max) {
- return `${max}+`;
- }
- return content;
- }
- };
- const style = computed(() => {
- const style2 = {
- background: props.color
- };
- if (props.offset) {
- const [x, y] = props.offset;
- if (slots.default) {
- style2.top = addUnit(y);
- if (typeof x === "number") {
- style2.right = addUnit(-x);
- } else {
- style2.right = x.startsWith("-") ? x.replace("-", "") : `-${x}`;
- }
- } else {
- style2.marginTop = addUnit(y);
- style2.marginLeft = addUnit(x);
- }
- }
- return style2;
- });
- const renderBadge = () => {
- if (hasContent() || props.dot) {
- return createVNode("div", {
- "class": bem$1q([props.position, {
- dot: props.dot,
- fixed: !!slots.default
- }]),
- "style": style.value
- }, [renderContent()]);
- }
- };
- return () => {
- if (slots.default) {
- const {
- tag
- } = props;
- return createVNode(tag, {
- "class": bem$1q("wrapper")
- }, {
- default: () => [slots.default(), renderBadge()]
- });
- }
- return renderBadge();
- };
- }
- });
- const Badge = withInstall(stdin_default$1B);
- let globalZIndex = 2e3;
- const useGlobalZIndex = () => ++globalZIndex;
- const setGlobalZIndex = (val) => {
- globalZIndex = val;
- };
- const [name$1t, bem$1p] = createNamespace("config-provider");
- const CONFIG_PROVIDER_KEY = Symbol(name$1t);
- const configProviderProps = {
- tag: makeStringProp("div"),
- zIndex: Number,
- themeVars: Object,
- iconPrefix: String
- };
- function mapThemeVarsToCSSVars(themeVars) {
- const cssVars = {};
- Object.keys(themeVars).forEach((key) => {
- cssVars[`--van-${kebabCase(key)}`] = themeVars[key];
- });
- return cssVars;
- }
- var stdin_default$1A = defineComponent({
- name: name$1t,
- props: configProviderProps,
- setup(props, {
- slots
- }) {
- const style = computed(() => {
- if (props.themeVars) {
- return mapThemeVarsToCSSVars(props.themeVars);
- }
- });
- provide(CONFIG_PROVIDER_KEY, props);
- watchEffect(() => {
- if (props.zIndex !== void 0) {
- setGlobalZIndex(props.zIndex);
- }
- });
- return () => createVNode(props.tag, {
- "class": bem$1p(),
- "style": style.value
- }, {
- default: () => {
- var _a;
- return [(_a = slots.default) == null ? void 0 : _a.call(slots)];
- }
- });
- }
- });
- const [name$1s, bem$1o] = createNamespace("icon");
- const isImage = (name2) => name2 == null ? void 0 : name2.includes("/");
- const iconProps = {
- dot: Boolean,
- tag: makeStringProp("i"),
- name: String,
- size: numericProp,
- badge: numericProp,
- color: String,
- badgeProps: Object,
- classPrefix: String
- };
- var stdin_default$1z = defineComponent({
- name: name$1s,
- props: iconProps,
- setup(props, {
- slots
- }) {
- const config = inject(CONFIG_PROVIDER_KEY, null);
- const classPrefix = computed(() => props.classPrefix || (config == null ? void 0 : config.iconPrefix) || bem$1o());
- return () => {
- const {
- tag,
- dot,
- name: name2,
- size,
- badge,
- color
- } = props;
- const isImageIcon = isImage(name2);
- return createVNode(Badge, mergeProps({
- "dot": dot,
- "tag": tag,
- "class": [classPrefix.value, isImageIcon ? "" : `${classPrefix.value}-${name2}`],
- "style": {
- color,
- fontSize: addUnit(size)
- },
- "content": badge
- }, props.badgeProps), {
- default: () => {
- var _a;
- return [(_a = slots.default) == null ? void 0 : _a.call(slots), isImageIcon && createVNode("img", {
- "class": bem$1o("image"),
- "src": name2
- }, null)];
- }
- });
- };
- }
- });
- const Icon = withInstall(stdin_default$1z);
- const [name$1r, bem$1n] = createNamespace("loading");
- const SpinIcon = Array(12).fill(null).map((_, index) => createVNode("i", {
- "class": bem$1n("line", String(index + 1))
- }, null));
- const CircularIcon = createVNode("svg", {
- "class": bem$1n("circular"),
- "viewBox": "25 25 50 50"
- }, [createVNode("circle", {
- "cx": "50",
- "cy": "50",
- "r": "20",
- "fill": "none"
- }, null)]);
- const loadingProps = {
- size: numericProp,
- type: makeStringProp("circular"),
- color: String,
- vertical: Boolean,
- textSize: numericProp,
- textColor: String
- };
- var stdin_default$1y = defineComponent({
- name: name$1r,
- props: loadingProps,
- setup(props, {
- slots
- }) {
- const spinnerStyle = computed(() => extend({
- color: props.color
- }, getSizeStyle(props.size)));
- const renderText = () => {
- var _a;
- if (slots.default) {
- return createVNode("span", {
- "class": bem$1n("text"),
- "style": {
- fontSize: addUnit(props.textSize),
- color: (_a = props.textColor) != null ? _a : props.color
- }
- }, [slots.default()]);
- }
- };
- return () => {
- const {
- type,
- vertical
- } = props;
- return createVNode("div", {
- "class": bem$1n([type, {
- vertical
- }]),
- "aria-live": "polite",
- "aria-busy": true
- }, [createVNode("span", {
- "class": bem$1n("spinner", type),
- "style": spinnerStyle.value
- }, [type === "spinner" ? SpinIcon : CircularIcon]), renderText()]);
- };
- }
- });
- const Loading = withInstall(stdin_default$1y);
- const [name$1q, bem$1m] = createNamespace("button");
- const buttonProps = extend({}, routeProps, {
- tag: makeStringProp("button"),
- text: String,
- icon: String,
- type: makeStringProp("default"),
- size: makeStringProp("normal"),
- color: String,
- block: Boolean,
- plain: Boolean,
- round: Boolean,
- square: Boolean,
- loading: Boolean,
- hairline: Boolean,
- disabled: Boolean,
- iconPrefix: String,
- nativeType: makeStringProp("button"),
- loadingSize: numericProp,
- loadingText: String,
- loadingType: String,
- iconPosition: makeStringProp("left")
- });
- var stdin_default$1x = defineComponent({
- name: name$1q,
- props: buttonProps,
- emits: ["click"],
- setup(props, {
- emit,
- slots
- }) {
- const route2 = useRoute();
- const renderLoadingIcon = () => {
- if (slots.loading) {
- return slots.loading();
- }
- return createVNode(Loading, {
- "size": props.loadingSize,
- "type": props.loadingType,
- "class": bem$1m("loading")
- }, null);
- };
- const renderIcon = () => {
- if (props.loading) {
- return renderLoadingIcon();
- }
- if (slots.icon) {
- return createVNode("div", {
- "class": bem$1m("icon")
- }, [slots.icon()]);
- }
- if (props.icon) {
- return createVNode(Icon, {
- "name": props.icon,
- "class": bem$1m("icon"),
- "classPrefix": props.iconPrefix
- }, null);
- }
- };
- const renderText = () => {
- let text;
- if (props.loading) {
- text = props.loadingText;
- } else {
- text = slots.default ? slots.default() : props.text;
- }
- if (text) {
- return createVNode("span", {
- "class": bem$1m("text")
- }, [text]);
- }
- };
- const getStyle = () => {
- const {
- color,
- plain
- } = props;
- if (color) {
- const style = {
- color: plain ? color : "white"
- };
- if (!plain) {
- style.background = color;
- }
- if (color.includes("gradient")) {
- style.border = 0;
- } else {
- style.borderColor = color;
- }
- return style;
- }
- };
- const onClick = (event) => {
- if (props.loading) {
- preventDefault(event);
- } else if (!props.disabled) {
- emit("click", event);
- route2();
- }
- };
- return () => {
- const {
- tag,
- type,
- size,
- block,
- round,
- plain,
- square,
- loading,
- disabled,
- hairline,
- nativeType,
- iconPosition
- } = props;
- const classes = [bem$1m([type, size, {
- plain,
- block,
- round,
- square,
- loading,
- disabled,
- hairline
- }]), {
- [BORDER_SURROUND]: hairline
- }];
- return createVNode(tag, {
- "type": nativeType,
- "class": classes,
- "style": getStyle(),
- "disabled": disabled,
- "onClick": onClick
- }, {
- default: () => [createVNode("div", {
- "class": bem$1m("content")
- }, [iconPosition === "left" && renderIcon(), renderText(), iconPosition === "right" && renderIcon()])]
- });
- };
- }
- });
- const Button = withInstall(stdin_default$1x);
- const [name$1p, bem$1l] = createNamespace("action-bar-button");
- const actionBarButtonProps = extend({}, routeProps, {
- type: String,
- text: String,
- icon: String,
- color: String,
- loading: Boolean,
- disabled: Boolean
- });
- var stdin_default$1w = defineComponent({
- name: name$1p,
- props: actionBarButtonProps,
- setup(props, {
- slots
- }) {
- const route2 = useRoute();
- const {
- parent,
- index
- } = useParent(ACTION_BAR_KEY);
- const isFirst = computed(() => {
- if (parent) {
- const prev = parent.children[index.value - 1];
- return !(prev && "isButton" in prev);
- }
- });
- const isLast = computed(() => {
- if (parent) {
- const next = parent.children[index.value + 1];
- return !(next && "isButton" in next);
- }
- });
- useExpose({
- isButton: true
- });
- return () => {
- const {
- type,
- icon,
- text,
- color,
- loading,
- disabled
- } = props;
- return createVNode(Button, {
- "class": bem$1l([type, {
- last: isLast.value,
- first: isFirst.value
- }]),
- "size": "large",
- "type": type,
- "icon": icon,
- "color": color,
- "loading": loading,
- "disabled": disabled,
- "onClick": route2
- }, {
- default: () => [slots.default ? slots.default() : text]
- });
- };
- }
- });
- const ActionBarButton = withInstall(stdin_default$1w);
- const [name$1o, bem$1k] = createNamespace("action-bar-icon");
- const actionBarIconProps = extend({}, routeProps, {
- dot: Boolean,
- text: String,
- icon: String,
- color: String,
- badge: numericProp,
- iconClass: unknownProp,
- badgeProps: Object,
- iconPrefix: String
- });
- var stdin_default$1v = defineComponent({
- name: name$1o,
- props: actionBarIconProps,
- setup(props, {
- slots
- }) {
- const route2 = useRoute();
- useParent(ACTION_BAR_KEY);
- const renderIcon = () => {
- const {
- dot,
- badge,
- icon,
- color,
- iconClass,
- badgeProps: badgeProps2,
- iconPrefix
- } = props;
- if (slots.icon) {
- return createVNode(Badge, mergeProps({
- "dot": dot,
- "class": bem$1k("icon"),
- "content": badge
- }, badgeProps2), {
- default: slots.icon
- });
- }
- return createVNode(Icon, {
- "tag": "div",
- "dot": dot,
- "name": icon,
- "badge": badge,
- "color": color,
- "class": [bem$1k("icon"), iconClass],
- "badgeProps": badgeProps2,
- "classPrefix": iconPrefix
- }, null);
- };
- return () => createVNode("div", {
- "role": "button",
- "class": bem$1k(),
- "tabindex": 0,
- "onClick": route2
- }, [renderIcon(), slots.default ? slots.default() : props.text]);
- }
- });
- const ActionBarIcon = withInstall(stdin_default$1v);
- const popupSharedProps = {
- show: Boolean,
- zIndex: numericProp,
- overlay: truthProp,
- duration: numericProp,
- teleport: [String, Object],
- lockScroll: truthProp,
- lazyRender: truthProp,
- beforeClose: Function,
- overlayStyle: Object,
- overlayClass: unknownProp,
- transitionAppear: Boolean,
- closeOnClickOverlay: truthProp
- };
- const popupSharedPropKeys = Object.keys(
- popupSharedProps
- );
- function getDirection(x, y) {
- if (x > y) {
- return "horizontal";
- }
- if (y > x) {
- return "vertical";
- }
- return "";
- }
- function useTouch() {
- const startX = ref(0);
- const startY = ref(0);
- const deltaX = ref(0);
- const deltaY = ref(0);
- const offsetX = ref(0);
- const offsetY = ref(0);
- const direction = ref("");
- const isVertical = () => direction.value === "vertical";
- const isHorizontal = () => direction.value === "horizontal";
- const reset = () => {
- deltaX.value = 0;
- deltaY.value = 0;
- offsetX.value = 0;
- offsetY.value = 0;
- direction.value = "";
- };
- const start = (event) => {
- reset();
- startX.value = event.touches[0].clientX;
- startY.value = event.touches[0].clientY;
- };
- const move = (event) => {
- const touch = event.touches[0];
- deltaX.value = (touch.clientX < 0 ? 0 : touch.clientX) - startX.value;
- deltaY.value = touch.clientY - startY.value;
- offsetX.value = Math.abs(deltaX.value);
- offsetY.value = Math.abs(deltaY.value);
- const LOCK_DIRECTION_DISTANCE = 10;
- if (!direction.value || offsetX.value < LOCK_DIRECTION_DISTANCE && offsetY.value < LOCK_DIRECTION_DISTANCE) {
- direction.value = getDirection(offsetX.value, offsetY.value);
- }
- };
- return {
- move,
- start,
- reset,
- startX,
- startY,
- deltaX,
- deltaY,
- offsetX,
- offsetY,
- direction,
- isVertical,
- isHorizontal
- };
- }
- let totalLockCount = 0;
- const BODY_LOCK_CLASS = "van-overflow-hidden";
- function useLockScroll(rootRef, shouldLock) {
- const touch = useTouch();
- const DIRECTION_UP = "01";
- const DIRECTION_DOWN = "10";
- const onTouchMove = (event) => {
- touch.move(event);
- const direction = touch.deltaY.value > 0 ? DIRECTION_DOWN : DIRECTION_UP;
- const el = getScrollParent(
- event.target,
- rootRef.value
- );
- const { scrollHeight, offsetHeight, scrollTop } = el;
- let status = "11";
- if (scrollTop === 0) {
- status = offsetHeight >= scrollHeight ? "00" : "01";
- } else if (scrollTop + offsetHeight >= scrollHeight) {
- status = "10";
- }
- if (status !== "11" && touch.isVertical() && !(parseInt(status, 2) & parseInt(direction, 2))) {
- preventDefault(event, true);
- }
- };
- const lock = () => {
- document.addEventListener("touchstart", touch.start);
- document.addEventListener("touchmove", onTouchMove, { passive: false });
- if (!totalLockCount) {
- document.body.classList.add(BODY_LOCK_CLASS);
- }
- totalLockCount++;
- };
- const unlock = () => {
- if (totalLockCount) {
- document.removeEventListener("touchstart", touch.start);
- document.removeEventListener("touchmove", onTouchMove);
- totalLockCount--;
- if (!totalLockCount) {
- document.body.classList.remove(BODY_LOCK_CLASS);
- }
- }
- };
- const init = () => shouldLock() && lock();
- const destroy = () => shouldLock() && unlock();
- onMountedOrActivated(init);
- onDeactivated(destroy);
- onBeforeUnmount(destroy);
- watch(shouldLock, (value) => {
- value ? lock() : unlock();
- });
- }
- function useLazyRender(show) {
- const inited = ref(false);
- watch(
- show,
- (value) => {
- if (value) {
- inited.value = value;
- }
- },
- { immediate: true }
- );
- return (render) => () => inited.value ? render() : null;
- }
- const [name$1n, bem$1j] = createNamespace("overlay");
- const overlayProps = {
- show: Boolean,
- zIndex: numericProp,
- duration: numericProp,
- className: unknownProp,
- lockScroll: truthProp,
- lazyRender: truthProp,
- customStyle: Object
- };
- var stdin_default$1u = defineComponent({
- name: name$1n,
- props: overlayProps,
- setup(props, {
- slots
- }) {
- const root = ref();
- const lazyRender = useLazyRender(() => props.show || !props.lazyRender);
- const onTouchMove = (event) => {
- if (props.lockScroll) {
- preventDefault(event, true);
- }
- };
- const renderOverlay = lazyRender(() => {
- var _a;
- const style = extend(getZIndexStyle(props.zIndex), props.customStyle);
- if (isDef(props.duration)) {
- style.animationDuration = `${props.duration}s`;
- }
- return withDirectives(createVNode("div", {
- "ref": root,
- "style": style,
- "class": [bem$1j(), props.className]
- }, [(_a = slots.default) == null ? void 0 : _a.call(slots)]), [[vShow, props.show]]);
- });
- useEventListener("touchmove", onTouchMove, {
- target: root
- });
- return () => createVNode(Transition, {
- "name": "van-fade",
- "appear": true
- }, {
- default: renderOverlay
- });
- }
- });
- const Overlay = withInstall(stdin_default$1u);
- const popupProps$2 = extend({}, popupSharedProps, {
- round: Boolean,
- position: makeStringProp("center"),
- closeIcon: makeStringProp("cross"),
- closeable: Boolean,
- transition: String,
- iconPrefix: String,
- closeOnPopstate: Boolean,
- closeIconPosition: makeStringProp("top-right"),
- safeAreaInsetTop: Boolean,
- safeAreaInsetBottom: Boolean
- });
- const [name$1m, bem$1i] = createNamespace("popup");
- var stdin_default$1t = defineComponent({
- name: name$1m,
- inheritAttrs: false,
- props: popupProps$2,
- emits: ["open", "close", "opened", "closed", "keydown", "update:show", "click-overlay", "click-close-icon"],
- setup(props, {
- emit,
- attrs,
- slots
- }) {
- let opened;
- let shouldReopen;
- const zIndex = ref();
- const popupRef = ref();
- const lazyRender = useLazyRender(() => props.show || !props.lazyRender);
- const style = computed(() => {
- const style2 = {
- zIndex: zIndex.value
- };
- if (isDef(props.duration)) {
- const key = props.position === "center" ? "animationDuration" : "transitionDuration";
- style2[key] = `${props.duration}s`;
- }
- return style2;
- });
- const open = () => {
- if (!opened) {
- opened = true;
- zIndex.value = props.zIndex !== void 0 ? +props.zIndex : useGlobalZIndex();
- emit("open");
- }
- };
- const close = () => {
- if (opened) {
- callInterceptor(props.beforeClose, {
- done() {
- opened = false;
- emit("close");
- emit("update:show", false);
- }
- });
- }
- };
- const onClickOverlay = (event) => {
- emit("click-overlay", event);
- if (props.closeOnClickOverlay) {
- close();
- }
- };
- const renderOverlay = () => {
- if (props.overlay) {
- return createVNode(Overlay, {
- "show": props.show,
- "class": props.overlayClass,
- "zIndex": zIndex.value,
- "duration": props.duration,
- "customStyle": props.overlayStyle,
- "role": props.closeOnClickOverlay ? "button" : void 0,
- "tabindex": props.closeOnClickOverlay ? 0 : void 0,
- "onClick": onClickOverlay
- }, {
- default: slots["overlay-content"]
- });
- }
- };
- const onClickCloseIcon = (event) => {
- emit("click-close-icon", event);
- close();
- };
- const renderCloseIcon = () => {
- if (props.closeable) {
- return createVNode(Icon, {
- "role": "button",
- "tabindex": 0,
- "name": props.closeIcon,
- "class": [bem$1i("close-icon", props.closeIconPosition), HAPTICS_FEEDBACK],
- "classPrefix": props.iconPrefix,
- "onClick": onClickCloseIcon
- }, null);
- }
- };
- const onOpened = () => emit("opened");
- const onClosed = () => emit("closed");
- const onKeydown = (event) => emit("keydown", event);
- const renderPopup = lazyRender(() => {
- var _a;
- const {
- round,
- position,
- safeAreaInsetTop,
- safeAreaInsetBottom
- } = props;
- return withDirectives(createVNode("div", mergeProps({
- "ref": popupRef,
- "style": style.value,
- "role": "dialog",
- "tabindex": 0,
- "class": [bem$1i({
- round,
- [position]: position
- }), {
- "van-safe-area-top": safeAreaInsetTop,
- "van-safe-area-bottom": safeAreaInsetBottom
- }],
- "onKeydown": onKeydown
- }, attrs), [(_a = slots.default) == null ? void 0 : _a.call(slots), renderCloseIcon()]), [[vShow, props.show]]);
- });
- const renderTransition = () => {
- const {
- position,
- transition,
- transitionAppear
- } = props;
- const name2 = position === "center" ? "van-fade" : `van-popup-slide-${position}`;
- return createVNode(Transition, {
- "name": transition || name2,
- "appear": transitionAppear,
- "onAfterEnter": onOpened,
- "onAfterLeave": onClosed
- }, {
- default: renderPopup
- });
- };
- watch(() => props.show, (show) => {
- if (show && !opened) {
- open();
- if (attrs.tabindex === 0) {
- nextTick(() => {
- var _a;
- (_a = popupRef.value) == null ? void 0 : _a.focus();
- });
- }
- }
- if (!show && opened) {
- opened = false;
- emit("close");
- }
- });
- useExpose({
- popupRef
- });
- useLockScroll(popupRef, () => props.show && props.lockScroll);
- useEventListener("popstate", () => {
- if (props.closeOnPopstate) {
- close();
- shouldReopen = false;
- }
- });
- onMounted(() => {
- if (props.show) {
- open();
- }
- });
- onActivated(() => {
- if (shouldReopen) {
- emit("update:show", true);
- shouldReopen = false;
- }
- });
- onDeactivated(() => {
- if (props.show && props.teleport) {
- close();
- shouldReopen = true;
- }
- });
- provide(POPUP_TOGGLE_KEY, () => props.show);
- return () => {
- if (props.teleport) {
- return createVNode(Teleport, {
- "to": props.teleport
- }, {
- default: () => [renderOverlay(), renderTransition()]
- });
- }
- return createVNode(Fragment, null, [renderOverlay(), renderTransition()]);
- };
- }
- });
- const Popup = withInstall(stdin_default$1t);
- const [name$1l, bem$1h] = createNamespace("action-sheet");
- const actionSheetProps = extend({}, popupSharedProps, {
- title: String,
- round: truthProp,
- actions: makeArrayProp(),
- closeIcon: makeStringProp("cross"),
- closeable: truthProp,
- cancelText: String,
- description: String,
- closeOnPopstate: truthProp,
- closeOnClickAction: Boolean,
- safeAreaInsetBottom: truthProp
- });
- const popupInheritKeys$2 = [...popupSharedPropKeys, "round", "closeOnPopstate", "safeAreaInsetBottom"];
- var stdin_default$1s = defineComponent({
- name: name$1l,
- props: actionSheetProps,
- emits: ["select", "cancel", "update:show"],
- setup(props, {
- slots,
- emit
- }) {
- const updateShow = (show) => emit("update:show", show);
- const onCancel = () => {
- updateShow(false);
- emit("cancel");
- };
- const renderHeader = () => {
- if (props.title) {
- return createVNode("div", {
- "class": bem$1h("header")
- }, [props.title, props.closeable && createVNode(Icon, {
- "name": props.closeIcon,
- "class": [bem$1h("close"), HAPTICS_FEEDBACK],
- "onClick": onCancel
- }, null)]);
- }
- };
- const renderCancel = () => {
- if (slots.cancel || props.cancelText) {
- return [createVNode("div", {
- "class": bem$1h("gap")
- }, null), createVNode("button", {
- "type": "button",
- "class": bem$1h("cancel"),
- "onClick": onCancel
- }, [slots.cancel ? slots.cancel() : props.cancelText])];
- }
- };
- const renderActionContent = (action, index) => {
- if (action.loading) {
- return createVNode(Loading, {
- "class": bem$1h("loading-icon")
- }, null);
- }
- if (slots.action) {
- return slots.action({
- action,
- index
- });
- }
- return [createVNode("span", {
- "class": bem$1h("name")
- }, [action.name]), action.subname && createVNode("div", {
- "class": bem$1h("subname")
- }, [action.subname])];
- };
- const renderAction = (action, index) => {
- const {
- color,
- loading,
- callback,
- disabled,
- className
- } = action;
- const onClick = () => {
- if (disabled || loading) {
- return;
- }
- if (callback) {
- callback(action);
- }
- if (props.closeOnClickAction) {
- updateShow(false);
- }
- nextTick(() => emit("select", action, index));
- };
- return createVNode("button", {
- "type": "button",
- "style": {
- color
- },
- "class": [bem$1h("item", {
- loading,
- disabled
- }), className],
- "onClick": onClick
- }, [renderActionContent(action, index)]);
- };
- const renderDescription = () => {
- if (props.description || slots.description) {
- const content = slots.description ? slots.description() : props.description;
- return createVNode("div", {
- "class": bem$1h("description")
- }, [content]);
- }
- };
- return () => createVNode(Popup, mergeProps({
- "class": bem$1h(),
- "position": "bottom",
- "onUpdate:show": updateShow
- }, pick(props, popupInheritKeys$2)), {
- default: () => {
- var _a;
- return [renderHeader(), renderDescription(), createVNode("div", {
- "class": bem$1h("content")
- }, [props.actions.map(renderAction), (_a = slots.default) == null ? void 0 : _a.call(slots)]), renderCancel()];
- }
- });
- }
- });
- const ActionSheet = withInstall(stdin_default$1s);
- function deepClone(obj) {
- if (!isDef(obj)) {
- return obj;
- }
- if (Array.isArray(obj)) {
- return obj.map((item) => deepClone(item));
- }
- if (isObject(obj)) {
- const to = {};
- Object.keys(obj).forEach((key) => {
- to[key] = deepClone(obj[key]);
- });
- return to;
- }
- return obj;
- }
- const DEFAULT_DURATION = 200;
- const MOMENTUM_LIMIT_TIME = 300;
- const MOMENTUM_LIMIT_DISTANCE = 15;
- const [name$1k, bem$1g] = createNamespace("picker-column");
- function getElementTranslateY(element) {
- const {
- transform
- } = window.getComputedStyle(element);
- const translateY = transform.slice(7, transform.length - 1).split(", ")[5];
- return Number(translateY);
- }
- const PICKER_KEY = Symbol(name$1k);
- const isOptionDisabled = (option) => isObject(option) && option.disabled;
- var stdin_default$1r = defineComponent({
- name: name$1k,
- props: {
- textKey: makeRequiredProp(String),
- readonly: Boolean,
- allowHtml: Boolean,
- className: unknownProp,
- itemHeight: makeRequiredProp(Number),
- defaultIndex: makeNumberProp(0),
- swipeDuration: makeRequiredProp(numericProp),
- initialOptions: makeArrayProp(),
- visibleItemCount: makeRequiredProp(numericProp)
- },
- emits: ["change"],
- setup(props, {
- emit,
- slots
- }) {
- let moving;
- let startOffset;
- let touchStartTime;
- let momentumOffset;
- let transitionEndTrigger;
- const root = ref();
- const wrapper = ref();
- const state = reactive({
- index: props.defaultIndex,
- offset: 0,
- duration: 0,
- options: deepClone(props.initialOptions)
- });
- const touch = useTouch();
- const count = () => state.options.length;
- const baseOffset = () => props.itemHeight * (+props.visibleItemCount - 1) / 2;
- const adjustIndex = (index) => {
- index = clamp(index, 0, count());
- for (let i = index; i < count(); i++) {
- if (!isOptionDisabled(state.options[i]))
- return i;
- }
- for (let i = index - 1; i >= 0; i--) {
- if (!isOptionDisabled(state.options[i]))
- return i;
- }
- };
- const setIndex = (index, emitChange) => {
- index = adjustIndex(index) || 0;
- const offset = -index * props.itemHeight;
- const trigger = () => {
- if (index !== state.index) {
- state.index = index;
- if (emitChange) {
- emit("change", index);
- }
- }
- };
- if (moving && offset !== state.offset) {
- transitionEndTrigger = trigger;
- } else {
- trigger();
- }
- state.offset = offset;
- };
- const setOptions = (options) => {
- if (JSON.stringify(options) !== JSON.stringify(state.options)) {
- state.options = deepClone(options);
- setIndex(props.defaultIndex);
- }
- };
- const onClickItem = (index) => {
- if (moving || props.readonly) {
- return;
- }
- transitionEndTrigger = null;
- state.duration = DEFAULT_DURATION;
- setIndex(index, true);
- };
- const getOptionText = (option) => {
- if (isObject(option) && props.textKey in option) {
- return option[props.textKey];
- }
- return option;
- };
- const getIndexByOffset = (offset) => clamp(Math.round(-offset / props.itemHeight), 0, count() - 1);
- const momentum = (distance, duration) => {
- const speed = Math.abs(distance / duration);
- distance = state.offset + speed / 3e-3 * (distance < 0 ? -1 : 1);
- const index = getIndexByOffset(distance);
- state.duration = +props.swipeDuration;
- setIndex(index, true);
- };
- const stopMomentum = () => {
- moving = false;
- state.duration = 0;
- if (transitionEndTrigger) {
- transitionEndTrigger();
- transitionEndTrigger = null;
- }
- };
- const onTouchStart = (event) => {
- if (props.readonly) {
- return;
- }
- touch.start(event);
- if (moving) {
- const translateY = getElementTranslateY(wrapper.value);
- state.offset = Math.min(0, translateY - baseOffset());
- startOffset = state.offset;
- } else {
- startOffset = state.offset;
- }
- state.duration = 0;
- touchStartTime = Date.now();
- momentumOffset = startOffset;
- transitionEndTrigger = null;
- };
- const onTouchMove = (event) => {
- if (props.readonly) {
- return;
- }
- touch.move(event);
- if (touch.isVertical()) {
- moving = true;
- preventDefault(event, true);
- }
- state.offset = clamp(startOffset + touch.deltaY.value, -(count() * props.itemHeight), props.itemHeight);
- const now = Date.now();
- if (now - touchStartTime > MOMENTUM_LIMIT_TIME) {
- touchStartTime = now;
- momentumOffset = state.offset;
- }
- };
- const onTouchEnd = () => {
- if (props.readonly) {
- return;
- }
- const distance = state.offset - momentumOffset;
- const duration = Date.now() - touchStartTime;
- const allowMomentum = duration < MOMENTUM_LIMIT_TIME && Math.abs(distance) > MOMENTUM_LIMIT_DISTANCE;
- if (allowMomentum) {
- momentum(distance, duration);
- return;
- }
- const index = getIndexByOffset(state.offset);
- state.duration = DEFAULT_DURATION;
- setIndex(index, true);
- setTimeout(() => {
- moving = false;
- }, 0);
- };
- const renderOptions = () => {
- const optionStyle = {
- height: `${props.itemHeight}px`
- };
- return state.options.map((option, index) => {
- const text = getOptionText(option);
- const disabled = isOptionDisabled(option);
- const data = {
- role: "button",
- style: optionStyle,
- tabindex: disabled ? -1 : 0,
- class: bem$1g("item", {
- disabled,
- selected: index === state.index
- }),
- onClick: () => onClickItem(index)
- };
- const childData = {
- class: "van-ellipsis",
- [props.allowHtml ? "innerHTML" : "textContent"]: text
- };
- return createVNode("li", data, [slots.option ? slots.option(option) : createVNode("div", childData, null)]);
- });
- };
- const setValue = (value) => {
- const {
- options
- } = state;
- for (let i = 0; i < options.length; i++) {
- if (getOptionText(options[i]) === value) {
- return setIndex(i);
- }
- }
- };
- const getValue = () => state.options[state.index];
- const hasOptions = () => state.options.length;
- setIndex(state.index);
- useParent(PICKER_KEY);
- useExpose({
- state,
- setIndex,
- getValue,
- setValue,
- setOptions,
- hasOptions,
- stopMomentum
- });
- watch(() => props.initialOptions, setOptions);
- watch(() => props.defaultIndex, (value) => setIndex(value));
- useEventListener("touchmove", onTouchMove, {
- target: root
- });
- return () => createVNode("div", {
- "ref": root,
- "class": [bem$1g(), props.className],
- "onTouchstartPassive": onTouchStart,
- "onTouchend": onTouchEnd,
- "onTouchcancel": onTouchEnd
- }, [createVNode("ul", {
- "ref": wrapper,
- "style": {
- transform: `translate3d(0, ${state.offset + baseOffset()}px, 0)`,
- transitionDuration: `${state.duration}ms`,
- transitionProperty: state.duration ? "all" : "none"
- },
- "class": bem$1g("wrapper"),
- "onTransitionend": stopMomentum
- }, [renderOptions()])]);
- }
- });
- const [name$1j, bem$1f, t$j] = createNamespace("picker");
- const pickerSharedProps = {
- title: String,
- loading: Boolean,
- readonly: Boolean,
- allowHtml: Boolean,
- itemHeight: makeNumericProp(44),
- showToolbar: truthProp,
- swipeDuration: makeNumericProp(1e3),
- visibleItemCount: makeNumericProp(6),
- cancelButtonText: String,
- confirmButtonText: String
- };
- const pickerProps = extend({}, pickerSharedProps, {
- columns: makeArrayProp(),
- valueKey: String,
- defaultIndex: makeNumericProp(0),
- toolbarPosition: makeStringProp("top"),
- columnsFieldNames: Object
- });
- var stdin_default$1q = defineComponent({
- name: name$1j,
- props: pickerProps,
- emits: ["confirm", "cancel", "change"],
- setup(props, {
- emit,
- slots
- }) {
- if (process.env.NODE_ENV !== "production") {
- if (slots.default) {
- console.warn('[Vant] Picker: "default" slot is deprecated, please use "toolbar" slot instead.');
- }
- if (props.valueKey) {
- console.warn('[Vant] Picker: "valueKey" prop is deprecated, please use "columnsFieldNames" prop instead.');
- }
- }
- const hasOptions = ref(false);
- const columnsRef = ref();
- const formattedColumns = ref([]);
- const columnsFieldNames = computed(() => {
- const {
- columnsFieldNames: columnsFieldNames2
- } = props;
- return {
- text: (columnsFieldNames2 == null ? void 0 : columnsFieldNames2.text) || props.valueKey || "text",
- values: (columnsFieldNames2 == null ? void 0 : columnsFieldNames2.values) || "values",
- children: (columnsFieldNames2 == null ? void 0 : columnsFieldNames2.children) || "children"
- };
- });
- const {
- children,
- linkChildren
- } = useChildren(PICKER_KEY);
- linkChildren();
- const itemHeight = computed(() => unitToPx(props.itemHeight));
- const dataType = computed(() => {
- const firstColumn = props.columns[0];
- if (typeof firstColumn === "object") {
- if (columnsFieldNames.value.children in firstColumn) {
- return "cascade";
- }
- if (columnsFieldNames.value.values in firstColumn) {
- return "object";
- }
- }
- return "plain";
- });
- const formatCascade = () => {
- var _a;
- const formatted = [];
- let cursor = {
- [columnsFieldNames.value.children]: props.columns
- };
- while (cursor && cursor[columnsFieldNames.value.children]) {
- const children2 = cursor[columnsFieldNames.value.children];
- let defaultIndex = (_a = cursor.defaultIndex) != null ? _a : +props.defaultIndex;
- while (children2[defaultIndex] && children2[defaultIndex].disabled) {
- if (defaultIndex < children2.length - 1) {
- defaultIndex++;
- } else {
- defaultIndex = 0;
- break;
- }
- }
- formatted.push({
- [columnsFieldNames.value.values]: cursor[columnsFieldNames.value.children],
- className: cursor.className,
- defaultIndex
- });
- cursor = children2[defaultIndex];
- }
- formattedColumns.value = formatted;
- };
- const format2 = () => {
- const {
- columns
- } = props;
- if (dataType.value === "plain") {
- formattedColumns.value = [{
- [columnsFieldNames.value.values]: columns
- }];
- } else if (dataType.value === "cascade") {
- formatCascade();
- } else {
- formattedColumns.value = columns;
- }
- hasOptions.value = formattedColumns.value.some((item) => item[columnsFieldNames.value.values] && item[columnsFieldNames.value.values].length !== 0) || children.some((item) => item.hasOptions);
- };
- const getIndexes = () => children.map((child) => child.state.index);
- const setColumnValues = (index, options) => {
- const column = children[index];
- if (column) {
- column.setOptions(options);
- hasOptions.value = true;
- }
- };
- const onCascadeChange = (columnIndex) => {
- let cursor = {
- [columnsFieldNames.value.children]: props.columns
- };
- const indexes = getIndexes();
- for (let i = 0; i <= columnIndex; i++) {
- cursor = cursor[columnsFieldNames.value.children][indexes[i]];
- }
- while (cursor && cursor[columnsFieldNames.value.children]) {
- columnIndex++;
- setColumnValues(columnIndex, cursor[columnsFieldNames.value.children]);
- cursor = cursor[columnsFieldNames.value.children][cursor.defaultIndex || 0];
- }
- };
- const getChild = (index) => children[index];
- const getColumnValue = (index) => {
- const column = getChild(index);
- if (column) {
- return column.getValue();
- }
- };
- const setColumnValue = (index, value) => {
- const column = getChild(index);
- if (column) {
- column.setValue(value);
- if (dataType.value === "cascade") {
- onCascadeChange(index);
- }
- }
- };
- const getColumnIndex = (index) => {
- const column = getChild(index);
- if (column) {
- return column.state.index;
- }
- };
- const setColumnIndex = (columnIndex, optionIndex) => {
- const column = getChild(columnIndex);
- if (column) {
- column.setIndex(optionIndex);
- if (dataType.value === "cascade") {
- onCascadeChange(columnIndex);
- }
- }
- };
- const getColumnValues = (index) => {
- const column = getChild(index);
- if (column) {
- return column.state.options;
- }
- };
- const getValues = () => children.map((child) => child.getValue());
- const setValues = (values) => {
- values.forEach((value, index) => {
- setColumnValue(index, value);
- });
- };
- const setIndexes = (indexes) => {
- indexes.forEach((optionIndex, columnIndex) => {
- setColumnIndex(columnIndex, optionIndex);
- });
- };
- const emitAction = (event) => {
- if (dataType.value === "plain") {
- emit(event, getColumnValue(0), getColumnIndex(0));
- } else {
- emit(event, getValues(), getIndexes());
- }
- };
- const onChange = (columnIndex) => {
- if (dataType.value === "cascade") {
- onCascadeChange(columnIndex);
- }
- if (dataType.value === "plain") {
- emit("change", getColumnValue(0), getColumnIndex(0));
- } else {
- emit("change", getValues(), columnIndex);
- }
- };
- const confirm = () => {
- children.forEach((child) => child.stopMomentum());
- emitAction("confirm");
- };
- const cancel = () => emitAction("cancel");
- const renderTitle = () => {
- if (slots.title) {
- return slots.title();
- }
- if (props.title) {
- return createVNode("div", {
- "class": [bem$1f("title"), "van-ellipsis"]
- }, [props.title]);
- }
- };
- const renderCancel = () => {
- const text = props.cancelButtonText || t$j("cancel");
- return createVNode("button", {
- "type": "button",
- "class": [bem$1f("cancel"), HAPTICS_FEEDBACK],
- "onClick": cancel
- }, [slots.cancel ? slots.cancel() : text]);
- };
- const renderConfirm = () => {
- const text = props.confirmButtonText || t$j("confirm");
- return createVNode("button", {
- "type": "button",
- "class": [bem$1f("confirm"), HAPTICS_FEEDBACK],
- "onClick": confirm
- }, [slots.confirm ? slots.confirm() : text]);
- };
- const renderToolbar = () => {
- if (props.showToolbar) {
- const slot = slots.toolbar || slots.default;
- return createVNode("div", {
- "class": bem$1f("toolbar")
- }, [slot ? slot() : [renderCancel(), renderTitle(), renderConfirm()]]);
- }
- };
- const renderColumnItems = () => formattedColumns.value.map((item, columnIndex) => {
- var _a;
- return createVNode(stdin_default$1r, {
- "textKey": columnsFieldNames.value.text,
- "readonly": props.readonly,
- "allowHtml": props.allowHtml,
- "className": item.className,
- "itemHeight": itemHeight.value,
- "defaultIndex": (_a = item.defaultIndex) != null ? _a : +props.defaultIndex,
- "swipeDuration": props.swipeDuration,
- "initialOptions": item[columnsFieldNames.value.values],
- "visibleItemCount": props.visibleItemCount,
- "onChange": () => onChange(columnIndex)
- }, {
- option: slots.option
- });
- });
- const renderMask = (wrapHeight) => {
- if (hasOptions.value) {
- const frameStyle = {
- height: `${itemHeight.value}px`
- };
- const maskStyle = {
- backgroundSize: `100% ${(wrapHeight - itemHeight.value) / 2}px`
- };
- return [createVNode("div", {
- "class": bem$1f("mask"),
- "style": maskStyle
- }, null), createVNode("div", {
- "class": [BORDER_UNSET_TOP_BOTTOM, bem$1f("frame")],
- "style": frameStyle
- }, null)];
- }
- };
- const renderColumns = () => {
- const wrapHeight = itemHeight.value * +props.visibleItemCount;
- const columnsStyle = {
- height: `${wrapHeight}px`
- };
- return createVNode("div", {
- "ref": columnsRef,
- "class": bem$1f("columns"),
- "style": columnsStyle
- }, [renderColumnItems(), renderMask(wrapHeight)]);
- };
- watch(() => props.columns, format2, {
- immediate: true
- });
- useEventListener("touchmove", preventDefault, {
- target: columnsRef
- });
- useExpose({
- confirm,
- getValues,
- setValues,
- getIndexes,
- setIndexes,
- getColumnIndex,
- setColumnIndex,
- getColumnValue,
- setColumnValue,
- getColumnValues,
- setColumnValues
- });
- return () => {
- var _a, _b;
- return createVNode("div", {
- "class": bem$1f()
- }, [props.toolbarPosition === "top" ? renderToolbar() : null, props.loading ? createVNode(Loading, {
- "class": bem$1f("loading")
- }, 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]);
- };
- }
- });
- const Picker = withInstall(stdin_default$1q);
- const [name$1i, bem$1e] = createNamespace("area");
- const EMPTY_CODE = "000000";
- const INHERIT_SLOTS = ["title", "cancel", "confirm", "toolbar", "columns-top", "columns-bottom"];
- const INHERIT_PROPS = ["title", "loading", "readonly", "itemHeight", "swipeDuration", "visibleItemCount", "cancelButtonText", "confirmButtonText"];
- const isOverseaCode = (code) => code[0] === "9";
- const areaProps = extend({}, pickerSharedProps, {
- value: String,
- columnsNum: makeNumericProp(3),
- columnsPlaceholder: makeArrayProp(),
- areaList: {
- type: Object,
- default: () => ({})
- },
- isOverseaCode: {
- type: Function,
- default: isOverseaCode
- }
- });
- var stdin_default$1p = defineComponent({
- name: name$1i,
- props: areaProps,
- emits: ["change", "confirm", "cancel"],
- setup(props, {
- emit,
- slots
- }) {
- const pickerRef = ref();
- const state = reactive({
- code: props.value,
- columns: [{
- values: []
- }, {
- values: []
- }, {
- values: []
- }]
- });
- const areaList = computed(() => {
- const {
- areaList: areaList2
- } = props;
- return {
- province: areaList2.province_list || {},
- city: areaList2.city_list || {},
- county: areaList2.county_list || {}
- };
- });
- const placeholderMap = computed(() => {
- const {
- columnsPlaceholder
- } = props;
- return {
- province: columnsPlaceholder[0] || "",
- city: columnsPlaceholder[1] || "",
- county: columnsPlaceholder[2] || ""
- };
- });
- const getDefaultCode = () => {
- if (props.columnsPlaceholder.length) {
- return EMPTY_CODE;
- }
- const {
- county,
- city
- } = areaList.value;
- const countyCodes = Object.keys(county);
- if (countyCodes[0]) {
- return countyCodes[0];
- }
- const cityCodes = Object.keys(city);
- if (cityCodes[0]) {
- return cityCodes[0];
- }
- return "";
- };
- const getColumnValues = (type, code) => {
- let column = [];
- if (type !== "province" && !code) {
- return column;
- }
- const list = areaList.value[type];
- column = Object.keys(list).map((listCode) => ({
- code: listCode,
- name: list[listCode]
- }));
- if (code) {
- if (type === "city" && props.isOverseaCode(code)) {
- code = "9";
- }
- column = column.filter((item) => item.code.indexOf(code) === 0);
- }
- if (placeholderMap.value[type] && column.length) {
- let codeFill = "";
- if (type === "city") {
- codeFill = EMPTY_CODE.slice(2, 4);
- } else if (type === "county") {
- codeFill = EMPTY_CODE.slice(4, 6);
- }
- column.unshift({
- code: code + codeFill,
- name: placeholderMap.value[type]
- });
- }
- return column;
- };
- const getIndex = (type, code) => {
- let compareNum = code.length;
- if (type === "province") {
- compareNum = props.isOverseaCode(code) ? 1 : 2;
- }
- if (type === "city") {
- compareNum = 4;
- }
- code = code.slice(0, compareNum);
- const list = getColumnValues(type, compareNum > 2 ? code.slice(0, compareNum - 2) : "");
- for (let i = 0; i < list.length; i++) {
- if (list[i].code.slice(0, compareNum) === code) {
- return i;
- }
- }
- return 0;
- };
- const setValues = () => {
- const picker = pickerRef.value;
- if (!picker) {
- return;
- }
- let code = state.code || getDefaultCode();
- const province = getColumnValues("province");
- const city = getColumnValues("city", code.slice(0, 2));
- picker.setColumnValues(0, province);
- picker.setColumnValues(1, city);
- if (city.length && code.slice(2, 4) === "00" && !props.isOverseaCode(code)) {
- [{
- code
- }] = city;
- }
- picker.setColumnValues(2, getColumnValues("county", code.slice(0, 4)));
- picker.setIndexes([getIndex("province", code), getIndex("city", code), getIndex("county", code)]);
- };
- const parseValues = (values) => values.map((value, index) => {
- if (value) {
- value = deepClone(value);
- if (!value.code || value.name === props.columnsPlaceholder[index]) {
- value.code = "";
- value.name = "";
- }
- }
- return value;
- });
- const getValues = () => {
- if (pickerRef.value) {
- const values = pickerRef.value.getValues().filter(Boolean);
- return parseValues(values);
- }
- return [];
- };
- const getArea = () => {
- const values = getValues();
- const area = {
- code: "",
- country: "",
- province: "",
- city: "",
- county: ""
- };
- if (!values.length) {
- return area;
- }
- const names = values.map((item) => item.name);
- const validValues = values.filter((value) => value.code);
- area.code = validValues.length ? validValues[validValues.length - 1].code : "";
- if (props.isOverseaCode(area.code)) {
- area.country = names[1] || "";
- area.province = names[2] || "";
- } else {
- area.province = names[0] || "";
- area.city = names[1] || "";
- area.county = names[2] || "";
- }
- return area;
- };
- const reset = (newCode = "") => {
- state.code = newCode;
- setValues();
- };
- const onChange = (values, index) => {
- state.code = values[index].code;
- setValues();
- if (pickerRef.value) {
- const parsedValues = parseValues(pickerRef.value.getValues());
- emit("change", parsedValues, index);
- }
- };
- const onConfirm = (values, index) => {
- setValues();
- emit("confirm", parseValues(values), index);
- };
- const onCancel = (...args) => emit("cancel", ...args);
- onMounted(setValues);
- watch(() => props.value, (value) => {
- state.code = value;
- setValues();
- });
- watch(() => props.areaList, setValues, {
- deep: true
- });
- watch(() => props.columnsNum, () => {
- nextTick(setValues);
- });
- useExpose({
- reset,
- getArea,
- getValues
- });
- return () => {
- const columns = state.columns.slice(0, +props.columnsNum);
- return createVNode(Picker, mergeProps({
- "ref": pickerRef,
- "class": bem$1e(),
- "columns": columns,
- "columnsFieldNames": {
- text: "name"
- },
- "onChange": onChange,
- "onCancel": onCancel,
- "onConfirm": onConfirm
- }, pick(props, INHERIT_PROPS)), pick(slots, INHERIT_SLOTS));
- };
- }
- });
- const Area = withInstall(stdin_default$1p);
- const [name$1h, bem$1d] = createNamespace("cell");
- const cellSharedProps = {
- icon: String,
- size: String,
- title: numericProp,
- value: numericProp,
- label: numericProp,
- center: Boolean,
- isLink: Boolean,
- border: truthProp,
- required: Boolean,
- iconPrefix: String,
- valueClass: unknownProp,
- labelClass: unknownProp,
- titleClass: unknownProp,
- titleStyle: null,
- arrowDirection: String,
- clickable: {
- type: Boolean,
- default: null
- }
- };
- const cellProps = extend({}, cellSharedProps, routeProps);
- var stdin_default$1o = defineComponent({
- name: name$1h,
- props: cellProps,
- setup(props, {
- slots
- }) {
- const route2 = useRoute();
- const renderLabel = () => {
- const showLabel = slots.label || isDef(props.label);
- if (showLabel) {
- return createVNode("div", {
- "class": [bem$1d("label"), props.labelClass]
- }, [slots.label ? slots.label() : props.label]);
- }
- };
- const renderTitle = () => {
- if (slots.title || isDef(props.title)) {
- return createVNode("div", {
- "class": [bem$1d("title"), props.titleClass],
- "style": props.titleStyle
- }, [slots.title ? slots.title() : createVNode("span", null, [props.title]), renderLabel()]);
- }
- };
- const renderValue = () => {
- const slot = slots.value || slots.default;
- const hasValue = slot || isDef(props.value);
- if (hasValue) {
- const hasTitle = slots.title || isDef(props.title);
- return createVNode("div", {
- "class": [bem$1d("value", {
- alone: !hasTitle
- }), props.valueClass]
- }, [slot ? slot() : createVNode("span", null, [props.value])]);
- }
- };
- const renderLeftIcon = () => {
- if (slots.icon) {
- return slots.icon();
- }
- if (props.icon) {
- return createVNode(Icon, {
- "name": props.icon,
- "class": bem$1d("left-icon"),
- "classPrefix": props.iconPrefix
- }, null);
- }
- };
- const renderRightIcon = () => {
- if (slots["right-icon"]) {
- return slots["right-icon"]();
- }
- if (props.isLink) {
- const name2 = props.arrowDirection && props.arrowDirection !== "right" ? `arrow-${props.arrowDirection}` : "arrow";
- return createVNode(Icon, {
- "name": name2,
- "class": bem$1d("right-icon")
- }, null);
- }
- };
- return () => {
- var _a, _b;
- const {
- size,
- center,
- border,
- isLink,
- required
- } = props;
- const clickable = (_a = props.clickable) != null ? _a : isLink;
- const classes = {
- center,
- required,
- clickable,
- borderless: !border
- };
- if (size) {
- classes[size] = !!size;
- }
- return createVNode("div", {
- "class": bem$1d(classes),
- "role": clickable ? "button" : void 0,
- "tabindex": clickable ? 0 : void 0,
- "onClick": route2
- }, [renderLeftIcon(), renderTitle(), renderValue(), renderRightIcon(), (_b = slots.extra) == null ? void 0 : _b.call(slots)]);
- };
- }
- });
- const Cell = withInstall(stdin_default$1o);
- const [name$1g, bem$1c] = createNamespace("form");
- const formProps = {
- colon: Boolean,
- disabled: Boolean,
- readonly: Boolean,
- showError: Boolean,
- labelWidth: numericProp,
- labelAlign: String,
- inputAlign: String,
- scrollToError: Boolean,
- validateFirst: Boolean,
- submitOnEnter: truthProp,
- showErrorMessage: truthProp,
- errorMessageAlign: String,
- validateTrigger: {
- type: [String, Array],
- default: "onBlur"
- }
- };
- var stdin_default$1n = defineComponent({
- name: name$1g,
- props: formProps,
- emits: ["submit", "failed"],
- setup(props, {
- emit,
- slots
- }) {
- const {
- children,
- linkChildren
- } = useChildren(FORM_KEY);
- const getFieldsByNames = (names) => {
- if (names) {
- return children.filter((field) => names.includes(field.name));
- }
- return children;
- };
- const validateSeq = (names) => new Promise((resolve, reject) => {
- const errors = [];
- const fields = getFieldsByNames(names);
- fields.reduce((promise, field) => promise.then(() => {
- if (!errors.length) {
- return field.validate().then((error) => {
- if (error) {
- errors.push(error);
- }
- });
- }
- }), Promise.resolve()).then(() => {
- if (errors.length) {
- reject(errors);
- } else {
- resolve();
- }
- });
- });
- const validateAll = (names) => new Promise((resolve, reject) => {
- const fields = getFieldsByNames(names);
- Promise.all(fields.map((item) => item.validate())).then((errors) => {
- errors = errors.filter(Boolean);
- if (errors.length) {
- reject(errors);
- } else {
- resolve();
- }
- });
- });
- const validateField = (name2) => {
- const matched = children.find((item) => item.name === name2);
- if (matched) {
- return new Promise((resolve, reject) => {
- matched.validate().then((error) => {
- if (error) {
- reject(error);
- } else {
- resolve();
- }
- });
- });
- }
- return Promise.reject();
- };
- const validate = (name2) => {
- if (typeof name2 === "string") {
- return validateField(name2);
- }
- return props.validateFirst ? validateSeq(name2) : validateAll(name2);
- };
- const resetValidation = (name2) => {
- if (typeof name2 === "string") {
- name2 = [name2];
- }
- const fields = getFieldsByNames(name2);
- fields.forEach((item) => {
- item.resetValidation();
- });
- };
- const getValidationStatus = () => children.reduce((form, field) => {
- form[field.name] = field.getValidationStatus();
- return form;
- }, {});
- const scrollToField = (name2, options) => {
- children.some((item) => {
- if (item.name === name2) {
- item.$el.scrollIntoView(options);
- return true;
- }
- return false;
- });
- };
- const getValues = () => children.reduce((form, field) => {
- form[field.name] = field.formValue.value;
- return form;
- }, {});
- const submit = () => {
- const values = getValues();
- validate().then(() => emit("submit", values)).catch((errors) => {
- emit("failed", {
- values,
- errors
- });
- if (props.scrollToError && errors[0].name) {
- scrollToField(errors[0].name);
- }
- });
- };
- const onSubmit = (event) => {
- preventDefault(event);
- submit();
- };
- linkChildren({
- props
- });
- useExpose({
- submit,
- validate,
- getValues,
- scrollToField,
- resetValidation,
- getValidationStatus
- });
- return () => {
- var _a;
- return createVNode("form", {
- "class": bem$1c(),
- "onSubmit": onSubmit
- }, [(_a = slots.default) == null ? void 0 : _a.call(slots)]);
- };
- }
- });
- const Form = withInstall(stdin_default$1n);
- function isEmptyValue(value) {
- if (Array.isArray(value)) {
- return !value.length;
- }
- if (value === 0) {
- return false;
- }
- return !value;
- }
- function runSyncRule(value, rule) {
- if (isEmptyValue(value)) {
- if (rule.required) {
- return false;
- }
- if (rule.validateEmpty === false) {
- return true;
- }
- }
- if (rule.pattern && !rule.pattern.test(String(value))) {
- return false;
- }
- return true;
- }
- function runRuleValidator(value, rule) {
- return new Promise((resolve) => {
- const returnVal = rule.validator(value, rule);
- if (isPromise(returnVal)) {
- returnVal.then(resolve);
- return;
- }
- resolve(returnVal);
- });
- }
- function getRuleMessage(value, rule) {
- const { message } = rule;
- if (isFunction(message)) {
- return message(value, rule);
- }
- return message || "";
- }
- function startComposing({ target }) {
- target.composing = true;
- }
- function endComposing({ target }) {
- if (target.composing) {
- target.composing = false;
- target.dispatchEvent(new Event("input"));
- }
- }
- function resizeTextarea(input, autosize) {
- const scrollTop = getRootScrollTop();
- input.style.height = "auto";
- let height = input.scrollHeight;
- if (isObject(autosize)) {
- const { maxHeight, minHeight } = autosize;
- if (maxHeight !== void 0) {
- height = Math.min(height, maxHeight);
- }
- if (minHeight !== void 0) {
- height = Math.max(height, minHeight);
- }
- }
- if (height) {
- input.style.height = `${height}px`;
- setRootScrollTop(scrollTop);
- }
- }
- function mapInputType(type) {
- if (type === "number") {
- return {
- type: "text",
- inputmode: "decimal"
- };
- }
- if (type === "digit") {
- return {
- type: "tel",
- inputmode: "numeric"
- };
- }
- return { type };
- }
- function getStringLength(str) {
- return [...str].length;
- }
- function cutString(str, maxlength) {
- return [...str].slice(0, maxlength).join("");
- }
- let current = 0;
- function useId() {
- const vm = getCurrentInstance();
- const { name: name2 = "unknown" } = (vm == null ? void 0 : vm.type) || {};
- if (process.env.NODE_ENV === "test") {
- return name2;
- }
- return `${name2}-${++current}`;
- }
- const [name$1f, bem$1b] = createNamespace("field");
- const fieldSharedProps = {
- id: String,
- name: String,
- leftIcon: String,
- rightIcon: String,
- autofocus: Boolean,
- clearable: Boolean,
- maxlength: numericProp,
- formatter: Function,
- clearIcon: makeStringProp("clear"),
- modelValue: makeNumericProp(""),
- inputAlign: String,
- placeholder: String,
- autocomplete: String,
- errorMessage: String,
- enterkeyhint: String,
- clearTrigger: makeStringProp("focus"),
- formatTrigger: makeStringProp("onChange"),
- error: {
- type: Boolean,
- default: null
- },
- disabled: {
- type: Boolean,
- default: null
- },
- readonly: {
- type: Boolean,
- default: null
- }
- };
- const fieldProps = extend({}, cellSharedProps, fieldSharedProps, {
- rows: numericProp,
- type: makeStringProp("text"),
- rules: Array,
- autosize: [Boolean, Object],
- labelWidth: numericProp,
- labelClass: unknownProp,
- labelAlign: String,
- showWordLimit: Boolean,
- errorMessageAlign: String,
- colon: {
- type: Boolean,
- default: null
- }
- });
- var stdin_default$1m = defineComponent({
- name: name$1f,
- props: fieldProps,
- emits: ["blur", "focus", "clear", "keypress", "click-input", "end-validate", "start-validate", "click-left-icon", "click-right-icon", "update:modelValue"],
- setup(props, {
- emit,
- slots
- }) {
- const id = useId();
- const state = reactive({
- status: "unvalidated",
- focused: false,
- validateMessage: ""
- });
- const inputRef = ref();
- const clearIconRef = ref();
- const customValue = ref();
- const {
- parent: form
- } = useParent(FORM_KEY);
- const getModelValue = () => {
- var _a;
- return String((_a = props.modelValue) != null ? _a : "");
- };
- const getProp = (key) => {
- if (isDef(props[key])) {
- return props[key];
- }
- if (form && isDef(form.props[key])) {
- return form.props[key];
- }
- };
- const showClear = computed(() => {
- const readonly = getProp("readonly");
- if (props.clearable && !readonly) {
- const hasValue = getModelValue() !== "";
- const trigger = props.clearTrigger === "always" || props.clearTrigger === "focus" && state.focused;
- return hasValue && trigger;
- }
- return false;
- });
- const formValue = computed(() => {
- if (customValue.value && slots.input) {
- return customValue.value();
- }
- return props.modelValue;
- });
- const runRules = (rules) => rules.reduce((promise, rule) => promise.then(() => {
- if (state.status === "failed") {
- return;
- }
- let {
- value
- } = formValue;
- if (rule.formatter) {
- value = rule.formatter(value, rule);
- }
- if (!runSyncRule(value, rule)) {
- state.status = "failed";
- state.validateMessage = getRuleMessage(value, rule);
- return;
- }
- if (rule.validator) {
- if (isEmptyValue(value) && rule.validateEmpty === false) {
- return;
- }
- return runRuleValidator(value, rule).then((result) => {
- if (result && typeof result === "string") {
- state.status = "failed";
- state.validateMessage = result;
- } else if (result === false) {
- state.status = "failed";
- state.validateMessage = getRuleMessage(value, rule);
- }
- });
- }
- }), Promise.resolve());
- const resetValidation = () => {
- state.status = "unvalidated";
- state.validateMessage = "";
- };
- const endValidate = () => emit("end-validate", {
- status: state.status
- });
- const validate = (rules = props.rules) => new Promise((resolve) => {
- resetValidation();
- if (rules) {
- emit("start-validate");
- runRules(rules).then(() => {
- if (state.status === "failed") {
- resolve({
- name: props.name,
- message: state.validateMessage
- });
- endValidate();
- } else {
- state.status = "passed";
- resolve();
- endValidate();
- }
- });
- } else {
- resolve();
- }
- });
- const validateWithTrigger = (trigger) => {
- if (form && props.rules) {
- const {
- validateTrigger
- } = form.props;
- const defaultTrigger = toArray(validateTrigger).includes(trigger);
- const rules = props.rules.filter((rule) => {
- if (rule.trigger) {
- return toArray(rule.trigger).includes(trigger);
- }
- return defaultTrigger;
- });
- if (rules.length) {
- validate(rules);
- }
- }
- };
- const limitValueLength = (value) => {
- const {
- maxlength
- } = props;
- if (isDef(maxlength) && getStringLength(value) > maxlength) {
- const modelValue = getModelValue();
- if (modelValue && getStringLength(modelValue) === +maxlength) {
- return modelValue;
- }
- return cutString(value, +maxlength);
- }
- return value;
- };
- const updateValue = (value, trigger = "onChange") => {
- const originalValue = value;
- value = limitValueLength(value);
- const isExceedLimit = value !== originalValue;
- if (props.type === "number" || props.type === "digit") {
- const isNumber = props.type === "number";
- value = formatNumber(value, isNumber, isNumber);
- }
- if (props.formatter && trigger === props.formatTrigger) {
- value = props.formatter(value);
- }
- if (inputRef.value && inputRef.value.value !== value) {
- if (state.focused && isExceedLimit) {
- const {
- selectionStart,
- selectionEnd
- } = inputRef.value;
- inputRef.value.value = value;
- inputRef.value.setSelectionRange(selectionStart - 1, selectionEnd - 1);
- } else {
- inputRef.value.value = value;
- }
- }
- if (value !== props.modelValue) {
- emit("update:modelValue", value);
- }
- };
- const onInput = (event) => {
- if (!event.target.composing) {
- updateValue(event.target.value);
- }
- };
- const blur = () => {
- var _a;
- return (_a = inputRef.value) == null ? void 0 : _a.blur();
- };
- const focus = () => {
- var _a;
- return (_a = inputRef.value) == null ? void 0 : _a.focus();
- };
- const adjustTextareaSize = () => {
- const input = inputRef.value;
- if (props.type === "textarea" && props.autosize && input) {
- resizeTextarea(input, props.autosize);
- }
- };
- const onFocus = (event) => {
- state.focused = true;
- emit("focus", event);
- nextTick(adjustTextareaSize);
- if (getProp("readonly")) {
- blur();
- }
- };
- const onBlur = (event) => {
- if (getProp("readonly")) {
- return;
- }
- state.focused = false;
- updateValue(getModelValue(), "onBlur");
- emit("blur", event);
- validateWithTrigger("onBlur");
- nextTick(adjustTextareaSize);
- resetScroll();
- };
- const onClickInput = (event) => emit("click-input", event);
- const onClickLeftIcon = (event) => emit("click-left-icon", event);
- const onClickRightIcon = (event) => emit("click-right-icon", event);
- const onClear = (event) => {
- preventDefault(event);
- emit("update:modelValue", "");
- emit("clear", event);
- };
- const showError = computed(() => {
- if (typeof props.error === "boolean") {
- return props.error;
- }
- if (form && form.props.showError && state.status === "failed") {
- return true;
- }
- });
- const labelStyle = computed(() => {
- const labelWidth = getProp("labelWidth");
- if (labelWidth) {
- return {
- width: addUnit(labelWidth)
- };
- }
- });
- const onKeypress = (event) => {
- const ENTER_CODE = 13;
- if (event.keyCode === ENTER_CODE) {
- const submitOnEnter = form && form.props.submitOnEnter;
- if (!submitOnEnter && props.type !== "textarea") {
- preventDefault(event);
- }
- if (props.type === "search") {
- blur();
- }
- }
- emit("keypress", event);
- };
- const getInputId = () => props.id || `${id}-input`;
- const getValidationStatus = () => state.status;
- const renderInput = () => {
- const controlClass = bem$1b("control", [getProp("inputAlign"), {
- error: showError.value,
- custom: !!slots.input,
- "min-height": props.type === "textarea" && !props.autosize
- }]);
- if (slots.input) {
- return createVNode("div", {
- "class": controlClass,
- "onClick": onClickInput
- }, [slots.input()]);
- }
- const inputAttrs = {
- id: getInputId(),
- ref: inputRef,
- name: props.name,
- rows: props.rows !== void 0 ? +props.rows : void 0,
- class: controlClass,
- disabled: getProp("disabled"),
- readonly: getProp("readonly"),
- autofocus: props.autofocus,
- placeholder: props.placeholder,
- autocomplete: props.autocomplete,
- enterkeyhint: props.enterkeyhint,
- "aria-labelledby": props.label ? `${id}-label` : void 0,
- onBlur,
- onFocus,
- onInput,
- onClick: onClickInput,
- onChange: endComposing,
- onKeypress,
- onCompositionend: endComposing,
- onCompositionstart: startComposing
- };
- if (props.type === "textarea") {
- return createVNode("textarea", inputAttrs, null);
- }
- return createVNode("input", mergeProps(mapInputType(props.type), inputAttrs), null);
- };
- const renderLeftIcon = () => {
- const leftIconSlot = slots["left-icon"];
- if (props.leftIcon || leftIconSlot) {
- return createVNode("div", {
- "class": bem$1b("left-icon"),
- "onClick": onClickLeftIcon
- }, [leftIconSlot ? leftIconSlot() : createVNode(Icon, {
- "name": props.leftIcon,
- "classPrefix": props.iconPrefix
- }, null)]);
- }
- };
- const renderRightIcon = () => {
- const rightIconSlot = slots["right-icon"];
- if (props.rightIcon || rightIconSlot) {
- return createVNode("div", {
- "class": bem$1b("right-icon"),
- "onClick": onClickRightIcon
- }, [rightIconSlot ? rightIconSlot() : createVNode(Icon, {
- "name": props.rightIcon,
- "classPrefix": props.iconPrefix
- }, null)]);
- }
- };
- const renderWordLimit = () => {
- if (props.showWordLimit && props.maxlength) {
- const count = getStringLength(getModelValue());
- return createVNode("div", {
- "class": bem$1b("word-limit")
- }, [createVNode("span", {
- "class": bem$1b("word-num")
- }, [count]), createTextVNode("/"), props.maxlength]);
- }
- };
- const renderMessage = () => {
- if (form && form.props.showErrorMessage === false) {
- return;
- }
- const message = props.errorMessage || state.validateMessage;
- if (message) {
- const slot = slots["error-message"];
- const errorMessageAlign = getProp("errorMessageAlign");
- return createVNode("div", {
- "class": bem$1b("error-message", errorMessageAlign)
- }, [slot ? slot({
- message
- }) : message]);
- }
- };
- const renderLabel = () => {
- const colon = getProp("colon") ? ":" : "";
- if (slots.label) {
- return [slots.label(), colon];
- }
- if (props.label) {
- return createVNode("label", {
- "id": `${id}-label`,
- "for": getInputId()
- }, [props.label + colon]);
- }
- };
- const renderFieldBody = () => [createVNode("div", {
- "class": bem$1b("body")
- }, [renderInput(), showClear.value && createVNode(Icon, {
- "ref": clearIconRef,
- "name": props.clearIcon,
- "class": bem$1b("clear")
- }, null), renderRightIcon(), slots.button && createVNode("div", {
- "class": bem$1b("button")
- }, [slots.button()])]), renderWordLimit(), renderMessage()];
- useExpose({
- blur,
- focus,
- validate,
- formValue,
- resetValidation,
- getValidationStatus
- });
- provide(CUSTOM_FIELD_INJECTION_KEY, {
- customValue,
- resetValidation,
- validateWithTrigger
- });
- watch(() => props.modelValue, () => {
- updateValue(getModelValue());
- resetValidation();
- validateWithTrigger("onChange");
- nextTick(adjustTextareaSize);
- });
- onMounted(() => {
- updateValue(getModelValue(), props.formatTrigger);
- nextTick(adjustTextareaSize);
- });
- useEventListener("touchstart", onClear, {
- target: computed(() => {
- var _a;
- return (_a = clearIconRef.value) == null ? void 0 : _a.$el;
- })
- });
- return () => {
- const disabled = getProp("disabled");
- const labelAlign = getProp("labelAlign");
- const Label = renderLabel();
- const LeftIcon = renderLeftIcon();
- return createVNode(Cell, {
- "size": props.size,
- "icon": props.leftIcon,
- "class": bem$1b({
- error: showError.value,
- disabled,
- [`label-${labelAlign}`]: labelAlign
- }),
- "center": props.center,
- "border": props.border,
- "isLink": props.isLink,
- "clickable": props.clickable,
- "titleStyle": labelStyle.value,
- "valueClass": bem$1b("value"),
- "titleClass": [bem$1b("label", [labelAlign, {
- required: props.required
- }]), props.labelClass],
- "arrowDirection": props.arrowDirection
- }, {
- icon: LeftIcon ? () => LeftIcon : null,
- title: Label ? () => Label : null,
- value: renderFieldBody,
- extra: slots.extra
- });
- };
- }
- });
- const Field = withInstall(stdin_default$1m);
- function usePopupState() {
- const state = reactive({
- show: false
- });
- const toggle = (show) => {
- state.show = show;
- };
- const open = (props) => {
- extend(state, props, { transitionAppear: true });
- toggle(true);
- };
- const close = () => toggle(false);
- useExpose({ open, close, toggle });
- return {
- open,
- close,
- state,
- toggle
- };
- }
- function mountComponent(RootComponent) {
- const app = createApp(RootComponent);
- const root = document.createElement("div");
- document.body.appendChild(root);
- return {
- instance: app.mount(root),
- unmount() {
- app.unmount();
- document.body.removeChild(root);
- }
- };
- }
- let lockCount = 0;
- function lockClick(lock) {
- if (lock) {
- if (!lockCount) {
- document.body.classList.add("van-toast--unclickable");
- }
- lockCount++;
- } else if (lockCount) {
- lockCount--;
- if (!lockCount) {
- document.body.classList.remove("van-toast--unclickable");
- }
- }
- }
- const [name$1e, bem$1a] = createNamespace("toast");
- const popupInheritProps = ["show", "overlay", "teleport", "transition", "overlayClass", "overlayStyle", "closeOnClickOverlay"];
- const toastProps = {
- icon: String,
- show: Boolean,
- type: makeStringProp("text"),
- overlay: Boolean,
- message: numericProp,
- iconSize: numericProp,
- duration: makeNumberProp(2e3),
- position: makeStringProp("middle"),
- teleport: [String, Object],
- className: unknownProp,
- iconPrefix: String,
- transition: makeStringProp("van-fade"),
- loadingType: String,
- forbidClick: Boolean,
- overlayClass: unknownProp,
- overlayStyle: Object,
- closeOnClick: Boolean,
- closeOnClickOverlay: Boolean
- };
- var stdin_default$1l = defineComponent({
- name: name$1e,
- props: toastProps,
- emits: ["update:show"],
- setup(props, {
- emit
- }) {
- let timer2;
- let clickable = false;
- const toggleClickable = () => {
- const newValue = props.show && props.forbidClick;
- if (clickable !== newValue) {
- clickable = newValue;
- lockClick(clickable);
- }
- };
- const updateShow = (show) => emit("update:show", show);
- const onClick = () => {
- if (props.closeOnClick) {
- updateShow(false);
- }
- };
- const clearTimer = () => clearTimeout(timer2);
- const renderIcon = () => {
- const {
- icon,
- type,
- iconSize,
- iconPrefix,
- loadingType
- } = props;
- const hasIcon = icon || type === "success" || type === "fail";
- if (hasIcon) {
- return createVNode(Icon, {
- "name": icon || type,
- "size": iconSize,
- "class": bem$1a("icon"),
- "classPrefix": iconPrefix
- }, null);
- }
- if (type === "loading") {
- return createVNode(Loading, {
- "class": bem$1a("loading"),
- "size": iconSize,
- "type": loadingType
- }, null);
- }
- };
- const renderMessage = () => {
- const {
- type,
- message
- } = props;
- if (isDef(message) && message !== "") {
- return type === "html" ? createVNode("div", {
- "key": 0,
- "class": bem$1a("text"),
- "innerHTML": String(message)
- }, null) : createVNode("div", {
- "class": bem$1a("text")
- }, [message]);
- }
- };
- watch(() => [props.show, props.forbidClick], toggleClickable);
- watch(() => [props.show, props.type, props.message, props.duration], () => {
- clearTimer();
- if (props.show && props.duration > 0) {
- timer2 = setTimeout(() => {
- updateShow(false);
- }, props.duration);
- }
- });
- onMounted(toggleClickable);
- onUnmounted(toggleClickable);
- return () => createVNode(Popup, mergeProps({
- "class": [bem$1a([props.position, {
- [props.type]: !props.icon
- }]), props.className],
- "lockScroll": false,
- "onClick": onClick,
- "onClosed": clearTimer,
- "onUpdate:show": updateShow
- }, pick(props, popupInheritProps)), {
- default: () => [renderIcon(), renderMessage()]
- });
- }
- });
- const defaultOptions$1 = {
- icon: "",
- type: "text",
- message: "",
- className: "",
- overlay: false,
- onClose: void 0,
- onOpened: void 0,
- duration: 2e3,
- teleport: "body",
- iconSize: void 0,
- iconPrefix: void 0,
- position: "middle",
- transition: "van-fade",
- forbidClick: false,
- loadingType: void 0,
- overlayClass: "",
- overlayStyle: void 0,
- closeOnClick: false,
- closeOnClickOverlay: false
- };
- let queue = [];
- let allowMultiple = false;
- let currentOptions = extend({}, defaultOptions$1);
- const defaultOptionsMap = /* @__PURE__ */ new Map();
- function parseOptions$1(message) {
- if (isObject(message)) {
- return message;
- }
- return {
- message
- };
- }
- function createInstance() {
- const {
- instance: instance2,
- unmount
- } = mountComponent({
- setup() {
- const message = ref("");
- const {
- open,
- state,
- close,
- toggle
- } = usePopupState();
- const onClosed = () => {
- if (allowMultiple) {
- queue = queue.filter((item) => item !== instance2);
- unmount();
- }
- };
- const render = () => {
- const attrs = {
- onClosed,
- "onUpdate:show": toggle
- };
- return createVNode(stdin_default$1l, mergeProps(state, attrs), null);
- };
- watch(message, (val) => {
- state.message = val;
- });
- getCurrentInstance().render = render;
- return {
- open,
- clear: close,
- message
- };
- }
- });
- return instance2;
- }
- function getInstance() {
- if (!queue.length || allowMultiple) {
- const instance2 = createInstance();
- queue.push(instance2);
- }
- return queue[queue.length - 1];
- }
- function Toast(options = {}) {
- if (!inBrowser) {
- return {};
- }
- const toast = getInstance();
- const parsedOptions = parseOptions$1(options);
- toast.open(extend({}, currentOptions, defaultOptionsMap.get(parsedOptions.type || currentOptions.type), parsedOptions));
- return toast;
- }
- const createMethod = (type) => (options) => Toast(extend({
- type
- }, parseOptions$1(options)));
- Toast.loading = createMethod("loading");
- Toast.success = createMethod("success");
- Toast.fail = createMethod("fail");
- Toast.clear = (all) => {
- var _a;
- if (queue.length) {
- if (all) {
- queue.forEach((toast) => {
- toast.clear();
- });
- queue = [];
- } else if (!allowMultiple) {
- queue[0].clear();
- } else {
- (_a = queue.shift()) == null ? void 0 : _a.clear();
- }
- }
- };
- function setDefaultOptions(type, options) {
- if (typeof type === "string") {
- defaultOptionsMap.set(type, options);
- } else {
- extend(currentOptions, type);
- }
- }
- Toast.setDefaultOptions = setDefaultOptions;
- Toast.resetDefaultOptions = (type) => {
- if (typeof type === "string") {
- defaultOptionsMap.delete(type);
- } else {
- currentOptions = extend({}, defaultOptions$1);
- defaultOptionsMap.clear();
- }
- };
- Toast.allowMultiple = (value = true) => {
- allowMultiple = value;
- };
- Toast.install = (app) => {
- app.use(withInstall(stdin_default$1l));
- app.config.globalProperties.$toast = Toast;
- };
- const [name$1d, bem$19] = createNamespace("switch");
- const switchProps = {
- size: numericProp,
- loading: Boolean,
- disabled: Boolean,
- modelValue: unknownProp,
- activeColor: String,
- inactiveColor: String,
- activeValue: {
- type: unknownProp,
- default: true
- },
- inactiveValue: {
- type: unknownProp,
- default: false
- }
- };
- var stdin_default$1k = defineComponent({
- name: name$1d,
- props: switchProps,
- emits: ["change", "update:modelValue"],
- setup(props, {
- emit,
- slots
- }) {
- const isChecked = () => props.modelValue === props.activeValue;
- const onClick = () => {
- if (!props.disabled && !props.loading) {
- const newValue = isChecked() ? props.inactiveValue : props.activeValue;
- emit("update:modelValue", newValue);
- emit("change", newValue);
- }
- };
- const renderLoading = () => {
- if (props.loading) {
- const color = isChecked() ? props.activeColor : props.inactiveColor;
- return createVNode(Loading, {
- "class": bem$19("loading"),
- "color": color
- }, null);
- }
- if (slots.node) {
- return slots.node();
- }
- };
- useCustomFieldValue(() => props.modelValue);
- return () => {
- var _a;
- const {
- size,
- loading,
- disabled,
- activeColor,
- inactiveColor
- } = props;
- const checked = isChecked();
- const style = {
- fontSize: addUnit(size),
- backgroundColor: checked ? activeColor : inactiveColor
- };
- return createVNode("div", {
- "role": "switch",
- "class": bem$19({
- on: checked,
- loading,
- disabled
- }),
- "style": style,
- "tabindex": disabled ? void 0 : 0,
- "aria-checked": checked,
- "onClick": onClick
- }, [createVNode("div", {
- "class": bem$19("node")
- }, [renderLoading()]), (_a = slots.background) == null ? void 0 : _a.call(slots)]);
- };
- }
- });
- const Switch = withInstall(stdin_default$1k);
- const [name$1c, bem$18] = createNamespace("address-edit-detail");
- const t$i = createNamespace("address-edit")[2];
- var stdin_default$1j = defineComponent({
- name: name$1c,
- props: {
- show: Boolean,
- rows: numericProp,
- value: String,
- rules: Array,
- focused: Boolean,
- maxlength: numericProp,
- searchResult: Array,
- showSearchResult: Boolean
- },
- emits: ["blur", "focus", "input", "select-search"],
- setup(props, {
- emit
- }) {
- const field = ref();
- const showSearchResult = () => props.focused && props.searchResult && props.showSearchResult;
- const onSelect = (express) => {
- emit("select-search", express);
- emit("input", `${express.address || ""} ${express.name || ""}`.trim());
- };
- const renderSearchTitle = (express) => {
- if (express.name) {
- const text = express.name.replace(props.value, `<span class=${bem$18("keyword")}>${props.value}</span>`);
- return createVNode("div", {
- "innerHTML": text
- }, null);
- }
- };
- const renderSearchResult = () => {
- if (!showSearchResult()) {
- return;
- }
- const {
- searchResult
- } = props;
- return searchResult.map((express) => createVNode(Cell, {
- "clickable": true,
- "key": express.name + express.address,
- "icon": "location-o",
- "label": express.address,
- "class": bem$18("search-item"),
- "border": false,
- "onClick": () => onSelect(express)
- }, {
- title: () => renderSearchTitle(express)
- }));
- };
- const onBlur = (event) => emit("blur", event);
- const onFocus = (event) => emit("focus", event);
- const onInput = (value) => emit("input", value);
- return () => {
- if (props.show) {
- return createVNode(Fragment, null, [createVNode(Field, {
- "autosize": true,
- "clearable": true,
- "ref": field,
- "class": bem$18(),
- "rows": props.rows,
- "type": "textarea",
- "rules": props.rules,
- "label": t$i("addressDetail"),
- "border": !showSearchResult(),
- "maxlength": props.maxlength,
- "modelValue": props.value,
- "placeholder": t$i("addressDetail"),
- "onBlur": onBlur,
- "onFocus": onFocus,
- "onUpdate:modelValue": onInput
- }, null), renderSearchResult()]);
- }
- };
- }
- });
- const [name$1b, bem$17, t$h] = createNamespace("address-edit");
- const DEFAULT_DATA = {
- name: "",
- tel: "",
- city: "",
- county: "",
- country: "",
- province: "",
- areaCode: "",
- isDefault: false,
- postalCode: "",
- addressDetail: ""
- };
- const isPostal = (value) => /^\d{6}$/.test(value);
- const addressEditProps = {
- areaList: Object,
- isSaving: Boolean,
- isDeleting: Boolean,
- validator: Function,
- showArea: truthProp,
- showDetail: truthProp,
- showDelete: Boolean,
- showPostal: Boolean,
- disableArea: Boolean,
- searchResult: Array,
- telMaxlength: numericProp,
- showSetDefault: Boolean,
- saveButtonText: String,
- areaPlaceholder: String,
- deleteButtonText: String,
- showSearchResult: Boolean,
- detailRows: makeNumericProp(1),
- detailMaxlength: makeNumericProp(200),
- areaColumnsPlaceholder: makeArrayProp(),
- addressInfo: {
- type: Object,
- default: () => extend({}, DEFAULT_DATA)
- },
- telValidator: {
- type: Function,
- default: isMobile
- },
- postalValidator: {
- type: Function,
- default: isPostal
- }
- };
- var stdin_default$1i = defineComponent({
- name: name$1b,
- props: addressEditProps,
- emits: ["save", "focus", "delete", "click-area", "change-area", "change-detail", "select-search", "change-default"],
- setup(props, {
- emit,
- slots
- }) {
- const areaRef = ref();
- const data = reactive({});
- const showAreaPopup = ref(false);
- const detailFocused = ref(false);
- const areaListLoaded = computed(() => isObject(props.areaList) && Object.keys(props.areaList).length);
- const areaText = computed(() => {
- const {
- country,
- province,
- city,
- county,
- areaCode
- } = data;
- if (areaCode) {
- const arr = [country, province, city, county];
- if (province && province === city) {
- arr.splice(1, 1);
- }
- return arr.filter(Boolean).join("/");
- }
- return "";
- });
- const hideBottomFields = computed(() => {
- var _a;
- return ((_a = props.searchResult) == null ? void 0 : _a.length) && detailFocused.value;
- });
- const assignAreaValues = () => {
- if (areaRef.value) {
- const detail = areaRef.value.getArea();
- detail.areaCode = detail.code;
- delete detail.code;
- extend(data, detail);
- }
- };
- const onFocus = (key) => {
- detailFocused.value = key === "addressDetail";
- emit("focus", key);
- };
- const rules = computed(() => {
- const {
- validator,
- telValidator,
- postalValidator
- } = props;
- const makeRule = (name2, emptyMessage) => ({
- validator: (value) => {
- if (validator) {
- const message = validator(name2, value);
- if (message) {
- return message;
- }
- }
- if (!value) {
- return emptyMessage;
- }
- return true;
- }
- });
- return {
- name: [makeRule("name", t$h("nameEmpty"))],
- tel: [makeRule("tel", t$h("telInvalid")), {
- validator: telValidator,
- message: t$h("telInvalid")
- }],
- areaCode: [makeRule("areaCode", t$h("areaEmpty"))],
- addressDetail: [makeRule("addressDetail", t$h("addressEmpty"))],
- postalCode: [makeRule("addressDetail", t$h("postalEmpty")), {
- validator: postalValidator,
- message: t$h("postalEmpty")
- }]
- };
- });
- const onSave = () => emit("save", data);
- const onChangeDetail = (val) => {
- data.addressDetail = val;
- emit("change-detail", val);
- };
- const onAreaConfirm = (values) => {
- values = values.filter(Boolean);
- if (values.some((value) => !value.code)) {
- Toast(t$h("areaEmpty"));
- } else {
- showAreaPopup.value = false;
- assignAreaValues();
- emit("change-area", values);
- }
- };
- const onDelete = () => emit("delete", data);
- const getArea = () => {
- var _a;
- return ((_a = areaRef.value) == null ? void 0 : _a.getValues()) || [];
- };
- const setAreaCode = (code) => {
- data.areaCode = code || "";
- if (code) {
- nextTick(assignAreaValues);
- }
- };
- const onDetailBlur = () => {
- setTimeout(() => {
- detailFocused.value = false;
- });
- };
- const setAddressDetail = (value) => {
- data.addressDetail = value;
- };
- const renderSetDefaultCell = () => {
- if (props.showSetDefault) {
- const slots2 = {
- "right-icon": () => createVNode(Switch, {
- "modelValue": data.isDefault,
- "onUpdate:modelValue": ($event) => data.isDefault = $event,
- "size": "24",
- "onChange": (event) => emit("change-default", event)
- }, null)
- };
- return withDirectives(createVNode(Cell, {
- "center": true,
- "title": t$h("defaultAddress"),
- "class": bem$17("default")
- }, slots2), [[vShow, !hideBottomFields.value]]);
- }
- };
- useExpose({
- getArea,
- setAreaCode,
- setAddressDetail
- });
- watch(() => props.areaList, () => setAreaCode(data.areaCode));
- watch(() => props.addressInfo, (value) => {
- extend(data, DEFAULT_DATA, value);
- setAreaCode(value.areaCode);
- }, {
- deep: true,
- immediate: true
- });
- return () => {
- const {
- disableArea
- } = props;
- return createVNode(Form, {
- "class": bem$17(),
- "onSubmit": onSave
- }, {
- default: () => {
- var _a;
- return [createVNode("div", {
- "class": bem$17("fields")
- }, [createVNode(Field, {
- "modelValue": data.name,
- "onUpdate:modelValue": ($event) => data.name = $event,
- "clearable": true,
- "label": t$h("name"),
- "rules": rules.value.name,
- "placeholder": t$h("name"),
- "onFocus": () => onFocus("name")
- }, null), createVNode(Field, {
- "modelValue": data.tel,
- "onUpdate:modelValue": ($event) => data.tel = $event,
- "clearable": true,
- "type": "tel",
- "label": t$h("tel"),
- "rules": rules.value.tel,
- "maxlength": props.telMaxlength,
- "placeholder": t$h("tel"),
- "onFocus": () => onFocus("tel")
- }, null), withDirectives(createVNode(Field, {
- "readonly": true,
- "label": t$h("area"),
- "is-link": !disableArea,
- "modelValue": areaText.value,
- "rules": rules.value.areaCode,
- "placeholder": props.areaPlaceholder || t$h("area"),
- "onFocus": () => onFocus("areaCode"),
- "onClick": () => {
- emit("click-area");
- showAreaPopup.value = !disableArea;
- }
- }, null), [[vShow, props.showArea]]), createVNode(stdin_default$1j, {
- "show": props.showDetail,
- "rows": props.detailRows,
- "rules": rules.value.addressDetail,
- "value": data.addressDetail,
- "focused": detailFocused.value,
- "maxlength": props.detailMaxlength,
- "searchResult": props.searchResult,
- "showSearchResult": props.showSearchResult,
- "onBlur": onDetailBlur,
- "onFocus": () => onFocus("addressDetail"),
- "onInput": onChangeDetail,
- "onSelect-search": (event) => emit("select-search", event)
- }, null), props.showPostal && withDirectives(createVNode(Field, {
- "modelValue": data.postalCode,
- "onUpdate:modelValue": ($event) => data.postalCode = $event,
- "type": "tel",
- "rules": rules.value.postalCode,
- "label": t$h("postal"),
- "maxlength": "6",
- "placeholder": t$h("postal"),
- "onFocus": () => onFocus("postalCode")
- }, null), [[vShow, !hideBottomFields.value]]), (_a = slots.default) == null ? void 0 : _a.call(slots)]), renderSetDefaultCell(), withDirectives(createVNode("div", {
- "class": bem$17("buttons")
- }, [createVNode(Button, {
- "block": true,
- "round": true,
- "type": "danger",
- "text": props.saveButtonText || t$h("save"),
- "class": bem$17("button"),
- "loading": props.isSaving,
- "nativeType": "submit"
- }, null), props.showDelete && createVNode(Button, {
- "block": true,
- "round": true,
- "class": bem$17("button"),
- "loading": props.isDeleting,
- "text": props.deleteButtonText || t$h("delete"),
- "onClick": onDelete
- }, null)]), [[vShow, !hideBottomFields.value]]), createVNode(Popup, {
- "show": showAreaPopup.value,
- "onUpdate:show": ($event) => showAreaPopup.value = $event,
- "round": true,
- "teleport": "body",
- "position": "bottom",
- "lazyRender": false
- }, {
- default: () => [createVNode(Area, {
- "ref": areaRef,
- "value": data.areaCode,
- "loading": !areaListLoaded.value,
- "areaList": props.areaList,
- "columnsPlaceholder": props.areaColumnsPlaceholder,
- "onConfirm": onAreaConfirm,
- "onCancel": () => {
- showAreaPopup.value = false;
- }
- }, null)]
- })];
- }
- });
- };
- }
- });
- const AddressEdit = withInstall(stdin_default$1i);
- const [name$1a, bem$16] = createNamespace("radio-group");
- const radioGroupProps = {
- disabled: Boolean,
- iconSize: numericProp,
- direction: String,
- modelValue: unknownProp,
- checkedColor: String
- };
- const RADIO_KEY = Symbol(name$1a);
- var stdin_default$1h = defineComponent({
- name: name$1a,
- props: radioGroupProps,
- emits: ["change", "update:modelValue"],
- setup(props, {
- emit,
- slots
- }) {
- const {
- linkChildren
- } = useChildren(RADIO_KEY);
- const updateValue = (value) => emit("update:modelValue", value);
- watch(() => props.modelValue, (value) => emit("change", value));
- linkChildren({
- props,
- updateValue
- });
- useCustomFieldValue(() => props.modelValue);
- return () => {
- var _a;
- return createVNode("div", {
- "class": bem$16([props.direction]),
- "role": "radiogroup"
- }, [(_a = slots.default) == null ? void 0 : _a.call(slots)]);
- };
- }
- });
- const RadioGroup = withInstall(stdin_default$1h);
- const [name$19, bem$15] = createNamespace("tag");
- const tagProps = {
- size: String,
- mark: Boolean,
- show: truthProp,
- type: makeStringProp("default"),
- color: String,
- plain: Boolean,
- round: Boolean,
- textColor: String,
- closeable: Boolean
- };
- var stdin_default$1g = defineComponent({
- name: name$19,
- props: tagProps,
- emits: ["close"],
- setup(props, {
- slots,
- emit
- }) {
- const onClose = (event) => {
- event.stopPropagation();
- emit("close", event);
- };
- const getStyle = () => {
- if (props.plain) {
- return {
- color: props.textColor || props.color,
- borderColor: props.color
- };
- }
- return {
- color: props.textColor,
- background: props.color
- };
- };
- const renderTag = () => {
- var _a;
- const {
- type,
- mark,
- plain,
- round,
- size,
- closeable
- } = props;
- const classes = {
- mark,
- plain,
- round
- };
- if (size) {
- classes[size] = size;
- }
- const CloseIcon = closeable && createVNode(Icon, {
- "name": "cross",
- "class": [bem$15("close"), HAPTICS_FEEDBACK],
- "onClick": onClose
- }, null);
- return createVNode("span", {
- "style": getStyle(),
- "class": bem$15([classes, type])
- }, [(_a = slots.default) == null ? void 0 : _a.call(slots), CloseIcon]);
- };
- return () => createVNode(Transition, {
- "name": props.closeable ? "van-fade" : void 0
- }, {
- default: () => [props.show ? renderTag() : null]
- });
- }
- });
- const Tag = withInstall(stdin_default$1g);
- const checkerProps = {
- name: unknownProp,
- shape: makeStringProp("round"),
- disabled: Boolean,
- iconSize: numericProp,
- modelValue: unknownProp,
- checkedColor: String,
- labelPosition: String,
- labelDisabled: Boolean
- };
- var stdin_default$1f = defineComponent({
- props: extend({}, checkerProps, {
- bem: makeRequiredProp(Function),
- role: String,
- parent: Object,
- checked: Boolean,
- bindGroup: truthProp
- }),
- emits: ["click", "toggle"],
- setup(props, {
- emit,
- slots
- }) {
- const iconRef = ref();
- const getParentProp = (name2) => {
- if (props.parent && props.bindGroup) {
- return props.parent.props[name2];
- }
- };
- const disabled = computed(() => getParentProp("disabled") || props.disabled);
- const direction = computed(() => getParentProp("direction"));
- const iconStyle = computed(() => {
- const checkedColor = props.checkedColor || getParentProp("checkedColor");
- if (checkedColor && props.checked && !disabled.value) {
- return {
- borderColor: checkedColor,
- backgroundColor: checkedColor
- };
- }
- });
- const onClick = (event) => {
- const {
- target
- } = event;
- const icon = iconRef.value;
- const iconClicked = icon === target || (icon == null ? void 0 : icon.contains(target));
- if (!disabled.value && (iconClicked || !props.labelDisabled)) {
- emit("toggle");
- }
- emit("click", event);
- };
- const renderIcon = () => {
- const {
- bem: bem2,
- shape,
- checked
- } = props;
- const iconSize = props.iconSize || getParentProp("iconSize");
- return createVNode("div", {
- "ref": iconRef,
- "class": bem2("icon", [shape, {
- disabled: disabled.value,
- checked
- }]),
- "style": {
- fontSize: addUnit(iconSize)
- }
- }, [slots.icon ? slots.icon({
- checked,
- disabled: disabled.value
- }) : createVNode(Icon, {
- "name": "success",
- "style": iconStyle.value
- }, null)]);
- };
- const renderLabel = () => {
- if (slots.default) {
- return createVNode("span", {
- "class": props.bem("label", [props.labelPosition, {
- disabled: disabled.value
- }])
- }, [slots.default()]);
- }
- };
- return () => {
- const nodes = props.labelPosition === "left" ? [renderLabel(), renderIcon()] : [renderIcon(), renderLabel()];
- return createVNode("div", {
- "role": props.role,
- "class": props.bem([{
- disabled: disabled.value,
- "label-disabled": props.labelDisabled
- }, direction.value]),
- "tabindex": disabled.value ? void 0 : 0,
- "aria-checked": props.checked,
- "onClick": onClick
- }, [nodes]);
- };
- }
- });
- const [name$18, bem$14] = createNamespace("radio");
- var stdin_default$1e = defineComponent({
- name: name$18,
- props: checkerProps,
- emits: ["update:modelValue"],
- setup(props, {
- emit,
- slots
- }) {
- const {
- parent
- } = useParent(RADIO_KEY);
- const checked = () => {
- const value = parent ? parent.props.modelValue : props.modelValue;
- return value === props.name;
- };
- const toggle = () => {
- if (parent) {
- parent.updateValue(props.name);
- } else {
- emit("update:modelValue", props.name);
- }
- };
- return () => createVNode(stdin_default$1f, mergeProps({
- "bem": bem$14,
- "role": "radio",
- "parent": parent,
- "checked": checked(),
- "onToggle": toggle
- }, props), pick(slots, ["default", "icon"]));
- }
- });
- const Radio = withInstall(stdin_default$1e);
- const [name$17, bem$13] = createNamespace("address-item");
- var stdin_default$1d = defineComponent({
- name: name$17,
- props: {
- address: makeRequiredProp(Object),
- disabled: Boolean,
- switchable: Boolean,
- defaultTagText: String
- },
- emits: ["edit", "click", "select"],
- setup(props, {
- slots,
- emit
- }) {
- const onClick = () => {
- if (props.switchable) {
- emit("select");
- }
- emit("click");
- };
- const renderRightIcon = () => createVNode(Icon, {
- "name": "edit",
- "class": bem$13("edit"),
- "onClick": (event) => {
- event.stopPropagation();
- emit("edit");
- emit("click");
- }
- }, null);
- const renderTag = () => {
- if (slots.tag) {
- return slots.tag(props.address);
- }
- if (props.address.isDefault && props.defaultTagText) {
- return createVNode(Tag, {
- "type": "danger",
- "round": true,
- "class": bem$13("tag")
- }, {
- default: () => [props.defaultTagText]
- });
- }
- };
- const renderContent = () => {
- const {
- address,
- disabled,
- switchable
- } = props;
- const Info = [createVNode("div", {
- "class": bem$13("name")
- }, [`${address.name} ${address.tel}`, renderTag()]), createVNode("div", {
- "class": bem$13("address")
- }, [address.address])];
- if (switchable && !disabled) {
- return createVNode(Radio, {
- "name": address.id,
- "iconSize": 18
- }, {
- default: () => [Info]
- });
- }
- return Info;
- };
- return () => {
- var _a;
- const {
- disabled
- } = props;
- return createVNode("div", {
- "class": bem$13({
- disabled
- }),
- "onClick": onClick
- }, [createVNode(Cell, {
- "border": false,
- "valueClass": bem$13("value")
- }, {
- value: renderContent,
- "right-icon": renderRightIcon
- }), (_a = slots.bottom) == null ? void 0 : _a.call(slots, extend({}, props.address, {
- disabled
- }))]);
- };
- }
- });
- const [name$16, bem$12, t$g] = createNamespace("address-list");
- const addressListProps = {
- list: makeArrayProp(),
- modelValue: numericProp,
- switchable: truthProp,
- disabledText: String,
- disabledList: makeArrayProp(),
- addButtonText: String,
- defaultTagText: String
- };
- var stdin_default$1c = defineComponent({
- name: name$16,
- props: addressListProps,
- emits: ["add", "edit", "select", "click-item", "edit-disabled", "select-disabled", "update:modelValue"],
- setup(props, {
- slots,
- emit
- }) {
- const renderItem = (item, index, disabled) => {
- const onEdit = () => emit(disabled ? "edit-disabled" : "edit", item, index);
- const onClick = () => emit("click-item", item, index);
- const onSelect = () => {
- emit(disabled ? "select-disabled" : "select", item, index);
- if (!disabled) {
- emit("update:modelValue", item.id);
- }
- };
- return createVNode(stdin_default$1d, {
- "key": item.id,
- "address": item,
- "disabled": disabled,
- "switchable": props.switchable,
- "defaultTagText": props.defaultTagText,
- "onEdit": onEdit,
- "onClick": onClick,
- "onSelect": onSelect
- }, {
- bottom: slots["item-bottom"],
- tag: slots.tag
- });
- };
- const renderList = (list, disabled) => {
- if (list) {
- return list.map((item, index) => renderItem(item, index, disabled));
- }
- };
- const renderBottom = () => createVNode("div", {
- "class": [bem$12("bottom"), "van-safe-area-bottom"]
- }, [createVNode(Button, {
- "round": true,
- "block": true,
- "type": "danger",
- "text": props.addButtonText || t$g("add"),
- "class": bem$12("add"),
- "onClick": () => emit("add")
- }, null)]);
- return () => {
- var _a, _b;
- const List2 = renderList(props.list);
- const DisabledList = renderList(props.disabledList, true);
- const DisabledText = props.disabledText && createVNode("div", {
- "class": bem$12("disabled-text")
- }, [props.disabledText]);
- return createVNode("div", {
- "class": bem$12()
- }, [(_a = slots.top) == null ? void 0 : _a.call(slots), createVNode(RadioGroup, {
- "modelValue": props.modelValue
- }, {
- default: () => [List2]
- }), DisabledText, DisabledList, (_b = slots.default) == null ? void 0 : _b.call(slots), renderBottom()]);
- };
- }
- });
- const AddressList = withInstall(stdin_default$1c);
- const [name$15, bem$11, t$f] = createNamespace("calendar");
- const formatMonthTitle = (date) => t$f("monthTitle", date.getFullYear(), date.getMonth() + 1);
- function compareMonth(date1, date2) {
- const year1 = date1.getFullYear();
- const year2 = date2.getFullYear();
- if (year1 === year2) {
- const month1 = date1.getMonth();
- const month2 = date2.getMonth();
- return month1 === month2 ? 0 : month1 > month2 ? 1 : -1;
- }
- return year1 > year2 ? 1 : -1;
- }
- function compareDay(day1, day2) {
- const compareMonthResult = compareMonth(day1, day2);
- if (compareMonthResult === 0) {
- const date1 = day1.getDate();
- const date2 = day2.getDate();
- return date1 === date2 ? 0 : date1 > date2 ? 1 : -1;
- }
- return compareMonthResult;
- }
- const cloneDate = (date) => new Date(date);
- const cloneDates = (dates) => Array.isArray(dates) ? dates.map(cloneDate) : cloneDate(dates);
- function getDayByOffset(date, offset) {
- const cloned = cloneDate(date);
- cloned.setDate(cloned.getDate() + offset);
- return cloned;
- }
- const getPrevDay = (date) => getDayByOffset(date, -1);
- const getNextDay = (date) => getDayByOffset(date, 1);
- const getToday = () => {
- const today = new Date();
- today.setHours(0, 0, 0, 0);
- return today;
- };
- function calcDateNum(date) {
- const day1 = date[0].getTime();
- const day2 = date[1].getTime();
- return (day2 - day1) / (1e3 * 60 * 60 * 24) + 1;
- }
- function useRefs() {
- const refs = ref([]);
- const cache = [];
- onBeforeUpdate(() => {
- refs.value = [];
- });
- const setRefs = (index) => {
- if (!cache[index]) {
- cache[index] = (el) => {
- refs.value[index] = el;
- };
- }
- return cache[index];
- };
- return [refs, setRefs];
- }
- const sharedProps = extend({}, pickerSharedProps, {
- filter: Function,
- columnsOrder: Array,
- formatter: {
- type: Function,
- default: (type, value) => value
- }
- });
- const pickerInheritKeys = Object.keys(pickerSharedProps);
- function times(n, iteratee) {
- if (n < 0) {
- return [];
- }
- const result = Array(n);
- let index = -1;
- while (++index < n) {
- result[index] = iteratee(index);
- }
- return result;
- }
- function getTrueValue(value) {
- if (!value) {
- return 0;
- }
- while (Number.isNaN(parseInt(value, 10))) {
- if (value.length > 1) {
- value = value.slice(1);
- } else {
- return 0;
- }
- }
- return parseInt(value, 10);
- }
- const getMonthEndDay = (year, month) => 32 - new Date(year, month - 1, 32).getDate();
- const proxyPickerMethods = (picker, callback) => {
- const methods = [
- "setValues",
- "setIndexes",
- "setColumnIndex",
- "setColumnValue"
- ];
- return new Proxy(picker, {
- get: (target, prop) => {
- if (methods.includes(prop)) {
- return (...args) => {
- target[prop](...args);
- callback();
- };
- }
- return target[prop];
- }
- });
- };
- const [name$14] = createNamespace("calendar-day");
- var stdin_default$1b = defineComponent({
- name: name$14,
- props: {
- item: makeRequiredProp(Object),
- color: String,
- index: Number,
- offset: makeNumberProp(0),
- rowHeight: String
- },
- emits: ["click"],
- setup(props, {
- emit,
- slots
- }) {
- const style = computed(() => {
- var _a;
- const {
- item,
- index,
- color,
- offset,
- rowHeight
- } = props;
- const style2 = {
- height: rowHeight
- };
- if (item.type === "placeholder") {
- style2.width = "100%";
- return style2;
- }
- if (index === 0) {
- style2.marginLeft = `${100 * offset / 7}%`;
- }
- if (color) {
- switch (item.type) {
- case "end":
- case "start":
- case "start-end":
- case "multiple-middle":
- case "multiple-selected":
- style2.background = color;
- break;
- case "middle":
- style2.color = color;
- break;
- }
- }
- if (offset + (((_a = item.date) == null ? void 0 : _a.getDate()) || 1) > 28) {
- style2.marginBottom = 0;
- }
- return style2;
- });
- const onClick = () => {
- if (props.item.type !== "disabled") {
- emit("click", props.item);
- }
- };
- const renderTopInfo = () => {
- const {
- topInfo
- } = props.item;
- if (topInfo || slots["top-info"]) {
- return createVNode("div", {
- "class": bem$11("top-info")
- }, [slots["top-info"] ? slots["top-info"](props.item) : topInfo]);
- }
- };
- const renderBottomInfo = () => {
- const {
- bottomInfo
- } = props.item;
- if (bottomInfo || slots["bottom-info"]) {
- return createVNode("div", {
- "class": bem$11("bottom-info")
- }, [slots["bottom-info"] ? slots["bottom-info"](props.item) : bottomInfo]);
- }
- };
- const renderContent = () => {
- const {
- item,
- color,
- rowHeight
- } = props;
- const {
- type,
- text
- } = item;
- const Nodes = [renderTopInfo(), text, renderBottomInfo()];
- if (type === "selected") {
- return createVNode("div", {
- "class": bem$11("selected-day"),
- "style": {
- width: rowHeight,
- height: rowHeight,
- background: color
- }
- }, [Nodes]);
- }
- return Nodes;
- };
- return () => {
- const {
- type,
- className
- } = props.item;
- if (type === "placeholder") {
- return createVNode("div", {
- "class": bem$11("day"),
- "style": style.value
- }, null);
- }
- return createVNode("div", {
- "role": "gridcell",
- "style": style.value,
- "class": [bem$11("day", type), className],
- "tabindex": type === "disabled" ? void 0 : -1,
- "onClick": onClick
- }, [renderContent()]);
- };
- }
- });
- const [name$13] = createNamespace("calendar-month");
- const calendarMonthProps = {
- date: makeRequiredProp(Date),
- type: String,
- color: String,
- minDate: makeRequiredProp(Date),
- maxDate: makeRequiredProp(Date),
- showMark: Boolean,
- rowHeight: numericProp,
- formatter: Function,
- lazyRender: Boolean,
- currentDate: [Date, Array],
- allowSameDay: Boolean,
- showSubtitle: Boolean,
- showMonthTitle: Boolean,
- firstDayOfWeek: Number
- };
- var stdin_default$1a = defineComponent({
- name: name$13,
- props: calendarMonthProps,
- emits: ["click", "update-height"],
- setup(props, {
- emit,
- slots
- }) {
- const [visible, setVisible] = useToggle();
- const daysRef = ref();
- const monthRef = ref();
- const height = useHeight(monthRef);
- const title = computed(() => formatMonthTitle(props.date));
- const rowHeight = computed(() => addUnit(props.rowHeight));
- const offset = computed(() => {
- const realDay = props.date.getDay();
- if (props.firstDayOfWeek) {
- return (realDay + 7 - props.firstDayOfWeek) % 7;
- }
- return realDay;
- });
- const totalDay = computed(() => getMonthEndDay(props.date.getFullYear(), props.date.getMonth() + 1));
- const shouldRender = computed(() => visible.value || !props.lazyRender);
- const getTitle = () => title.value;
- const getMultipleDayType = (day) => {
- const isSelected = (date) => props.currentDate.some((item) => compareDay(item, date) === 0);
- if (isSelected(day)) {
- const prevDay = getPrevDay(day);
- const nextDay = getNextDay(day);
- const prevSelected = isSelected(prevDay);
- const nextSelected = isSelected(nextDay);
- if (prevSelected && nextSelected) {
- return "multiple-middle";
- }
- if (prevSelected) {
- return "end";
- }
- if (nextSelected) {
- return "start";
- }
- return "multiple-selected";
- }
- return "";
- };
- const getRangeDayType = (day) => {
- const [startDay, endDay] = props.currentDate;
- if (!startDay) {
- return "";
- }
- const compareToStart = compareDay(day, startDay);
- if (!endDay) {
- return compareToStart === 0 ? "start" : "";
- }
- const compareToEnd = compareDay(day, endDay);
- if (props.allowSameDay && compareToStart === 0 && compareToEnd === 0) {
- return "start-end";
- }
- if (compareToStart === 0) {
- return "start";
- }
- if (compareToEnd === 0) {
- return "end";
- }
- if (compareToStart > 0 && compareToEnd < 0) {
- return "middle";
- }
- return "";
- };
- const getDayType = (day) => {
- const {
- type,
- minDate,
- maxDate,
- currentDate
- } = props;
- if (compareDay(day, minDate) < 0 || compareDay(day, maxDate) > 0) {
- return "disabled";
- }
- if (currentDate === null) {
- return "";
- }
- if (Array.isArray(currentDate)) {
- if (type === "multiple") {
- return getMultipleDayType(day);
- }
- if (type === "range") {
- return getRangeDayType(day);
- }
- } else if (type === "single") {
- return compareDay(day, currentDate) === 0 ? "selected" : "";
- }
- return "";
- };
- const getBottomInfo = (dayType) => {
- if (props.type === "range") {
- if (dayType === "start" || dayType === "end") {
- return t$f(dayType);
- }
- if (dayType === "start-end") {
- return `${t$f("start")}/${t$f("end")}`;
- }
- }
- };
- const renderTitle = () => {
- if (props.showMonthTitle) {
- return createVNode("div", {
- "class": bem$11("month-title")
- }, [title.value]);
- }
- };
- const renderMark = () => {
- if (props.showMark && shouldRender.value) {
- return createVNode("div", {
- "class": bem$11("month-mark")
- }, [props.date.getMonth() + 1]);
- }
- };
- const placeholders = computed(() => {
- const count = Math.ceil((totalDay.value + offset.value) / 7);
- return Array(count).fill({
- type: "placeholder"
- });
- });
- const days = computed(() => {
- const days2 = [];
- const year = props.date.getFullYear();
- const month = props.date.getMonth();
- for (let day = 1; day <= totalDay.value; day++) {
- const date = new Date(year, month, day);
- const type = getDayType(date);
- let config = {
- date,
- type,
- text: day,
- bottomInfo: getBottomInfo(type)
- };
- if (props.formatter) {
- config = props.formatter(config);
- }
- days2.push(config);
- }
- return days2;
- });
- const disabledDays = computed(() => days.value.filter((day) => day.type === "disabled"));
- const scrollToDate = (body, targetDate) => {
- if (daysRef.value) {
- const daysRect = useRect(daysRef.value);
- const totalRows = placeholders.value.length;
- const currentRow = Math.ceil((targetDate.getDate() + offset.value) / 7);
- const rowOffset = (currentRow - 1) * daysRect.height / totalRows;
- setScrollTop(body, daysRect.top + rowOffset + body.scrollTop - useRect(body).top);
- }
- };
- const renderDay = (item, index) => createVNode(stdin_default$1b, {
- "item": item,
- "index": index,
- "color": props.color,
- "offset": offset.value,
- "rowHeight": rowHeight.value,
- "onClick": (item2) => emit("click", item2)
- }, pick(slots, ["top-info", "bottom-info"]));
- const renderDays = () => createVNode("div", {
- "ref": daysRef,
- "role": "grid",
- "class": bem$11("days")
- }, [renderMark(), (shouldRender.value ? days : placeholders).value.map(renderDay)]);
- useExpose({
- getTitle,
- getHeight: () => height.value,
- setVisible,
- scrollToDate,
- disabledDays
- });
- return () => createVNode("div", {
- "class": bem$11("month"),
- "ref": monthRef
- }, [renderTitle(), renderDays()]);
- }
- });
- const [name$12] = createNamespace("calendar-header");
- var stdin_default$19 = defineComponent({
- name: name$12,
- props: {
- title: String,
- subtitle: String,
- showTitle: Boolean,
- showSubtitle: Boolean,
- firstDayOfWeek: Number
- },
- emits: ["click-subtitle"],
- setup(props, {
- slots,
- emit
- }) {
- const renderTitle = () => {
- if (props.showTitle) {
- const text = props.title || t$f("title");
- const title = slots.title ? slots.title() : text;
- return createVNode("div", {
- "class": bem$11("header-title")
- }, [title]);
- }
- };
- const onClickSubtitle = (event) => emit("click-subtitle", event);
- const renderSubtitle = () => {
- if (props.showSubtitle) {
- const title = slots.subtitle ? slots.subtitle() : props.subtitle;
- return createVNode("div", {
- "class": bem$11("header-subtitle"),
- "onClick": onClickSubtitle
- }, [title]);
- }
- };
- const renderWeekDays = () => {
- const {
- firstDayOfWeek
- } = props;
- const weekdays = t$f("weekdays");
- const renderWeekDays2 = [...weekdays.slice(firstDayOfWeek, 7), ...weekdays.slice(0, firstDayOfWeek)];
- return createVNode("div", {
- "class": bem$11("weekdays")
- }, [renderWeekDays2.map((text) => createVNode("span", {
- "class": bem$11("weekday")
- }, [text]))]);
- };
- return () => createVNode("div", {
- "class": bem$11("header")
- }, [renderTitle(), renderSubtitle(), renderWeekDays()]);
- }
- });
- const calendarProps = {
- show: Boolean,
- type: makeStringProp("single"),
- title: String,
- color: String,
- round: truthProp,
- readonly: Boolean,
- poppable: truthProp,
- maxRange: makeNumericProp(null),
- position: makeStringProp("bottom"),
- teleport: [String, Object],
- showMark: truthProp,
- showTitle: truthProp,
- formatter: Function,
- rowHeight: numericProp,
- confirmText: String,
- rangePrompt: String,
- lazyRender: truthProp,
- showConfirm: truthProp,
- defaultDate: [Date, Array],
- allowSameDay: Boolean,
- showSubtitle: truthProp,
- closeOnPopstate: truthProp,
- showRangePrompt: truthProp,
- confirmDisabledText: String,
- closeOnClickOverlay: truthProp,
- safeAreaInsetTop: Boolean,
- safeAreaInsetBottom: truthProp,
- minDate: {
- type: Date,
- validator: isDate,
- default: getToday
- },
- maxDate: {
- type: Date,
- validator: isDate,
- default: () => {
- const now = getToday();
- return new Date(now.getFullYear(), now.getMonth() + 6, now.getDate());
- }
- },
- firstDayOfWeek: {
- type: numericProp,
- default: 0,
- validator: (val) => val >= 0 && val <= 6
- }
- };
- var stdin_default$18 = defineComponent({
- name: name$15,
- props: calendarProps,
- emits: ["select", "confirm", "unselect", "month-show", "over-range", "update:show", "click-subtitle"],
- setup(props, {
- emit,
- slots
- }) {
- const limitDateRange = (date, minDate = props.minDate, maxDate = props.maxDate) => {
- if (compareDay(date, minDate) === -1) {
- return minDate;
- }
- if (compareDay(date, maxDate) === 1) {
- return maxDate;
- }
- return date;
- };
- const getInitialDate = (defaultDate = props.defaultDate) => {
- const {
- type,
- minDate,
- maxDate,
- allowSameDay
- } = props;
- if (defaultDate === null) {
- return defaultDate;
- }
- const now = getToday();
- if (type === "range") {
- if (!Array.isArray(defaultDate)) {
- defaultDate = [];
- }
- const start = limitDateRange(defaultDate[0] || now, minDate, allowSameDay ? maxDate : getPrevDay(maxDate));
- const end = limitDateRange(defaultDate[1] || now, allowSameDay ? minDate : getNextDay(minDate));
- return [start, end];
- }
- if (type === "multiple") {
- if (Array.isArray(defaultDate)) {
- return defaultDate.map((date) => limitDateRange(date));
- }
- return [limitDateRange(now)];
- }
- if (!defaultDate || Array.isArray(defaultDate)) {
- defaultDate = now;
- }
- return limitDateRange(defaultDate);
- };
- let bodyHeight;
- const bodyRef = ref();
- const subtitle = ref("");
- const currentDate = ref(getInitialDate());
- const [monthRefs, setMonthRefs] = useRefs();
- const dayOffset = computed(() => props.firstDayOfWeek ? +props.firstDayOfWeek % 7 : 0);
- const months = computed(() => {
- const months2 = [];
- const cursor = new Date(props.minDate);
- cursor.setDate(1);
- do {
- months2.push(new Date(cursor));
- cursor.setMonth(cursor.getMonth() + 1);
- } while (compareMonth(cursor, props.maxDate) !== 1);
- return months2;
- });
- const buttonDisabled = computed(() => {
- if (currentDate.value) {
- if (props.type === "range") {
- return !currentDate.value[0] || !currentDate.value[1];
- }
- if (props.type === "multiple") {
- return !currentDate.value.length;
- }
- }
- return !currentDate.value;
- });
- const getSelectedDate = () => currentDate.value;
- const onScroll = () => {
- const top = getScrollTop(bodyRef.value);
- const bottom = top + bodyHeight;
- const heights = months.value.map((item, index) => monthRefs.value[index].getHeight());
- const heightSum = heights.reduce((a, b) => a + b, 0);
- if (bottom > heightSum && top > 0) {
- return;
- }
- let height = 0;
- let currentMonth;
- const visibleRange = [-1, -1];
- for (let i = 0; i < months.value.length; i++) {
- const month = monthRefs.value[i];
- const visible = height <= bottom && height + heights[i] >= top;
- if (visible) {
- visibleRange[1] = i;
- if (!currentMonth) {
- currentMonth = month;
- visibleRange[0] = i;
- }
- if (!monthRefs.value[i].showed) {
- monthRefs.value[i].showed = true;
- emit("month-show", {
- date: month.date,
- title: month.getTitle()
- });
- }
- }
- height += heights[i];
- }
- months.value.forEach((month, index) => {
- const visible = index >= visibleRange[0] - 1 && index <= visibleRange[1] + 1;
- monthRefs.value[index].setVisible(visible);
- });
- if (currentMonth) {
- subtitle.value = currentMonth.getTitle();
- }
- };
- const scrollToDate = (targetDate) => {
- raf(() => {
- months.value.some((month, index) => {
- if (compareMonth(month, targetDate) === 0) {
- if (bodyRef.value) {
- monthRefs.value[index].scrollToDate(bodyRef.value, targetDate);
- }
- return true;
- }
- return false;
- });
- onScroll();
- });
- };
- const scrollToCurrentDate = () => {
- if (props.poppable && !props.show) {
- return;
- }
- if (currentDate.value) {
- const targetDate = props.type === "single" ? currentDate.value : currentDate.value[0];
- if (isDate(targetDate)) {
- scrollToDate(targetDate);
- }
- } else {
- raf(onScroll);
- }
- };
- const init = () => {
- if (props.poppable && !props.show) {
- return;
- }
- raf(() => {
- bodyHeight = Math.floor(useRect(bodyRef).height);
- });
- scrollToCurrentDate();
- };
- const reset = (date = getInitialDate()) => {
- currentDate.value = date;
- scrollToCurrentDate();
- };
- const checkRange = (date) => {
- const {
- maxRange,
- rangePrompt,
- showRangePrompt
- } = props;
- if (maxRange && calcDateNum(date) > maxRange) {
- if (showRangePrompt) {
- Toast(rangePrompt || t$f("rangePrompt", maxRange));
- }
- emit("over-range");
- return false;
- }
- return true;
- };
- const onConfirm = () => {
- var _a;
- return emit("confirm", (_a = currentDate.value) != null ? _a : cloneDates(currentDate.value));
- };
- const select = (date, complete) => {
- const setCurrentDate = (date2) => {
- currentDate.value = date2;
- emit("select", cloneDates(date2));
- };
- if (complete && props.type === "range") {
- const valid = checkRange(date);
- if (!valid) {
- setCurrentDate([date[0], getDayByOffset(date[0], +props.maxRange - 1)]);
- return;
- }
- }
- setCurrentDate(date);
- if (complete && !props.showConfirm) {
- onConfirm();
- }
- };
- const getDisabledDate = (disabledDays2, startDay, date) => {
- var _a;
- return (_a = disabledDays2.find((day) => compareDay(startDay, day.date) === -1 && compareDay(day.date, date) === -1)) == null ? void 0 : _a.date;
- };
- const disabledDays = computed(() => monthRefs.value.reduce((arr, ref2) => {
- var _a, _b;
- arr.push(...(_b = (_a = ref2.disabledDays) == null ? void 0 : _a.value) != null ? _b : []);
- return arr;
- }, []));
- const onClickDay = (item) => {
- if (props.readonly || !item.date) {
- return;
- }
- const {
- date
- } = item;
- const {
- type
- } = props;
- if (type === "range") {
- if (!currentDate.value) {
- select([date]);
- return;
- }
- const [startDay, endDay] = currentDate.value;
- if (startDay && !endDay) {
- const compareToStart = compareDay(date, startDay);
- if (compareToStart === 1) {
- const disabledDay = getDisabledDate(disabledDays.value, startDay, date);
- if (disabledDay) {
- const endDay2 = getPrevDay(disabledDay);
- if (compareDay(startDay, endDay2) === -1) {
- select([startDay, endDay2]);
- } else {
- select([date]);
- }
- } else {
- select([startDay, date], true);
- }
- } else if (compareToStart === -1) {
- select([date]);
- } else if (props.allowSameDay) {
- select([date, date], true);
- }
- } else {
- select([date]);
- }
- } else if (type === "multiple") {
- if (!currentDate.value) {
- select([date]);
- return;
- }
- const dates = currentDate.value;
- const selectedIndex = dates.findIndex((dateItem) => compareDay(dateItem, date) === 0);
- if (selectedIndex !== -1) {
- const [unselectedDate] = dates.splice(selectedIndex, 1);
- emit("unselect", cloneDate(unselectedDate));
- } else if (props.maxRange && dates.length >= props.maxRange) {
- Toast(props.rangePrompt || t$f("rangePrompt", props.maxRange));
- } else {
- select([...dates, date]);
- }
- } else {
- select(date, true);
- }
- };
- const updateShow = (value) => emit("update:show", value);
- const renderMonth = (date, index) => {
- const showMonthTitle = index !== 0 || !props.showSubtitle;
- return createVNode(stdin_default$1a, mergeProps({
- "ref": setMonthRefs(index),
- "date": date,
- "currentDate": currentDate.value,
- "showMonthTitle": showMonthTitle,
- "firstDayOfWeek": dayOffset.value
- }, pick(props, ["type", "color", "minDate", "maxDate", "showMark", "formatter", "rowHeight", "lazyRender", "showSubtitle", "allowSameDay"]), {
- "onClick": onClickDay
- }), pick(slots, ["top-info", "bottom-info"]));
- };
- const renderFooterButton = () => {
- if (slots.footer) {
- return slots.footer();
- }
- if (props.showConfirm) {
- const slot = slots["confirm-text"];
- const disabled = buttonDisabled.value;
- const text = disabled ? props.confirmDisabledText : props.confirmText;
- return createVNode(Button, {
- "round": true,
- "block": true,
- "type": "danger",
- "color": props.color,
- "class": bem$11("confirm"),
- "disabled": disabled,
- "nativeType": "button",
- "onClick": onConfirm
- }, {
- default: () => [slot ? slot({
- disabled
- }) : text || t$f("confirm")]
- });
- }
- };
- const renderFooter = () => createVNode("div", {
- "class": [bem$11("footer"), {
- "van-safe-area-bottom": props.safeAreaInsetBottom
- }]
- }, [renderFooterButton()]);
- const renderCalendar = () => createVNode("div", {
- "class": bem$11()
- }, [createVNode(stdin_default$19, {
- "title": props.title,
- "subtitle": subtitle.value,
- "showTitle": props.showTitle,
- "showSubtitle": props.showSubtitle,
- "firstDayOfWeek": dayOffset.value,
- "onClick-subtitle": (event) => emit("click-subtitle", event)
- }, pick(slots, ["title", "subtitle"])), createVNode("div", {
- "ref": bodyRef,
- "class": bem$11("body"),
- "onScroll": onScroll
- }, [months.value.map(renderMonth)]), renderFooter()]);
- watch(() => props.show, init);
- watch(() => [props.type, props.minDate, props.maxDate], () => reset(getInitialDate(currentDate.value)));
- watch(() => props.defaultDate, (value = null) => {
- currentDate.value = value;
- scrollToCurrentDate();
- });
- useExpose({
- reset,
- scrollToDate,
- getSelectedDate
- });
- onMountedOrActivated(init);
- return () => {
- if (props.poppable) {
- return createVNode(Popup, {
- "show": props.show,
- "class": bem$11("popup"),
- "round": props.round,
- "position": props.position,
- "closeable": props.showTitle || props.showSubtitle,
- "teleport": props.teleport,
- "closeOnPopstate": props.closeOnPopstate,
- "safeAreaInsetTop": props.safeAreaInsetTop,
- "closeOnClickOverlay": props.closeOnClickOverlay,
- "onUpdate:show": updateShow
- }, {
- default: renderCalendar
- });
- }
- return renderCalendar();
- };
- }
- });
- const Calendar = withInstall(stdin_default$18);
- const [name$11, bem$10] = createNamespace("image");
- const imageProps = {
- src: String,
- alt: String,
- fit: String,
- position: String,
- round: Boolean,
- block: Boolean,
- width: numericProp,
- height: numericProp,
- radius: numericProp,
- lazyLoad: Boolean,
- iconSize: numericProp,
- showError: truthProp,
- errorIcon: makeStringProp("photo-fail"),
- iconPrefix: String,
- showLoading: truthProp,
- loadingIcon: makeStringProp("photo")
- };
- var stdin_default$17 = defineComponent({
- name: name$11,
- props: imageProps,
- emits: ["load", "error"],
- setup(props, {
- emit,
- slots
- }) {
- const error = ref(false);
- const loading = ref(true);
- const imageRef = ref();
- const {
- $Lazyload
- } = getCurrentInstance().proxy;
- const style = computed(() => {
- const style2 = {
- width: addUnit(props.width),
- height: addUnit(props.height)
- };
- if (isDef(props.radius)) {
- style2.overflow = "hidden";
- style2.borderRadius = addUnit(props.radius);
- }
- return style2;
- });
- watch(() => props.src, () => {
- error.value = false;
- loading.value = true;
- });
- const onLoad = (event) => {
- loading.value = false;
- emit("load", event);
- };
- const onError = (event) => {
- error.value = true;
- loading.value = false;
- emit("error", event);
- };
- const renderIcon = (name2, className, slot) => {
- if (slot) {
- return slot();
- }
- return createVNode(Icon, {
- "name": name2,
- "size": props.iconSize,
- "class": className,
- "classPrefix": props.iconPrefix
- }, null);
- };
- const renderPlaceholder = () => {
- if (loading.value && props.showLoading) {
- return createVNode("div", {
- "class": bem$10("loading")
- }, [renderIcon(props.loadingIcon, bem$10("loading-icon"), slots.loading)]);
- }
- if (error.value && props.showError) {
- return createVNode("div", {
- "class": bem$10("error")
- }, [renderIcon(props.errorIcon, bem$10("error-icon"), slots.error)]);
- }
- };
- const renderImage = () => {
- if (error.value || !props.src) {
- return;
- }
- const attrs = {
- alt: props.alt,
- class: bem$10("img"),
- style: {
- objectFit: props.fit,
- objectPosition: props.position
- }
- };
- if (props.lazyLoad) {
- return withDirectives(createVNode("img", mergeProps({
- "ref": imageRef
- }, attrs), null), [[resolveDirective("lazy"), props.src]]);
- }
- return createVNode("img", mergeProps({
- "src": props.src,
- "onLoad": onLoad,
- "onError": onError
- }, attrs), null);
- };
- const onLazyLoaded = ({
- el
- }) => {
- const check = () => {
- if (el === imageRef.value && loading.value) {
- onLoad();
- }
- };
- if (imageRef.value) {
- check();
- } else {
- nextTick(check);
- }
- };
- const onLazyLoadError = ({
- el
- }) => {
- if (el === imageRef.value && !error.value) {
- onError();
- }
- };
- if ($Lazyload && inBrowser) {
- $Lazyload.$on("loaded", onLazyLoaded);
- $Lazyload.$on("error", onLazyLoadError);
- onBeforeUnmount(() => {
- $Lazyload.$off("loaded", onLazyLoaded);
- $Lazyload.$off("error", onLazyLoadError);
- });
- }
- return () => {
- var _a;
- return createVNode("div", {
- "class": bem$10({
- round: props.round,
- block: props.block
- }),
- "style": style.value
- }, [renderImage(), renderPlaceholder(), (_a = slots.default) == null ? void 0 : _a.call(slots)]);
- };
- }
- });
- const Image$1 = withInstall(stdin_default$17);
- const [name$10, bem$$] = createNamespace("card");
- const cardProps = {
- tag: String,
- num: numericProp,
- desc: String,
- thumb: String,
- title: String,
- price: numericProp,
- centered: Boolean,
- lazyLoad: Boolean,
- currency: makeStringProp("\xA5"),
- thumbLink: String,
- originPrice: numericProp
- };
- var stdin_default$16 = defineComponent({
- name: name$10,
- props: cardProps,
- emits: ["click-thumb"],
- setup(props, {
- slots,
- emit
- }) {
- const renderTitle = () => {
- if (slots.title) {
- return slots.title();
- }
- if (props.title) {
- return createVNode("div", {
- "class": [bem$$("title"), "van-multi-ellipsis--l2"]
- }, [props.title]);
- }
- };
- const renderThumbTag = () => {
- if (slots.tag || props.tag) {
- return createVNode("div", {
- "class": bem$$("tag")
- }, [slots.tag ? slots.tag() : createVNode(Tag, {
- "mark": true,
- "type": "danger"
- }, {
- default: () => [props.tag]
- })]);
- }
- };
- const renderThumbImage = () => {
- if (slots.thumb) {
- return slots.thumb();
- }
- return createVNode(Image$1, {
- "src": props.thumb,
- "fit": "cover",
- "width": "100%",
- "height": "100%",
- "lazyLoad": props.lazyLoad
- }, null);
- };
- const renderThumb = () => {
- if (slots.thumb || props.thumb) {
- return createVNode("a", {
- "href": props.thumbLink,
- "class": bem$$("thumb"),
- "onClick": (event) => emit("click-thumb", event)
- }, [renderThumbImage(), renderThumbTag()]);
- }
- };
- const renderDesc = () => {
- if (slots.desc) {
- return slots.desc();
- }
- if (props.desc) {
- return createVNode("div", {
- "class": [bem$$("desc"), "van-ellipsis"]
- }, [props.desc]);
- }
- };
- const renderPriceText = () => {
- const priceArr = props.price.toString().split(".");
- return createVNode("div", null, [createVNode("span", {
- "class": bem$$("price-currency")
- }, [props.currency]), createVNode("span", {
- "class": bem$$("price-integer")
- }, [priceArr[0]]), createTextVNode("."), createVNode("span", {
- "class": bem$$("price-decimal")
- }, [priceArr[1]])]);
- };
- return () => {
- var _a, _b, _c;
- const showNum = slots.num || isDef(props.num);
- const showPrice = slots.price || isDef(props.price);
- const showOriginPrice = slots["origin-price"] || isDef(props.originPrice);
- const showBottom = showNum || showPrice || showOriginPrice || slots.bottom;
- const Price = showPrice && createVNode("div", {
- "class": bem$$("price")
- }, [slots.price ? slots.price() : renderPriceText()]);
- const OriginPrice = showOriginPrice && createVNode("div", {
- "class": bem$$("origin-price")
- }, [slots["origin-price"] ? slots["origin-price"]() : `${props.currency} ${props.originPrice}`]);
- const Num = showNum && createVNode("div", {
- "class": bem$$("num")
- }, [slots.num ? slots.num() : `x${props.num}`]);
- const Footer = slots.footer && createVNode("div", {
- "class": bem$$("footer")
- }, [slots.footer()]);
- const Bottom = showBottom && createVNode("div", {
- "class": bem$$("bottom")
- }, [(_a = slots["price-top"]) == null ? void 0 : _a.call(slots), Price, OriginPrice, Num, (_b = slots.bottom) == null ? void 0 : _b.call(slots)]);
- return createVNode("div", {
- "class": bem$$()
- }, [createVNode("div", {
- "class": bem$$("header")
- }, [renderThumb(), createVNode("div", {
- "class": bem$$("content", {
- centered: props.centered
- })
- }, [createVNode("div", null, [renderTitle(), renderDesc(), (_c = slots.tags) == null ? void 0 : _c.call(slots)]), Bottom])]), Footer]);
- };
- }
- });
- const Card = withInstall(stdin_default$16);
- function scrollLeftTo(scroller, to, duration) {
- let count = 0;
- const from = scroller.scrollLeft;
- const frames = duration === 0 ? 1 : Math.round(duration * 1e3 / 16);
- function animate() {
- scroller.scrollLeft += (to - from) / frames;
- if (++count < frames) {
- raf(animate);
- }
- }
- animate();
- }
- function scrollTopTo(scroller, to, duration, callback) {
- let current2 = getScrollTop(scroller);
- const isDown = current2 < to;
- const frames = duration === 0 ? 1 : Math.round(duration * 1e3 / 16);
- const step = (to - current2) / frames;
- function animate() {
- current2 += step;
- if (isDown && current2 > to || !isDown && current2 < to) {
- current2 = to;
- }
- setScrollTop(scroller, current2);
- if (isDown && current2 < to || !isDown && current2 > to) {
- raf(animate);
- } else if (callback) {
- raf(callback);
- }
- }
- animate();
- }
- function useVisibilityChange(target, onChange) {
- if (!inBrowser || !window.IntersectionObserver) {
- return;
- }
- const observer = new IntersectionObserver(
- (entries) => {
- onChange(entries[0].intersectionRatio > 0);
- },
- { root: document.body }
- );
- const observe = () => {
- if (target.value) {
- observer.observe(target.value);
- }
- };
- const unobserve = () => {
- if (target.value) {
- observer.unobserve(target.value);
- }
- };
- onDeactivated(unobserve);
- onBeforeUnmount(unobserve);
- onMountedOrActivated(observe);
- }
- const [name$$, bem$_] = createNamespace("sticky");
- const stickyProps = {
- zIndex: numericProp,
- position: makeStringProp("top"),
- container: Object,
- offsetTop: makeNumericProp(0),
- offsetBottom: makeNumericProp(0)
- };
- var stdin_default$15 = defineComponent({
- name: name$$,
- props: stickyProps,
- emits: ["scroll", "change"],
- setup(props, {
- emit,
- slots
- }) {
- const root = ref();
- const scrollParent = useScrollParent(root);
- const state = reactive({
- fixed: false,
- width: 0,
- height: 0,
- transform: 0
- });
- const offset = computed(() => unitToPx(props.position === "top" ? props.offsetTop : props.offsetBottom));
- const rootStyle = computed(() => {
- const {
- fixed,
- height,
- width
- } = state;
- if (fixed) {
- return {
- width: `${width}px`,
- height: `${height}px`
- };
- }
- });
- const stickyStyle = computed(() => {
- if (!state.fixed) {
- return;
- }
- const style = extend(getZIndexStyle(props.zIndex), {
- width: `${state.width}px`,
- height: `${state.height}px`,
- [props.position]: `${offset.value}px`
- });
- if (state.transform) {
- style.transform = `translate3d(0, ${state.transform}px, 0)`;
- }
- return style;
- });
- const emitScroll = (scrollTop) => emit("scroll", {
- scrollTop,
- isFixed: state.fixed
- });
- const onScroll = () => {
- if (!root.value || isHidden(root)) {
- return;
- }
- const {
- container,
- position
- } = props;
- const rootRect = useRect(root);
- const scrollTop = getScrollTop(window);
- state.width = rootRect.width;
- state.height = rootRect.height;
- if (position === "top") {
- if (container) {
- const containerRect = useRect(container);
- const difference = containerRect.bottom - offset.value - state.height;
- state.fixed = offset.value > rootRect.top && containerRect.bottom > 0;
- state.transform = difference < 0 ? difference : 0;
- } else {
- state.fixed = offset.value > rootRect.top;
- }
- } else {
- const {
- clientHeight
- } = document.documentElement;
- if (container) {
- const containerRect = useRect(container);
- const difference = clientHeight - containerRect.top - offset.value - state.height;
- state.fixed = clientHeight - offset.value < rootRect.bottom && clientHeight > containerRect.top;
- state.transform = difference < 0 ? -difference : 0;
- } else {
- state.fixed = clientHeight - offset.value < rootRect.bottom;
- }
- }
- emitScroll(scrollTop);
- };
- watch(() => state.fixed, (value) => emit("change", value));
- useEventListener("scroll", onScroll, {
- target: scrollParent,
- passive: true
- });
- useVisibilityChange(root, onScroll);
- return () => {
- var _a;
- return createVNode("div", {
- "ref": root,
- "style": rootStyle.value
- }, [createVNode("div", {
- "class": bem$_({
- fixed: state.fixed
- }),
- "style": stickyStyle.value
- }, [(_a = slots.default) == null ? void 0 : _a.call(slots)])]);
- };
- }
- });
- const Sticky = withInstall(stdin_default$15);
- const [name$_, bem$Z] = createNamespace("tab");
- var stdin_default$14 = defineComponent({
- name: name$_,
- props: {
- id: String,
- dot: Boolean,
- type: String,
- color: String,
- title: String,
- badge: numericProp,
- shrink: Boolean,
- isActive: Boolean,
- disabled: Boolean,
- controls: String,
- scrollable: Boolean,
- activeColor: String,
- inactiveColor: String,
- showZeroBadge: truthProp
- },
- setup(props, {
- slots
- }) {
- const style = computed(() => {
- const style2 = {};
- const {
- type,
- color,
- disabled,
- isActive,
- activeColor,
- inactiveColor
- } = props;
- const isCard = type === "card";
- if (color && isCard) {
- style2.borderColor = color;
- if (!disabled) {
- if (isActive) {
- style2.backgroundColor = color;
- } else {
- style2.color = color;
- }
- }
- }
- const titleColor = isActive ? activeColor : inactiveColor;
- if (titleColor) {
- style2.color = titleColor;
- }
- return style2;
- });
- const renderText = () => {
- const Text2 = createVNode("span", {
- "class": bem$Z("text", {
- ellipsis: !props.scrollable
- })
- }, [slots.title ? slots.title() : props.title]);
- if (props.dot || isDef(props.badge) && props.badge !== "") {
- return createVNode(Badge, {
- "dot": props.dot,
- "content": props.badge,
- "showZero": props.showZeroBadge
- }, {
- default: () => [Text2]
- });
- }
- return Text2;
- };
- return () => createVNode("div", {
- "id": props.id,
- "role": "tab",
- "class": [bem$Z([props.type, {
- grow: props.scrollable && !props.shrink,
- shrink: props.shrink,
- active: props.isActive,
- disabled: props.disabled
- }])],
- "style": style.value,
- "tabindex": props.disabled ? void 0 : props.isActive ? 0 : -1,
- "aria-selected": props.isActive,
- "aria-disabled": props.disabled || void 0,
- "aria-controls": props.controls
- }, [renderText()]);
- }
- });
- const [name$Z, bem$Y] = createNamespace("swipe");
- const swipeProps = {
- loop: truthProp,
- width: numericProp,
- height: numericProp,
- vertical: Boolean,
- autoplay: makeNumericProp(0),
- duration: makeNumericProp(500),
- touchable: truthProp,
- lazyRender: Boolean,
- initialSwipe: makeNumericProp(0),
- indicatorColor: String,
- showIndicators: truthProp,
- stopPropagation: truthProp
- };
- const SWIPE_KEY = Symbol(name$Z);
- var stdin_default$13 = defineComponent({
- name: name$Z,
- props: swipeProps,
- emits: ["change"],
- setup(props, {
- emit,
- slots
- }) {
- const root = ref();
- const track = ref();
- const state = reactive({
- rect: null,
- width: 0,
- height: 0,
- offset: 0,
- active: 0,
- swiping: false
- });
- const touch = useTouch();
- const {
- children,
- linkChildren
- } = useChildren(SWIPE_KEY);
- const count = computed(() => children.length);
- const size = computed(() => state[props.vertical ? "height" : "width"]);
- const delta = computed(() => props.vertical ? touch.deltaY.value : touch.deltaX.value);
- const minOffset = computed(() => {
- if (state.rect) {
- const base = props.vertical ? state.rect.height : state.rect.width;
- return base - size.value * count.value;
- }
- return 0;
- });
- const maxCount = computed(() => Math.ceil(Math.abs(minOffset.value) / size.value));
- const trackSize = computed(() => count.value * size.value);
- const activeIndicator = computed(() => (state.active + count.value) % count.value);
- const isCorrectDirection = computed(() => {
- const expect = props.vertical ? "vertical" : "horizontal";
- return touch.direction.value === expect;
- });
- const trackStyle = computed(() => {
- const style = {
- transitionDuration: `${state.swiping ? 0 : props.duration}ms`,
- transform: `translate${props.vertical ? "Y" : "X"}(${state.offset}px)`
- };
- if (size.value) {
- const mainAxis = props.vertical ? "height" : "width";
- const crossAxis = props.vertical ? "width" : "height";
- style[mainAxis] = `${trackSize.value}px`;
- style[crossAxis] = props[crossAxis] ? `${props[crossAxis]}px` : "";
- }
- return style;
- });
- const getTargetActive = (pace) => {
- const {
- active
- } = state;
- if (pace) {
- if (props.loop) {
- return clamp(active + pace, -1, count.value);
- }
- return clamp(active + pace, 0, maxCount.value);
- }
- return active;
- };
- const getTargetOffset = (targetActive, offset = 0) => {
- let currentPosition = targetActive * size.value;
- if (!props.loop) {
- currentPosition = Math.min(currentPosition, -minOffset.value);
- }
- let targetOffset = offset - currentPosition;
- if (!props.loop) {
- targetOffset = clamp(targetOffset, minOffset.value, 0);
- }
- return targetOffset;
- };
- const move = ({
- pace = 0,
- offset = 0,
- emitChange
- }) => {
- if (count.value <= 1) {
- return;
- }
- const {
- active
- } = state;
- const targetActive = getTargetActive(pace);
- const targetOffset = getTargetOffset(targetActive, offset);
- if (props.loop) {
- if (children[0] && targetOffset !== minOffset.value) {
- const outRightBound = targetOffset < minOffset.value;
- children[0].setOffset(outRightBound ? trackSize.value : 0);
- }
- if (children[count.value - 1] && targetOffset !== 0) {
- const outLeftBound = targetOffset > 0;
- children[count.value - 1].setOffset(outLeftBound ? -trackSize.value : 0);
- }
- }
- state.active = targetActive;
- state.offset = targetOffset;
- if (emitChange && targetActive !== active) {
- emit("change", activeIndicator.value);
- }
- };
- const correctPosition = () => {
- state.swiping = true;
- if (state.active <= -1) {
- move({
- pace: count.value
- });
- } else if (state.active >= count.value) {
- move({
- pace: -count.value
- });
- }
- };
- const prev = () => {
- correctPosition();
- touch.reset();
- doubleRaf(() => {
- state.swiping = false;
- move({
- pace: -1,
- emitChange: true
- });
- });
- };
- const next = () => {
- correctPosition();
- touch.reset();
- doubleRaf(() => {
- state.swiping = false;
- move({
- pace: 1,
- emitChange: true
- });
- });
- };
- let autoplayTimer;
- const stopAutoplay = () => clearTimeout(autoplayTimer);
- const autoplay = () => {
- stopAutoplay();
- if (props.autoplay > 0 && count.value > 1) {
- autoplayTimer = setTimeout(() => {
- next();
- autoplay();
- }, +props.autoplay);
- }
- };
- const initialize = (active = +props.initialSwipe) => {
- if (!root.value) {
- return;
- }
- const cb = () => {
- var _a, _b;
- if (!isHidden(root)) {
- const rect = {
- width: root.value.offsetWidth,
- height: root.value.offsetHeight
- };
- state.rect = rect;
- state.width = +((_a = props.width) != null ? _a : rect.width);
- state.height = +((_b = props.height) != null ? _b : rect.height);
- }
- if (count.value) {
- active = Math.min(count.value - 1, active);
- }
- state.active = active;
- state.swiping = true;
- state.offset = getTargetOffset(active);
- children.forEach((swipe) => {
- swipe.setOffset(0);
- });
- autoplay();
- };
- if (isHidden(root)) {
- nextTick().then(cb);
- } else {
- cb();
- }
- };
- const resize = () => initialize(state.active);
- let touchStartTime;
- const onTouchStart = (event) => {
- if (!props.touchable)
- return;
- touch.start(event);
- touchStartTime = Date.now();
- stopAutoplay();
- correctPosition();
- };
- const onTouchMove = (event) => {
- if (props.touchable && state.swiping) {
- touch.move(event);
- if (isCorrectDirection.value) {
- const isEdgeTouch = !props.loop && (state.active === 0 && delta.value > 0 || state.active === count.value - 1 && delta.value < 0);
- if (!isEdgeTouch) {
- preventDefault(event, props.stopPropagation);
- move({
- offset: delta.value
- });
- }
- }
- }
- };
- const onTouchEnd = () => {
- if (!props.touchable || !state.swiping) {
- return;
- }
- const duration = Date.now() - touchStartTime;
- const speed = delta.value / duration;
- const shouldSwipe = Math.abs(speed) > 0.25 || Math.abs(delta.value) > size.value / 2;
- if (shouldSwipe && isCorrectDirection.value) {
- const offset = props.vertical ? touch.offsetY.value : touch.offsetX.value;
- let pace = 0;
- if (props.loop) {
- pace = offset > 0 ? delta.value > 0 ? -1 : 1 : 0;
- } else {
- pace = -Math[delta.value > 0 ? "ceil" : "floor"](delta.value / size.value);
- }
- move({
- pace,
- emitChange: true
- });
- } else if (delta.value) {
- move({
- pace: 0
- });
- }
- state.swiping = false;
- autoplay();
- };
- const swipeTo = (index, options = {}) => {
- correctPosition();
- touch.reset();
- doubleRaf(() => {
- let targetIndex;
- if (props.loop && index === count.value) {
- targetIndex = state.active === 0 ? 0 : index;
- } else {
- targetIndex = index % count.value;
- }
- if (options.immediate) {
- doubleRaf(() => {
- state.swiping = false;
- });
- } else {
- state.swiping = false;
- }
- move({
- pace: targetIndex - state.active,
- emitChange: true
- });
- });
- };
- const renderDot = (_, index) => {
- const active = index === activeIndicator.value;
- const style = active ? {
- backgroundColor: props.indicatorColor
- } : void 0;
- return createVNode("i", {
- "style": style,
- "class": bem$Y("indicator", {
- active
- })
- }, null);
- };
- const renderIndicator = () => {
- if (slots.indicator) {
- return slots.indicator({
- active: activeIndicator.value,
- total: count.value
- });
- }
- if (props.showIndicators && count.value > 1) {
- return createVNode("div", {
- "class": bem$Y("indicators", {
- vertical: props.vertical
- })
- }, [Array(count.value).fill("").map(renderDot)]);
- }
- };
- useExpose({
- prev,
- next,
- state,
- resize,
- swipeTo
- });
- linkChildren({
- size,
- props,
- count,
- activeIndicator
- });
- watch(() => props.initialSwipe, (value) => initialize(+value));
- watch(count, () => initialize(state.active));
- watch(() => props.autoplay, autoplay);
- watch([windowWidth, windowHeight], resize);
- watch(usePageVisibility(), (visible) => {
- if (visible === "visible") {
- autoplay();
- } else {
- stopAutoplay();
- }
- });
- onMounted(initialize);
- onActivated(() => initialize(state.active));
- onPopupReopen(() => initialize(state.active));
- onDeactivated(stopAutoplay);
- onBeforeUnmount(stopAutoplay);
- useEventListener("touchmove", onTouchMove, {
- target: track
- });
- return () => {
- var _a;
- return createVNode("div", {
- "ref": root,
- "class": bem$Y()
- }, [createVNode("div", {
- "ref": track,
- "style": trackStyle.value,
- "class": bem$Y("track", {
- vertical: props.vertical
- }),
- "onTouchstartPassive": onTouchStart,
- "onTouchend": onTouchEnd,
- "onTouchcancel": onTouchEnd
- }, [(_a = slots.default) == null ? void 0 : _a.call(slots)]), renderIndicator()]);
- };
- }
- });
- const Swipe = withInstall(stdin_default$13);
- const [name$Y, bem$X] = createNamespace("tabs");
- var stdin_default$12 = defineComponent({
- name: name$Y,
- props: {
- count: makeRequiredProp(Number),
- inited: Boolean,
- animated: Boolean,
- duration: makeRequiredProp(numericProp),
- swipeable: Boolean,
- lazyRender: Boolean,
- currentIndex: makeRequiredProp(Number)
- },
- emits: ["change"],
- setup(props, {
- emit,
- slots
- }) {
- const swipeRef = ref();
- const onChange = (index) => emit("change", index);
- const renderChildren = () => {
- var _a;
- const Content = (_a = slots.default) == null ? void 0 : _a.call(slots);
- if (props.animated || props.swipeable) {
- return createVNode(Swipe, {
- "ref": swipeRef,
- "loop": false,
- "class": bem$X("track"),
- "duration": +props.duration * 1e3,
- "touchable": props.swipeable,
- "lazyRender": props.lazyRender,
- "showIndicators": false,
- "onChange": onChange
- }, {
- default: () => [Content]
- });
- }
- return Content;
- };
- const swipeToCurrentTab = (index) => {
- const swipe = swipeRef.value;
- if (swipe && swipe.state.active !== index) {
- swipe.swipeTo(index, {
- immediate: !props.inited
- });
- }
- };
- watch(() => props.currentIndex, swipeToCurrentTab);
- onMounted(() => {
- swipeToCurrentTab(props.currentIndex);
- });
- useExpose({
- swipeRef
- });
- return () => createVNode("div", {
- "class": bem$X("content", {
- animated: props.animated || props.swipeable
- })
- }, [renderChildren()]);
- }
- });
- const [name$X, bem$W] = createNamespace("tabs");
- const tabsProps = {
- type: makeStringProp("line"),
- color: String,
- border: Boolean,
- sticky: Boolean,
- shrink: Boolean,
- active: makeNumericProp(0),
- duration: makeNumericProp(0.3),
- animated: Boolean,
- ellipsis: truthProp,
- swipeable: Boolean,
- scrollspy: Boolean,
- offsetTop: makeNumericProp(0),
- background: String,
- lazyRender: truthProp,
- lineWidth: numericProp,
- lineHeight: numericProp,
- beforeChange: Function,
- swipeThreshold: makeNumericProp(5),
- titleActiveColor: String,
- titleInactiveColor: String
- };
- const TABS_KEY = Symbol(name$X);
- var stdin_default$11 = defineComponent({
- name: name$X,
- props: tabsProps,
- emits: ["click", "change", "scroll", "disabled", "rendered", "click-tab", "update:active"],
- setup(props, {
- emit,
- slots
- }) {
- var _a, _b;
- if (process.env.NODE_ENV !== "production") {
- const props2 = (_b = (_a = getCurrentInstance()) == null ? void 0 : _a.vnode) == null ? void 0 : _b.props;
- if (props2 && "onClick" in props2) {
- console.warn('[Vant] Tabs: "click" event is deprecated, using "click-tab" instead.');
- }
- if (props2 && "onDisabled" in props2) {
- console.warn('[Vant] Tabs: "disabled" event is deprecated, using "click-tab" instead.');
- }
- }
- let tabHeight;
- let lockScroll;
- let stickyFixed;
- const root = ref();
- const navRef = ref();
- const wrapRef = ref();
- const contentRef = ref();
- const id = useId();
- const scroller = useScrollParent(root);
- const [titleRefs, setTitleRefs] = useRefs();
- const {
- children,
- linkChildren
- } = useChildren(TABS_KEY);
- const state = reactive({
- inited: false,
- position: "",
- lineStyle: {},
- currentIndex: -1
- });
- const scrollable = computed(() => children.length > props.swipeThreshold || !props.ellipsis || props.shrink);
- const navStyle = computed(() => ({
- borderColor: props.color,
- background: props.background
- }));
- const getTabName = (tab, index) => {
- var _a2;
- return (_a2 = tab.name) != null ? _a2 : index;
- };
- const currentName = computed(() => {
- const activeTab = children[state.currentIndex];
- if (activeTab) {
- return getTabName(activeTab, state.currentIndex);
- }
- });
- const offsetTopPx = computed(() => unitToPx(props.offsetTop));
- const scrollOffset = computed(() => {
- if (props.sticky) {
- return offsetTopPx.value + tabHeight;
- }
- return 0;
- });
- const scrollIntoView = (immediate) => {
- const nav = navRef.value;
- const titles = titleRefs.value;
- if (!scrollable.value || !nav || !titles || !titles[state.currentIndex]) {
- return;
- }
- const title = titles[state.currentIndex].$el;
- const to = title.offsetLeft - (nav.offsetWidth - title.offsetWidth) / 2;
- scrollLeftTo(nav, to, immediate ? 0 : +props.duration);
- };
- const setLine = () => {
- const shouldAnimate = state.inited;
- nextTick(() => {
- const titles = titleRefs.value;
- if (!titles || !titles[state.currentIndex] || props.type !== "line" || isHidden(root.value)) {
- return;
- }
- const title = titles[state.currentIndex].$el;
- const {
- lineWidth,
- lineHeight
- } = props;
- const left = title.offsetLeft + title.offsetWidth / 2;
- const lineStyle = {
- width: addUnit(lineWidth),
- backgroundColor: props.color,
- transform: `translateX(${left}px) translateX(-50%)`
- };
- if (shouldAnimate) {
- lineStyle.transitionDuration = `${props.duration}s`;
- }
- if (isDef(lineHeight)) {
- const height = addUnit(lineHeight);
- lineStyle.height = height;
- lineStyle.borderRadius = height;
- }
- state.lineStyle = lineStyle;
- });
- };
- const findAvailableTab = (index) => {
- const diff = index < state.currentIndex ? -1 : 1;
- while (index >= 0 && index < children.length) {
- if (!children[index].disabled) {
- return index;
- }
- index += diff;
- }
- };
- const setCurrentIndex = (currentIndex, skipScrollIntoView) => {
- const newIndex = findAvailableTab(currentIndex);
- if (!isDef(newIndex)) {
- return;
- }
- const newTab = children[newIndex];
- const newName = getTabName(newTab, newIndex);
- const shouldEmitChange = state.currentIndex !== null;
- if (state.currentIndex !== newIndex) {
- state.currentIndex = newIndex;
- if (!skipScrollIntoView) {
- scrollIntoView();
- }
- setLine();
- }
- if (newName !== props.active) {
- emit("update:active", newName);
- if (shouldEmitChange) {
- emit("change", newName, newTab.title);
- }
- }
- if (stickyFixed && !props.scrollspy) {
- setRootScrollTop(Math.ceil(getElementTop(root.value) - offsetTopPx.value));
- }
- };
- const setCurrentIndexByName = (name2, skipScrollIntoView) => {
- const matched = children.find((tab, index2) => getTabName(tab, index2) === name2);
- const index = matched ? children.indexOf(matched) : 0;
- setCurrentIndex(index, skipScrollIntoView);
- };
- const scrollToCurrentContent = (immediate = false) => {
- if (props.scrollspy) {
- const target = children[state.currentIndex].$el;
- if (target && scroller.value) {
- const to = getElementTop(target, scroller.value) - scrollOffset.value;
- lockScroll = true;
- scrollTopTo(scroller.value, to, immediate ? 0 : +props.duration, () => {
- lockScroll = false;
- });
- }
- }
- };
- const onClickTab = (item, index, event) => {
- const {
- title,
- disabled
- } = children[index];
- const name2 = getTabName(children[index], index);
- if (disabled) {
- emit("disabled", name2, title);
- } else {
- callInterceptor(props.beforeChange, {
- args: [name2],
- done: () => {
- setCurrentIndex(index);
- scrollToCurrentContent();
- }
- });
- emit("click", name2, title);
- route(item);
- }
- emit("click-tab", {
- name: name2,
- title,
- event,
- disabled
- });
- };
- const onStickyScroll = (params) => {
- stickyFixed = params.isFixed;
- emit("scroll", params);
- };
- const scrollTo = (name2) => {
- nextTick(() => {
- setCurrentIndexByName(name2);
- scrollToCurrentContent(true);
- });
- };
- const getCurrentIndexOnScroll = () => {
- for (let index = 0; index < children.length; index++) {
- const {
- top
- } = useRect(children[index].$el);
- if (top > scrollOffset.value) {
- return index === 0 ? 0 : index - 1;
- }
- }
- return children.length - 1;
- };
- const onScroll = () => {
- if (props.scrollspy && !lockScroll) {
- const index = getCurrentIndexOnScroll();
- setCurrentIndex(index);
- }
- };
- const renderNav = () => children.map((item, index) => createVNode(stdin_default$14, mergeProps({
- "key": item.id,
- "id": `${id}-${index}`,
- "ref": setTitleRefs(index),
- "type": props.type,
- "color": props.color,
- "style": item.titleStyle,
- "class": item.titleClass,
- "shrink": props.shrink,
- "isActive": index === state.currentIndex,
- "controls": item.id,
- "scrollable": scrollable.value,
- "activeColor": props.titleActiveColor,
- "inactiveColor": props.titleInactiveColor,
- "onClick": (event) => onClickTab(item, index, event)
- }, pick(item, ["dot", "badge", "title", "disabled", "showZeroBadge"])), {
- title: item.$slots.title
- }));
- const renderLine = () => {
- if (props.type === "line" && children.length) {
- return createVNode("div", {
- "class": bem$W("line"),
- "style": state.lineStyle
- }, null);
- }
- };
- const renderHeader = () => {
- var _a2, _b2, _c;
- const {
- type,
- border,
- sticky
- } = props;
- const Header = [createVNode("div", {
- "ref": sticky ? void 0 : wrapRef,
- "class": [bem$W("wrap"), {
- [BORDER_TOP_BOTTOM]: type === "line" && border
- }]
- }, [createVNode("div", {
- "ref": navRef,
- "role": "tablist",
- "class": bem$W("nav", [type, {
- shrink: props.shrink,
- complete: scrollable.value
- }]),
- "style": navStyle.value,
- "aria-orientation": "horizontal"
- }, [(_a2 = slots["nav-left"]) == null ? void 0 : _a2.call(slots), renderNav(), renderLine(), (_b2 = slots["nav-right"]) == null ? void 0 : _b2.call(slots)])]), (_c = slots["nav-bottom"]) == null ? void 0 : _c.call(slots)];
- if (sticky) {
- return createVNode("div", {
- "ref": wrapRef
- }, [Header]);
- }
- return Header;
- };
- watch([() => props.color, windowWidth], setLine);
- watch(() => props.active, (value) => {
- if (value !== currentName.value) {
- setCurrentIndexByName(value);
- }
- });
- watch(() => children.length, () => {
- if (state.inited) {
- setCurrentIndexByName(props.active);
- setLine();
- nextTick(() => {
- scrollIntoView(true);
- });
- }
- });
- const init = () => {
- setCurrentIndexByName(props.active, true);
- nextTick(() => {
- state.inited = true;
- if (wrapRef.value) {
- tabHeight = useRect(wrapRef.value).height;
- }
- scrollIntoView(true);
- });
- };
- const onRendered = (name2, title) => emit("rendered", name2, title);
- const resize = () => {
- setLine();
- nextTick(() => {
- var _a2, _b2;
- return (_b2 = (_a2 = contentRef.value) == null ? void 0 : _a2.swipeRef.value) == null ? void 0 : _b2.resize();
- });
- };
- useExpose({
- resize,
- scrollTo
- });
- onActivated(setLine);
- onPopupReopen(setLine);
- onMountedOrActivated(init);
- useEventListener("scroll", onScroll, {
- target: scroller,
- passive: true
- });
- linkChildren({
- id,
- props,
- setLine,
- onRendered,
- currentName,
- scrollIntoView
- });
- return () => createVNode("div", {
- "ref": root,
- "class": bem$W([props.type])
- }, [props.sticky ? createVNode(Sticky, {
- "container": root.value,
- "offsetTop": offsetTopPx.value,
- "onScroll": onStickyScroll
- }, {
- default: () => [renderHeader()]
- }) : renderHeader(), createVNode(stdin_default$12, {
- "ref": contentRef,
- "count": children.length,
- "inited": state.inited,
- "animated": props.animated,
- "duration": props.duration,
- "swipeable": props.swipeable,
- "lazyRender": props.lazyRender,
- "currentIndex": state.currentIndex,
- "onChange": setCurrentIndex
- }, {
- default: () => {
- var _a2;
- return [(_a2 = slots.default) == null ? void 0 : _a2.call(slots)];
- }
- })]);
- }
- });
- const TAB_STATUS_KEY = Symbol();
- const useTabStatus = () => inject(TAB_STATUS_KEY, null);
- const [name$W, bem$V] = createNamespace("swipe-item");
- var stdin_default$10 = defineComponent({
- name: name$W,
- setup(props, {
- slots
- }) {
- let rendered;
- const state = reactive({
- offset: 0,
- inited: false,
- mounted: false
- });
- const {
- parent,
- index
- } = useParent(SWIPE_KEY);
- if (!parent) {
- if (process.env.NODE_ENV !== "production") {
- console.error("[Vant] <SwipeItem> must be a child component of <Swipe>.");
- }
- return;
- }
- const style = computed(() => {
- const style2 = {};
- const {
- vertical
- } = parent.props;
- if (parent.size.value) {
- style2[vertical ? "height" : "width"] = `${parent.size.value}px`;
- }
- if (state.offset) {
- style2.transform = `translate${vertical ? "Y" : "X"}(${state.offset}px)`;
- }
- return style2;
- });
- const shouldRender = computed(() => {
- const {
- loop,
- lazyRender
- } = parent.props;
- if (!lazyRender || rendered) {
- return true;
- }
- if (!state.mounted) {
- return false;
- }
- const active = parent.activeIndicator.value;
- const maxActive = parent.count.value - 1;
- const prevActive = active === 0 && loop ? maxActive : active - 1;
- const nextActive = active === maxActive && loop ? 0 : active + 1;
- rendered = index.value === active || index.value === prevActive || index.value === nextActive;
- return rendered;
- });
- const setOffset = (offset) => {
- state.offset = offset;
- };
- onMounted(() => {
- nextTick(() => {
- state.mounted = true;
- });
- });
- useExpose({
- setOffset
- });
- return () => {
- var _a;
- return createVNode("div", {
- "class": bem$V(),
- "style": style.value
- }, [shouldRender.value ? (_a = slots.default) == null ? void 0 : _a.call(slots) : null]);
- };
- }
- });
- const SwipeItem = withInstall(stdin_default$10);
- const [name$V, bem$U] = createNamespace("tab");
- const tabProps = extend({}, routeProps, {
- dot: Boolean,
- name: numericProp,
- badge: numericProp,
- title: String,
- disabled: Boolean,
- titleClass: unknownProp,
- titleStyle: [String, Object],
- showZeroBadge: truthProp
- });
- var stdin_default$$ = defineComponent({
- name: name$V,
- props: tabProps,
- setup(props, {
- slots
- }) {
- const id = useId();
- const inited = ref(false);
- const {
- parent,
- index
- } = useParent(TABS_KEY);
- if (!parent) {
- if (process.env.NODE_ENV !== "production") {
- console.error("[Vant] <Tab> must be a child component of <Tabs>.");
- }
- return;
- }
- const getName = () => {
- var _a;
- return (_a = props.name) != null ? _a : index.value;
- };
- const init = () => {
- inited.value = true;
- if (parent.props.lazyRender) {
- nextTick(() => {
- parent.onRendered(getName(), props.title);
- });
- }
- };
- const active = computed(() => {
- const isActive = getName() === parent.currentName.value;
- if (isActive && !inited.value) {
- init();
- }
- return isActive;
- });
- const hasInactiveClass = ref(!active.value);
- watch(active, (val) => {
- if (val) {
- hasInactiveClass.value = false;
- } else {
- doubleRaf(() => {
- hasInactiveClass.value = true;
- });
- }
- });
- watch(() => props.title, () => {
- parent.setLine();
- parent.scrollIntoView();
- });
- provide(TAB_STATUS_KEY, active);
- return () => {
- var _a;
- const label = `${parent.id}-${index.value}`;
- const {
- animated,
- swipeable,
- scrollspy,
- lazyRender
- } = parent.props;
- if (!slots.default && !animated) {
- return;
- }
- const show = scrollspy || active.value;
- if (animated || swipeable) {
- return createVNode(SwipeItem, {
- "id": id,
- "role": "tabpanel",
- "class": bem$U("panel-wrapper", {
- inactive: hasInactiveClass.value
- }),
- "tabindex": active.value ? 0 : -1,
- "aria-hidden": !active.value,
- "aria-labelledby": label
- }, {
- default: () => {
- var _a2;
- return [createVNode("div", {
- "class": bem$U("panel")
- }, [(_a2 = slots.default) == null ? void 0 : _a2.call(slots)])];
- }
- });
- }
- const shouldRender = inited.value || scrollspy || !lazyRender;
- const Content = shouldRender ? (_a = slots.default) == null ? void 0 : _a.call(slots) : null;
- useExpose({
- id
- });
- return withDirectives(createVNode("div", {
- "id": id,
- "role": "tabpanel",
- "class": bem$U("panel"),
- "tabindex": show ? 0 : -1,
- "aria-labelledby": label
- }, [Content]), [[vShow, show]]);
- };
- }
- });
- const Tab = withInstall(stdin_default$$);
- const Tabs = withInstall(stdin_default$11);
- const [name$U, bem$T, t$e] = createNamespace("cascader");
- const cascaderProps = {
- title: String,
- options: makeArrayProp(),
- closeable: truthProp,
- swipeable: truthProp,
- closeIcon: makeStringProp("cross"),
- showHeader: truthProp,
- modelValue: numericProp,
- fieldNames: Object,
- placeholder: String,
- activeColor: String
- };
- var stdin_default$_ = defineComponent({
- name: name$U,
- props: cascaderProps,
- emits: ["close", "change", "finish", "click-tab", "update:modelValue"],
- setup(props, {
- slots,
- emit
- }) {
- const tabs = ref([]);
- const activeTab = ref(0);
- const {
- text: textKey,
- value: valueKey,
- children: childrenKey
- } = extend({
- text: "text",
- value: "value",
- children: "children"
- }, props.fieldNames);
- const getSelectedOptionsByValue = (options, value) => {
- for (const option of options) {
- if (option[valueKey] === value) {
- return [option];
- }
- if (option[childrenKey]) {
- const selectedOptions = getSelectedOptionsByValue(option[childrenKey], value);
- if (selectedOptions) {
- return [option, ...selectedOptions];
- }
- }
- }
- };
- const updateTabs = () => {
- const {
- options,
- modelValue
- } = props;
- if (modelValue !== void 0) {
- const selectedOptions = getSelectedOptionsByValue(options, modelValue);
- if (selectedOptions) {
- let optionsCursor = options;
- tabs.value = selectedOptions.map((option) => {
- const tab = {
- options: optionsCursor,
- selected: option
- };
- const next = optionsCursor.find((item) => item[valueKey] === option[valueKey]);
- if (next) {
- optionsCursor = next[childrenKey];
- }
- return tab;
- });
- if (optionsCursor) {
- tabs.value.push({
- options: optionsCursor,
- selected: null
- });
- }
- nextTick(() => {
- activeTab.value = tabs.value.length - 1;
- });
- return;
- }
- }
- tabs.value = [{
- options,
- selected: null
- }];
- };
- const onSelect = (option, tabIndex) => {
- if (option.disabled) {
- return;
- }
- tabs.value[tabIndex].selected = option;
- if (tabs.value.length > tabIndex + 1) {
- tabs.value = tabs.value.slice(0, tabIndex + 1);
- }
- if (option[childrenKey]) {
- const nextTab = {
- options: option[childrenKey],
- selected: null
- };
- if (tabs.value[tabIndex + 1]) {
- tabs.value[tabIndex + 1] = nextTab;
- } else {
- tabs.value.push(nextTab);
- }
- nextTick(() => {
- activeTab.value++;
- });
- }
- const selectedOptions = tabs.value.map((tab) => tab.selected).filter(Boolean);
- emit("update:modelValue", option[valueKey]);
- const params = {
- value: option[valueKey],
- tabIndex,
- selectedOptions
- };
- emit("change", params);
- if (!option[childrenKey]) {
- emit("finish", params);
- }
- };
- const onClose = () => emit("close");
- const onClickTab = ({
- name: name2,
- title
- }) => emit("click-tab", name2, title);
- const renderHeader = () => props.showHeader ? createVNode("div", {
- "class": bem$T("header")
- }, [createVNode("h2", {
- "class": bem$T("title")
- }, [slots.title ? slots.title() : props.title]), props.closeable ? createVNode(Icon, {
- "name": props.closeIcon,
- "class": [bem$T("close-icon"), HAPTICS_FEEDBACK],
- "onClick": onClose
- }, null) : null]) : null;
- const renderOption = (option, selectedOption, tabIndex) => {
- const {
- disabled
- } = option;
- const selected = !!(selectedOption && option[valueKey] === selectedOption[valueKey]);
- const color = option.color || (selected ? props.activeColor : void 0);
- const Text2 = slots.option ? slots.option({
- option,
- selected
- }) : createVNode("span", null, [option[textKey]]);
- return createVNode("li", {
- "role": "menuitemradio",
- "class": [bem$T("option", {
- selected,
- disabled
- }), option.className],
- "style": {
- color
- },
- "tabindex": disabled ? void 0 : selected ? 0 : -1,
- "aria-checked": selected,
- "aria-disabled": disabled || void 0,
- "onClick": () => onSelect(option, tabIndex)
- }, [Text2, selected ? createVNode(Icon, {
- "name": "success",
- "class": bem$T("selected-icon")
- }, null) : null]);
- };
- const renderOptions = (options, selectedOption, tabIndex) => createVNode("ul", {
- "role": "menu",
- "class": bem$T("options")
- }, [options.map((option) => renderOption(option, selectedOption, tabIndex))]);
- const renderTab = (tab, tabIndex) => {
- const {
- options,
- selected
- } = tab;
- const placeholder = props.placeholder || t$e("select");
- const title = selected ? selected[textKey] : placeholder;
- return createVNode(Tab, {
- "title": title,
- "titleClass": bem$T("tab", {
- unselected: !selected
- })
- }, {
- default: () => {
- var _a, _b;
- return [(_a = slots["options-top"]) == null ? void 0 : _a.call(slots, {
- tabIndex
- }), renderOptions(options, selected, tabIndex), (_b = slots["options-bottom"]) == null ? void 0 : _b.call(slots, {
- tabIndex
- })];
- }
- });
- };
- const renderTabs = () => createVNode(Tabs, {
- "active": activeTab.value,
- "onUpdate:active": ($event) => activeTab.value = $event,
- "shrink": true,
- "animated": true,
- "class": bem$T("tabs"),
- "color": props.activeColor,
- "swipeable": props.swipeable,
- "onClick-tab": onClickTab
- }, {
- default: () => [tabs.value.map(renderTab)]
- });
- updateTabs();
- watch(() => props.options, updateTabs, {
- deep: true
- });
- watch(() => props.modelValue, (value) => {
- if (value !== void 0) {
- const values = tabs.value.map((tab) => {
- var _a;
- return (_a = tab.selected) == null ? void 0 : _a[valueKey];
- });
- if (values.includes(value)) {
- return;
- }
- }
- updateTabs();
- });
- return () => createVNode("div", {
- "class": bem$T()
- }, [renderHeader(), renderTabs()]);
- }
- });
- const Cascader = withInstall(stdin_default$_);
- const [name$T, bem$S] = createNamespace("cell-group");
- const cellGroupProps = {
- title: String,
- inset: Boolean,
- border: truthProp
- };
- var stdin_default$Z = defineComponent({
- name: name$T,
- inheritAttrs: false,
- props: cellGroupProps,
- setup(props, {
- slots,
- attrs
- }) {
- const renderGroup = () => {
- var _a;
- return createVNode("div", mergeProps({
- "class": [bem$S({
- inset: props.inset
- }), {
- [BORDER_TOP_BOTTOM]: props.border && !props.inset
- }]
- }, attrs), [(_a = slots.default) == null ? void 0 : _a.call(slots)]);
- };
- const renderTitle = () => createVNode("div", {
- "class": bem$S("title", {
- inset: props.inset
- })
- }, [slots.title ? slots.title() : props.title]);
- return () => {
- if (props.title || slots.title) {
- return createVNode(Fragment, null, [renderTitle(), renderGroup()]);
- }
- return renderGroup();
- };
- }
- });
- const CellGroup = withInstall(stdin_default$Z);
- const [name$S, bem$R] = createNamespace("checkbox-group");
- const checkboxGroupProps = {
- max: numericProp,
- disabled: Boolean,
- iconSize: numericProp,
- direction: String,
- modelValue: makeArrayProp(),
- checkedColor: String
- };
- const CHECKBOX_GROUP_KEY = Symbol(name$S);
- var stdin_default$Y = defineComponent({
- name: name$S,
- props: checkboxGroupProps,
- emits: ["change", "update:modelValue"],
- setup(props, {
- emit,
- slots
- }) {
- const {
- children,
- linkChildren
- } = useChildren(CHECKBOX_GROUP_KEY);
- const updateValue = (value) => emit("update:modelValue", value);
- const toggleAll = (options = {}) => {
- if (typeof options === "boolean") {
- options = {
- checked: options
- };
- }
- const {
- checked,
- skipDisabled
- } = options;
- const checkedChildren = children.filter((item) => {
- if (!item.props.bindGroup) {
- return false;
- }
- if (item.props.disabled && skipDisabled) {
- return item.checked.value;
- }
- return checked != null ? checked : !item.checked.value;
- });
- const names = checkedChildren.map((item) => item.name);
- updateValue(names);
- };
- watch(() => props.modelValue, (value) => emit("change", value));
- useExpose({
- toggleAll
- });
- useCustomFieldValue(() => props.modelValue);
- linkChildren({
- props,
- updateValue
- });
- return () => {
- var _a;
- return createVNode("div", {
- "class": bem$R([props.direction])
- }, [(_a = slots.default) == null ? void 0 : _a.call(slots)]);
- };
- }
- });
- const [name$R, bem$Q] = createNamespace("checkbox");
- const checkboxProps = extend({}, checkerProps, {
- bindGroup: truthProp
- });
- var stdin_default$X = defineComponent({
- name: name$R,
- props: checkboxProps,
- emits: ["change", "update:modelValue"],
- setup(props, {
- emit,
- slots
- }) {
- const {
- parent
- } = useParent(CHECKBOX_GROUP_KEY);
- const setParentValue = (checked2) => {
- const {
- name: name2
- } = props;
- const {
- max,
- modelValue
- } = parent.props;
- const value = modelValue.slice();
- if (checked2) {
- const overlimit = max && value.length >= max;
- if (!overlimit && !value.includes(name2)) {
- value.push(name2);
- if (props.bindGroup) {
- parent.updateValue(value);
- }
- }
- } else {
- const index = value.indexOf(name2);
- if (index !== -1) {
- value.splice(index, 1);
- if (props.bindGroup) {
- parent.updateValue(value);
- }
- }
- }
- };
- const checked = computed(() => {
- if (parent && props.bindGroup) {
- return parent.props.modelValue.indexOf(props.name) !== -1;
- }
- return !!props.modelValue;
- });
- const toggle = (newValue = !checked.value) => {
- if (parent && props.bindGroup) {
- setParentValue(newValue);
- } else {
- emit("update:modelValue", newValue);
- }
- };
- watch(() => props.modelValue, (value) => emit("change", value));
- useExpose({
- toggle,
- props,
- checked
- });
- useCustomFieldValue(() => props.modelValue);
- return () => createVNode(stdin_default$1f, mergeProps({
- "bem": bem$Q,
- "role": "checkbox",
- "parent": parent,
- "checked": checked.value,
- "onToggle": toggle
- }, props), pick(slots, ["default", "icon"]));
- }
- });
- const Checkbox = withInstall(stdin_default$X);
- const CheckboxGroup = withInstall(stdin_default$Y);
- const [name$Q, bem$P] = createNamespace("circle");
- let uid = 0;
- const format = (rate) => Math.min(Math.max(+rate, 0), 100);
- function getPath(clockwise, viewBoxSize) {
- const sweepFlag = clockwise ? 1 : 0;
- 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`;
- }
- const circleProps = {
- text: String,
- size: numericProp,
- fill: makeStringProp("none"),
- rate: makeNumericProp(100),
- speed: makeNumericProp(0),
- color: [String, Object],
- clockwise: truthProp,
- layerColor: String,
- currentRate: makeNumberProp(0),
- strokeWidth: makeNumericProp(40),
- strokeLinecap: String,
- startPosition: makeStringProp("top")
- };
- var stdin_default$W = defineComponent({
- name: name$Q,
- props: circleProps,
- emits: ["update:currentRate"],
- setup(props, {
- emit,
- slots
- }) {
- const id = `van-circle-${uid++}`;
- const viewBoxSize = computed(() => +props.strokeWidth + 1e3);
- const path = computed(() => getPath(props.clockwise, viewBoxSize.value));
- const svgStyle = computed(() => {
- const ROTATE_ANGLE_MAP = {
- top: 0,
- right: 90,
- bottom: 180,
- left: 270
- };
- const angleValue = ROTATE_ANGLE_MAP[props.startPosition];
- if (angleValue) {
- return {
- transform: `rotate(${angleValue}deg)`
- };
- }
- });
- watch(() => props.rate, (rate) => {
- let rafId;
- const startTime = Date.now();
- const startRate = props.currentRate;
- const endRate = format(rate);
- const duration = Math.abs((startRate - endRate) * 1e3 / +props.speed);
- const animate = () => {
- const now = Date.now();
- const progress = Math.min((now - startTime) / duration, 1);
- const rate2 = progress * (endRate - startRate) + startRate;
- emit("update:currentRate", format(parseFloat(rate2.toFixed(1))));
- if (endRate > startRate ? rate2 < endRate : rate2 > endRate) {
- rafId = raf(animate);
- }
- };
- if (props.speed) {
- if (rafId) {
- cancelRaf(rafId);
- }
- rafId = raf(animate);
- } else {
- emit("update:currentRate", endRate);
- }
- }, {
- immediate: true
- });
- const renderHover = () => {
- const PERIMETER = 3140;
- const {
- strokeWidth,
- currentRate,
- strokeLinecap
- } = props;
- const offset = PERIMETER * currentRate / 100;
- const color = isObject(props.color) ? `url(#${id})` : props.color;
- const style = {
- stroke: color,
- strokeWidth: `${+strokeWidth + 1}px`,
- strokeLinecap,
- strokeDasharray: `${offset}px ${PERIMETER}px`
- };
- return createVNode("path", {
- "d": path.value,
- "style": style,
- "class": bem$P("hover"),
- "stroke": color
- }, null);
- };
- const renderLayer = () => {
- const style = {
- fill: props.fill,
- stroke: props.layerColor,
- strokeWidth: `${props.strokeWidth}px`
- };
- return createVNode("path", {
- "class": bem$P("layer"),
- "style": style,
- "d": path.value
- }, null);
- };
- const renderGradient = () => {
- const {
- color
- } = props;
- if (!isObject(color)) {
- return;
- }
- const Stops = Object.keys(color).sort((a, b) => parseFloat(a) - parseFloat(b)).map((key, index) => createVNode("stop", {
- "key": index,
- "offset": key,
- "stop-color": color[key]
- }, null));
- return createVNode("defs", null, [createVNode("linearGradient", {
- "id": id,
- "x1": "100%",
- "y1": "0%",
- "x2": "0%",
- "y2": "0%"
- }, [Stops])]);
- };
- const renderText = () => {
- if (slots.default) {
- return slots.default();
- }
- if (props.text) {
- return createVNode("div", {
- "class": bem$P("text")
- }, [props.text]);
- }
- };
- return () => createVNode("div", {
- "class": bem$P(),
- "style": getSizeStyle(props.size)
- }, [createVNode("svg", {
- "viewBox": `0 0 ${viewBoxSize.value} ${viewBoxSize.value}`,
- "style": svgStyle.value
- }, [renderGradient(), renderLayer(), renderHover()]), renderText()]);
- }
- });
- const Circle = withInstall(stdin_default$W);
- const [name$P, bem$O] = createNamespace("row");
- const ROW_KEY = Symbol(name$P);
- const rowProps = {
- tag: makeStringProp("div"),
- wrap: truthProp,
- align: String,
- gutter: makeNumericProp(0),
- justify: String
- };
- var stdin_default$V = defineComponent({
- name: name$P,
- props: rowProps,
- setup(props, {
- slots
- }) {
- const {
- children,
- linkChildren
- } = useChildren(ROW_KEY);
- const groups = computed(() => {
- const groups2 = [[]];
- let totalSpan = 0;
- children.forEach((child, index) => {
- totalSpan += Number(child.span);
- if (totalSpan > 24) {
- groups2.push([index]);
- totalSpan -= 24;
- } else {
- groups2[groups2.length - 1].push(index);
- }
- });
- return groups2;
- });
- const spaces = computed(() => {
- const gutter = Number(props.gutter);
- const spaces2 = [];
- if (!gutter) {
- return spaces2;
- }
- groups.value.forEach((group) => {
- const averagePadding = gutter * (group.length - 1) / group.length;
- group.forEach((item, index) => {
- if (index === 0) {
- spaces2.push({
- right: averagePadding
- });
- } else {
- const left = gutter - spaces2[item - 1].right;
- const right = averagePadding - left;
- spaces2.push({
- left,
- right
- });
- }
- });
- });
- return spaces2;
- });
- linkChildren({
- spaces
- });
- return () => {
- const {
- tag,
- wrap,
- align,
- justify
- } = props;
- return createVNode(tag, {
- "class": bem$O({
- [`align-${align}`]: align,
- [`justify-${justify}`]: justify,
- nowrap: !wrap
- })
- }, {
- default: () => {
- var _a;
- return [(_a = slots.default) == null ? void 0 : _a.call(slots)];
- }
- });
- };
- }
- });
- const [name$O, bem$N] = createNamespace("col");
- const colProps = {
- tag: makeStringProp("div"),
- span: makeNumericProp(0),
- offset: numericProp
- };
- var stdin_default$U = defineComponent({
- name: name$O,
- props: colProps,
- setup(props, {
- slots
- }) {
- const {
- parent,
- index
- } = useParent(ROW_KEY);
- const style = computed(() => {
- if (!parent) {
- return;
- }
- const {
- spaces
- } = parent;
- if (spaces && spaces.value && spaces.value[index.value]) {
- const {
- left,
- right
- } = spaces.value[index.value];
- return {
- paddingLeft: left ? `${left}px` : null,
- paddingRight: right ? `${right}px` : null
- };
- }
- });
- return () => {
- const {
- tag,
- span,
- offset
- } = props;
- return createVNode(tag, {
- "style": style.value,
- "class": bem$N({
- [span]: span,
- [`offset-${offset}`]: offset
- })
- }, {
- default: () => {
- var _a;
- return [(_a = slots.default) == null ? void 0 : _a.call(slots)];
- }
- });
- };
- }
- });
- const Col = withInstall(stdin_default$U);
- const [name$N, bem$M] = createNamespace("collapse");
- const COLLAPSE_KEY = Symbol(name$N);
- const collapseProps = {
- border: truthProp,
- accordion: Boolean,
- modelValue: {
- type: [String, Number, Array],
- default: ""
- }
- };
- function validateModelValue(modelValue, accordion) {
- if (accordion && Array.isArray(modelValue)) {
- console.error('[Vant] Collapse: "v-model" should not be Array in accordion mode');
- return false;
- }
- if (!accordion && !Array.isArray(modelValue)) {
- console.error('[Vant] Collapse: "v-model" should be Array in non-accordion mode');
- return false;
- }
- return true;
- }
- var stdin_default$T = defineComponent({
- name: name$N,
- props: collapseProps,
- emits: ["change", "update:modelValue"],
- setup(props, {
- emit,
- slots
- }) {
- const {
- linkChildren,
- children
- } = useChildren(COLLAPSE_KEY);
- const updateName = (name2) => {
- emit("change", name2);
- emit("update:modelValue", name2);
- };
- const toggle = (name2, expanded) => {
- const {
- accordion,
- modelValue
- } = props;
- if (accordion) {
- updateName(name2 === modelValue ? "" : name2);
- } else if (expanded) {
- updateName(modelValue.concat(name2));
- } else {
- updateName(modelValue.filter((activeName) => activeName !== name2));
- }
- };
- const toggleAll = (options = {}) => {
- if (props.accordion) {
- return;
- }
- if (typeof options === "boolean") {
- options = {
- expanded: options
- };
- }
- const {
- expanded,
- skipDisabled
- } = options;
- const expandedChildren = children.filter((item) => {
- if (item.disabled && skipDisabled) {
- return item.expanded.value;
- }
- return expanded != null ? expanded : !item.expanded.value;
- });
- const names = expandedChildren.map((item) => item.itemName.value);
- updateName(names);
- };
- const isExpanded = (name2) => {
- const {
- accordion,
- modelValue
- } = props;
- if (process.env.NODE_ENV !== "production" && !validateModelValue(modelValue, accordion)) {
- return false;
- }
- return accordion ? modelValue === name2 : modelValue.includes(name2);
- };
- useExpose({
- toggleAll
- });
- linkChildren({
- toggle,
- isExpanded
- });
- return () => {
- var _a;
- return createVNode("div", {
- "class": [bem$M(), {
- [BORDER_TOP_BOTTOM]: props.border
- }]
- }, [(_a = slots.default) == null ? void 0 : _a.call(slots)]);
- };
- }
- });
- const Collapse = withInstall(stdin_default$T);
- const [name$M, bem$L] = createNamespace("collapse-item");
- const CELL_SLOTS = ["icon", "title", "value", "label", "right-icon"];
- const collapseItemProps = extend({}, cellSharedProps, {
- name: numericProp,
- isLink: truthProp,
- disabled: Boolean,
- readonly: Boolean,
- lazyRender: truthProp
- });
- var stdin_default$S = defineComponent({
- name: name$M,
- props: collapseItemProps,
- setup(props, {
- slots
- }) {
- const wrapperRef = ref();
- const contentRef = ref();
- const {
- parent,
- index
- } = useParent(COLLAPSE_KEY);
- if (!parent) {
- if (process.env.NODE_ENV !== "production") {
- console.error("[Vant] <CollapseItem> must be a child component of <Collapse>.");
- }
- return;
- }
- const name2 = computed(() => {
- var _a;
- return (_a = props.name) != null ? _a : index.value;
- });
- const expanded = computed(() => parent.isExpanded(name2.value));
- const show = ref(expanded.value);
- const lazyRender = useLazyRender(() => show.value || !props.lazyRender);
- const onTransitionEnd = () => {
- if (!expanded.value) {
- show.value = false;
- } else if (wrapperRef.value) {
- wrapperRef.value.style.height = "";
- }
- };
- watch(expanded, (value, oldValue) => {
- if (oldValue === null) {
- return;
- }
- if (value) {
- show.value = true;
- }
- const tick = value ? nextTick : raf;
- tick(() => {
- if (!contentRef.value || !wrapperRef.value) {
- return;
- }
- const {
- offsetHeight
- } = contentRef.value;
- if (offsetHeight) {
- const contentHeight = `${offsetHeight}px`;
- wrapperRef.value.style.height = value ? "0" : contentHeight;
- doubleRaf(() => {
- if (wrapperRef.value) {
- wrapperRef.value.style.height = value ? contentHeight : "0";
- }
- });
- } else {
- onTransitionEnd();
- }
- });
- });
- const toggle = (newValue = !expanded.value) => {
- parent.toggle(name2.value, newValue);
- };
- const onClickTitle = () => {
- if (!props.disabled && !props.readonly) {
- toggle();
- }
- };
- const renderTitle = () => {
- const {
- border,
- disabled,
- readonly
- } = props;
- const attrs = pick(props, Object.keys(cellSharedProps));
- if (readonly) {
- attrs.isLink = false;
- }
- if (disabled || readonly) {
- attrs.clickable = false;
- }
- return createVNode(Cell, mergeProps({
- "role": "button",
- "class": bem$L("title", {
- disabled,
- expanded: expanded.value,
- borderless: !border
- }),
- "aria-expanded": String(expanded.value),
- "onClick": onClickTitle
- }, attrs), pick(slots, CELL_SLOTS));
- };
- const renderContent = lazyRender(() => {
- var _a;
- return withDirectives(createVNode("div", {
- "ref": wrapperRef,
- "class": bem$L("wrapper"),
- "onTransitionend": onTransitionEnd
- }, [createVNode("div", {
- "ref": contentRef,
- "class": bem$L("content")
- }, [(_a = slots.default) == null ? void 0 : _a.call(slots)])]), [[vShow, show.value]]);
- });
- useExpose({
- toggle,
- expanded,
- itemName: name2
- });
- return () => createVNode("div", {
- "class": [bem$L({
- border: index.value && props.border
- })]
- }, [renderTitle(), renderContent()]);
- }
- });
- const CollapseItem = withInstall(stdin_default$S);
- const ConfigProvider = withInstall(stdin_default$1A);
- const [name$L, bem$K, t$d] = createNamespace("contact-card");
- const contactCardProps = {
- tel: String,
- name: String,
- type: makeStringProp("add"),
- addText: String,
- editable: truthProp
- };
- var stdin_default$R = defineComponent({
- name: name$L,
- props: contactCardProps,
- emits: ["click"],
- setup(props, {
- emit
- }) {
- const onClick = (event) => {
- if (props.editable) {
- emit("click", event);
- }
- };
- const renderContent = () => {
- if (props.type === "add") {
- return props.addText || t$d("addContact");
- }
- return [createVNode("div", null, [`${t$d("name")}\uFF1A${props.name}`]), createVNode("div", null, [`${t$d("tel")}\uFF1A${props.tel}`])];
- };
- return () => createVNode(Cell, {
- "center": true,
- "icon": props.type === "edit" ? "contact" : "add-square",
- "class": bem$K([props.type]),
- "border": false,
- "isLink": props.editable,
- "valueClass": bem$K("value"),
- "onClick": onClick
- }, {
- value: renderContent
- });
- }
- });
- const ContactCard = withInstall(stdin_default$R);
- const [name$K, bem$J, t$c] = createNamespace("contact-edit");
- const DEFAULT_CONTACT = {
- tel: "",
- name: ""
- };
- const contactEditProps = {
- isEdit: Boolean,
- isSaving: Boolean,
- isDeleting: Boolean,
- showSetDefault: Boolean,
- setDefaultLabel: String,
- contactInfo: {
- type: Object,
- default: () => extend({}, DEFAULT_CONTACT)
- },
- telValidator: {
- type: Function,
- default: isMobile
- }
- };
- var stdin_default$Q = defineComponent({
- name: name$K,
- props: contactEditProps,
- emits: ["save", "delete", "change-default"],
- setup(props, {
- emit
- }) {
- const contact = reactive(extend({}, DEFAULT_CONTACT, props.contactInfo));
- const onSave = () => {
- if (!props.isSaving) {
- emit("save", contact);
- }
- };
- const onDelete = () => emit("delete", contact);
- const renderButtons = () => createVNode("div", {
- "class": bem$J("buttons")
- }, [createVNode(Button, {
- "block": true,
- "round": true,
- "type": "danger",
- "text": t$c("save"),
- "class": bem$J("button"),
- "loading": props.isSaving,
- "nativeType": "submit"
- }, null), props.isEdit && createVNode(Button, {
- "block": true,
- "round": true,
- "text": t$c("delete"),
- "class": bem$J("button"),
- "loading": props.isDeleting,
- "onClick": onDelete
- }, null)]);
- const renderSwitch = () => createVNode(Switch, {
- "modelValue": contact.isDefault,
- "onUpdate:modelValue": ($event) => contact.isDefault = $event,
- "size": 24,
- "onChange": (checked) => emit("change-default", checked)
- }, null);
- const renderSetDefault = () => {
- if (props.showSetDefault) {
- return createVNode(Cell, {
- "title": props.setDefaultLabel,
- "class": bem$J("switch-cell"),
- "border": false
- }, {
- "right-icon": renderSwitch
- });
- }
- };
- watch(() => props.contactInfo, (value) => extend(contact, DEFAULT_CONTACT, value));
- return () => createVNode(Form, {
- "class": bem$J(),
- "onSubmit": onSave
- }, {
- default: () => [createVNode("div", {
- "class": bem$J("fields")
- }, [createVNode(Field, {
- "modelValue": contact.name,
- "onUpdate:modelValue": ($event) => contact.name = $event,
- "clearable": true,
- "label": t$c("name"),
- "rules": [{
- required: true,
- message: t$c("nameEmpty")
- }],
- "maxlength": "30",
- "placeholder": t$c("name")
- }, null), createVNode(Field, {
- "modelValue": contact.tel,
- "onUpdate:modelValue": ($event) => contact.tel = $event,
- "clearable": true,
- "type": "tel",
- "label": t$c("tel"),
- "rules": [{
- validator: props.telValidator,
- message: t$c("telInvalid")
- }],
- "placeholder": t$c("tel")
- }, null)]), renderSetDefault(), renderButtons()]
- });
- }
- });
- const ContactEdit = withInstall(stdin_default$Q);
- const [name$J, bem$I, t$b] = createNamespace("contact-list");
- const contactListProps = {
- list: Array,
- addText: String,
- modelValue: unknownProp,
- defaultTagText: String
- };
- var stdin_default$P = defineComponent({
- name: name$J,
- props: contactListProps,
- emits: ["add", "edit", "select", "update:modelValue"],
- setup(props, {
- emit
- }) {
- const renderItem = (item, index) => {
- const onClick = () => {
- emit("update:modelValue", item.id);
- emit("select", item, index);
- };
- const renderRightIcon = () => createVNode(Radio, {
- "class": bem$I("radio"),
- "name": item.id,
- "iconSize": 16
- }, null);
- const renderEditIcon = () => createVNode(Icon, {
- "name": "edit",
- "class": bem$I("edit"),
- "onClick": (event) => {
- event.stopPropagation();
- emit("edit", item, index);
- }
- }, null);
- const renderContent = () => {
- const nodes = [`${item.name}\uFF0C${item.tel}`];
- if (item.isDefault && props.defaultTagText) {
- nodes.push(createVNode(Tag, {
- "type": "danger",
- "round": true,
- "class": bem$I("item-tag")
- }, {
- default: () => [props.defaultTagText]
- }));
- }
- return nodes;
- };
- return createVNode(Cell, {
- "key": item.id,
- "isLink": true,
- "center": true,
- "class": bem$I("item"),
- "valueClass": bem$I("item-value"),
- "onClick": onClick
- }, {
- icon: renderEditIcon,
- value: renderContent,
- "right-icon": renderRightIcon
- });
- };
- return () => createVNode("div", {
- "class": bem$I()
- }, [createVNode(RadioGroup, {
- "modelValue": props.modelValue,
- "class": bem$I("group")
- }, {
- default: () => [props.list && props.list.map(renderItem)]
- }), createVNode("div", {
- "class": [bem$I("bottom"), "van-safe-area-bottom"]
- }, [createVNode(Button, {
- "round": true,
- "block": true,
- "type": "danger",
- "class": bem$I("add"),
- "text": props.addText || t$b("addContact"),
- "onClick": () => emit("add")
- }, null)])]);
- }
- });
- const ContactList = withInstall(stdin_default$P);
- function parseFormat(format2, currentTime) {
- const { days } = currentTime;
- let { hours, minutes, seconds, milliseconds } = currentTime;
- if (format2.includes("DD")) {
- format2 = format2.replace("DD", padZero(days));
- } else {
- hours += days * 24;
- }
- if (format2.includes("HH")) {
- format2 = format2.replace("HH", padZero(hours));
- } else {
- minutes += hours * 60;
- }
- if (format2.includes("mm")) {
- format2 = format2.replace("mm", padZero(minutes));
- } else {
- seconds += minutes * 60;
- }
- if (format2.includes("ss")) {
- format2 = format2.replace("ss", padZero(seconds));
- } else {
- milliseconds += seconds * 1e3;
- }
- if (format2.includes("S")) {
- const ms = padZero(milliseconds, 3);
- if (format2.includes("SSS")) {
- format2 = format2.replace("SSS", ms);
- } else if (format2.includes("SS")) {
- format2 = format2.replace("SS", ms.slice(0, 2));
- } else {
- format2 = format2.replace("S", ms.charAt(0));
- }
- }
- return format2;
- }
- const [name$I, bem$H] = createNamespace("count-down");
- const countDownProps = {
- time: makeNumericProp(0),
- format: makeStringProp("HH:mm:ss"),
- autoStart: truthProp,
- millisecond: Boolean
- };
- var stdin_default$O = defineComponent({
- name: name$I,
- props: countDownProps,
- emits: ["change", "finish"],
- setup(props, {
- emit,
- slots
- }) {
- const {
- start,
- pause,
- reset,
- current: current2
- } = useCountDown({
- time: +props.time,
- millisecond: props.millisecond,
- onChange: (current22) => emit("change", current22),
- onFinish: () => emit("finish")
- });
- const timeText = computed(() => parseFormat(props.format, current2.value));
- const resetTime = () => {
- reset(+props.time);
- if (props.autoStart) {
- start();
- }
- };
- watch(() => props.time, resetTime, {
- immediate: true
- });
- useExpose({
- start,
- pause,
- reset: resetTime
- });
- return () => createVNode("div", {
- "role": "timer",
- "class": bem$H()
- }, [slots.default ? slots.default(current2.value) : timeText.value]);
- }
- });
- const CountDown = withInstall(stdin_default$O);
- function getDate(timeStamp) {
- const date = new Date(timeStamp * 1e3);
- return `${date.getFullYear()}.${padZero(date.getMonth() + 1)}.${padZero(
- date.getDate()
- )}`;
- }
- const formatDiscount = (discount) => (discount / 10).toFixed(discount % 10 === 0 ? 0 : 1);
- const formatAmount = (amount) => (amount / 100).toFixed(amount % 100 === 0 ? 0 : amount % 10 === 0 ? 1 : 2);
- const [name$H, bem$G, t$a] = createNamespace("coupon");
- var stdin_default$N = defineComponent({
- name: name$H,
- props: {
- chosen: Boolean,
- coupon: makeRequiredProp(Object),
- disabled: Boolean,
- currency: makeStringProp("\xA5")
- },
- setup(props) {
- const validPeriod = computed(() => {
- const {
- startAt,
- endAt
- } = props.coupon;
- return `${getDate(startAt)} - ${getDate(endAt)}`;
- });
- const faceAmount = computed(() => {
- const {
- coupon,
- currency
- } = props;
- if (coupon.valueDesc) {
- return [coupon.valueDesc, createVNode("span", null, [coupon.unitDesc || ""])];
- }
- if (coupon.denominations) {
- const denominations = formatAmount(coupon.denominations);
- return [createVNode("span", null, [currency]), ` ${denominations}`];
- }
- if (coupon.discount) {
- return t$a("discount", formatDiscount(coupon.discount));
- }
- return "";
- });
- const conditionMessage = computed(() => {
- const condition = formatAmount(props.coupon.originCondition || 0);
- return condition === "0" ? t$a("unlimited") : t$a("condition", condition);
- });
- return () => {
- const {
- chosen,
- coupon,
- disabled
- } = props;
- const description = disabled && coupon.reason || coupon.description;
- return createVNode("div", {
- "class": bem$G({
- disabled
- })
- }, [createVNode("div", {
- "class": bem$G("content")
- }, [createVNode("div", {
- "class": bem$G("head")
- }, [createVNode("h2", {
- "class": bem$G("amount")
- }, [faceAmount.value]), createVNode("p", {
- "class": bem$G("condition")
- }, [coupon.condition || conditionMessage.value])]), createVNode("div", {
- "class": bem$G("body")
- }, [createVNode("p", {
- "class": bem$G("name")
- }, [coupon.name]), createVNode("p", {
- "class": bem$G("valid")
- }, [validPeriod.value]), !disabled && createVNode(Checkbox, {
- "class": bem$G("corner"),
- "modelValue": chosen
- }, null)])]), description && createVNode("p", {
- "class": bem$G("description")
- }, [description])]);
- };
- }
- });
- const Coupon = withInstall(stdin_default$N);
- const [name$G, bem$F, t$9] = createNamespace("coupon-cell");
- const couponCellProps = {
- title: String,
- border: truthProp,
- editable: truthProp,
- coupons: makeArrayProp(),
- currency: makeStringProp("\xA5"),
- chosenCoupon: makeNumericProp(-1)
- };
- function formatValue({
- coupons,
- chosenCoupon,
- currency
- }) {
- const coupon = coupons[+chosenCoupon];
- if (coupon) {
- let value = 0;
- if (isDef(coupon.value)) {
- ({
- value
- } = coupon);
- } else if (isDef(coupon.denominations)) {
- value = coupon.denominations;
- }
- return `-${currency} ${(value / 100).toFixed(2)}`;
- }
- return coupons.length === 0 ? t$9("noCoupon") : t$9("count", coupons.length);
- }
- var stdin_default$M = defineComponent({
- name: name$G,
- props: couponCellProps,
- setup(props) {
- return () => {
- const selected = props.coupons[+props.chosenCoupon];
- return createVNode(Cell, {
- "class": bem$F(),
- "value": formatValue(props),
- "title": props.title || t$9("title"),
- "border": props.border,
- "isLink": props.editable,
- "valueClass": bem$F("value", {
- selected
- })
- }, null);
- };
- }
- });
- const CouponCell = withInstall(stdin_default$M);
- const [name$F, bem$E] = createNamespace("empty");
- const emptyProps = {
- image: makeStringProp("default"),
- imageSize: [Number, String, Array],
- description: String
- };
- var stdin_default$L = defineComponent({
- name: name$F,
- props: emptyProps,
- setup(props, {
- slots
- }) {
- const renderDescription = () => {
- const description = slots.description ? slots.description() : props.description;
- if (description) {
- return createVNode("p", {
- "class": bem$E("description")
- }, [description]);
- }
- };
- const renderBottom = () => {
- if (slots.default) {
- return createVNode("div", {
- "class": bem$E("bottom")
- }, [slots.default()]);
- }
- };
- const baseId = useId();
- const getId = (num) => `${baseId}-${num}`;
- const getUrlById = (num) => `url(#${getId(num)})`;
- const renderStop = (color, offset, opacity) => createVNode("stop", {
- "stop-color": color,
- "offset": `${offset}%`,
- "stop-opacity": opacity
- }, null);
- const renderStops = (fromColor, toColor) => [renderStop(fromColor, 0), renderStop(toColor, 100)];
- const renderShadow = (id) => [createVNode("defs", null, [createVNode("radialGradient", {
- "id": getId(id),
- "cx": "50%",
- "cy": "54%",
- "fx": "50%",
- "fy": "54%",
- "r": "297%",
- "gradientTransform": "matrix(-.16 0 0 -.33 .58 .72)"
- }, [renderStop("#EBEDF0", 0), renderStop("#F2F3F5", 100, 0.3)])]), createVNode("ellipse", {
- "fill": getUrlById(id),
- "opacity": ".8",
- "cx": "80",
- "cy": "140",
- "rx": "46",
- "ry": "8"
- }, null)];
- const renderBuilding = () => [createVNode("defs", null, [createVNode("linearGradient", {
- "id": getId("a"),
- "x1": "64%",
- "y1": "100%",
- "x2": "64%"
- }, [renderStop("#FFF", 0, 0.5), renderStop("#F2F3F5", 100)])]), createVNode("g", {
- "opacity": ".8"
- }, [createVNode("path", {
- "d": "M36 131V53H16v20H2v58h34z",
- "fill": getUrlById("a")
- }, null), createVNode("path", {
- "d": "M123 15h22v14h9v77h-31V15z",
- "fill": getUrlById("a")
- }, null)])];
- const renderCloud = () => [createVNode("defs", null, [createVNode("linearGradient", {
- "id": getId("b"),
- "x1": "64%",
- "y1": "97%",
- "x2": "64%",
- "y2": "0%"
- }, [renderStop("#F2F3F5", 0, 0.3), renderStop("#F2F3F5", 100)])]), createVNode("g", {
- "opacity": ".8"
- }, [createVNode("path", {
- "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",
- "fill": getUrlById("b")
- }, null), createVNode("path", {
- "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",
- "fill": getUrlById("b")
- }, null)])];
- const renderNetwork = () => createVNode("svg", {
- "viewBox": "0 0 160 160"
- }, [createVNode("defs", null, [createVNode("linearGradient", {
- "id": getId(1),
- "x1": "64%",
- "y1": "100%",
- "x2": "64%"
- }, [renderStop("#FFF", 0, 0.5), renderStop("#F2F3F5", 100)]), createVNode("linearGradient", {
- "id": getId(2),
- "x1": "50%",
- "x2": "50%",
- "y2": "84%"
- }, [renderStop("#EBEDF0", 0), renderStop("#DCDEE0", 100, 0)]), createVNode("linearGradient", {
- "id": getId(3),
- "x1": "100%",
- "x2": "100%",
- "y2": "100%"
- }, [renderStops("#EAEDF0", "#DCDEE0")]), createVNode("radialGradient", {
- "id": getId(4),
- "cx": "50%",
- "cy": "0%",
- "fx": "50%",
- "fy": "0%",
- "r": "100%",
- "gradientTransform": "matrix(0 1 -.54 0 .5 -.5)"
- }, [renderStop("#EBEDF0", 0), renderStop("#FFF", 100, 0)])]), createVNode("g", {
- "fill": "none"
- }, [renderBuilding(), createVNode("path", {
- "fill": getUrlById(4),
- "d": "M0 139h160v21H0z"
- }, null), createVNode("path", {
- "d": "M80 54a7 7 0 0 1 3 13v27l-2 2h-2a2 2 0 0 1-2-2V67a7 7 0 0 1 3-13z",
- "fill": getUrlById(2)
- }, null), createVNode("g", {
- "opacity": ".6",
- "stroke-linecap": "round",
- "stroke-width": "7"
- }, [createVNode("path", {
- "d": "M64 47a19 19 0 0 0-5 13c0 5 2 10 5 13",
- "stroke": getUrlById(3)
- }, null), createVNode("path", {
- "d": "M53 36a34 34 0 0 0 0 48",
- "stroke": getUrlById(3)
- }, null), createVNode("path", {
- "d": "M95 73a19 19 0 0 0 6-13c0-5-2-9-6-13",
- "stroke": getUrlById(3)
- }, null), createVNode("path", {
- "d": "M106 84a34 34 0 0 0 0-48",
- "stroke": getUrlById(3)
- }, null)]), createVNode("g", {
- "transform": "translate(31 105)"
- }, [createVNode("rect", {
- "fill": "#EBEDF0",
- "width": "98",
- "height": "34",
- "rx": "2"
- }, null), createVNode("rect", {
- "fill": "#FFF",
- "x": "9",
- "y": "8",
- "width": "80",
- "height": "18",
- "rx": "1.1"
- }, null), createVNode("rect", {
- "fill": "#EBEDF0",
- "x": "15",
- "y": "12",
- "width": "18",
- "height": "6",
- "rx": "1.1"
- }, null)])])]);
- const renderMaterial = () => createVNode("svg", {
- "viewBox": "0 0 160 160"
- }, [createVNode("defs", null, [createVNode("linearGradient", {
- "x1": "50%",
- "x2": "50%",
- "y2": "100%",
- "id": getId(5)
- }, [renderStops("#F2F3F5", "#DCDEE0")]), createVNode("linearGradient", {
- "x1": "95%",
- "y1": "48%",
- "x2": "5.5%",
- "y2": "51%",
- "id": getId(6)
- }, [renderStops("#EAEDF1", "#DCDEE0")]), createVNode("linearGradient", {
- "y1": "45%",
- "x2": "100%",
- "y2": "54%",
- "id": getId(7)
- }, [renderStops("#EAEDF1", "#DCDEE0")])]), renderBuilding(), renderCloud(), createVNode("g", {
- "transform": "translate(36 50)",
- "fill": "none"
- }, [createVNode("g", {
- "transform": "translate(8)"
- }, [createVNode("rect", {
- "fill": "#EBEDF0",
- "opacity": ".6",
- "x": "38",
- "y": "13",
- "width": "36",
- "height": "53",
- "rx": "2"
- }, null), createVNode("rect", {
- "fill": getUrlById(5),
- "width": "64",
- "height": "66",
- "rx": "2"
- }, null), createVNode("rect", {
- "fill": "#FFF",
- "x": "6",
- "y": "6",
- "width": "52",
- "height": "55",
- "rx": "1"
- }, null), createVNode("g", {
- "transform": "translate(15 17)",
- "fill": getUrlById(6)
- }, [createVNode("rect", {
- "width": "34",
- "height": "6",
- "rx": "1"
- }, null), createVNode("path", {
- "d": "M0 14h34v6H0z"
- }, null), createVNode("rect", {
- "y": "28",
- "width": "34",
- "height": "6",
- "rx": "1"
- }, null)])]), createVNode("rect", {
- "fill": getUrlById(7),
- "y": "61",
- "width": "88",
- "height": "28",
- "rx": "1"
- }, null), createVNode("rect", {
- "fill": "#F7F8FA",
- "x": "29",
- "y": "72",
- "width": "30",
- "height": "6",
- "rx": "1"
- }, null)])]);
- const renderError = () => createVNode("svg", {
- "viewBox": "0 0 160 160"
- }, [createVNode("defs", null, [createVNode("linearGradient", {
- "x1": "50%",
- "x2": "50%",
- "y2": "100%",
- "id": getId(8)
- }, [renderStops("#EAEDF1", "#DCDEE0")])]), renderBuilding(), renderCloud(), renderShadow("c"), createVNode("path", {
- "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",
- "fill": getUrlById(8)
- }, null)]);
- const renderSearch = () => createVNode("svg", {
- "viewBox": "0 0 160 160"
- }, [createVNode("defs", null, [createVNode("linearGradient", {
- "x1": "50%",
- "y1": "100%",
- "x2": "50%",
- "id": getId(9)
- }, [renderStops("#EEE", "#D8D8D8")]), createVNode("linearGradient", {
- "x1": "100%",
- "y1": "50%",
- "y2": "50%",
- "id": getId(10)
- }, [renderStops("#F2F3F5", "#DCDEE0")]), createVNode("linearGradient", {
- "x1": "50%",
- "x2": "50%",
- "y2": "100%",
- "id": getId(11)
- }, [renderStops("#F2F3F5", "#DCDEE0")]), createVNode("linearGradient", {
- "x1": "50%",
- "x2": "50%",
- "y2": "100%",
- "id": getId(12)
- }, [renderStops("#FFF", "#F7F8FA")])]), renderBuilding(), renderCloud(), renderShadow("d"), createVNode("g", {
- "transform": "rotate(-45 113 -4)",
- "fill": "none"
- }, [createVNode("rect", {
- "fill": getUrlById(9),
- "x": "24",
- "y": "52.8",
- "width": "5.8",
- "height": "19",
- "rx": "1"
- }, null), createVNode("rect", {
- "fill": getUrlById(10),
- "x": "22.1",
- "y": "67.3",
- "width": "9.9",
- "height": "28",
- "rx": "1"
- }, null), createVNode("circle", {
- "stroke": getUrlById(11),
- "stroke-width": "8",
- "cx": "27",
- "cy": "27",
- "r": "27"
- }, null), createVNode("circle", {
- "fill": getUrlById(12),
- "cx": "27",
- "cy": "27",
- "r": "16"
- }, null), createVNode("path", {
- "d": "M37 7c-8 0-15 5-16 12",
- "stroke": getUrlById(11),
- "stroke-width": "3",
- "opacity": ".5",
- "stroke-linecap": "round",
- "transform": "rotate(45 29 13)"
- }, null)])]);
- const renderImage = () => {
- var _a;
- if (slots.image) {
- return slots.image();
- }
- const PRESET_IMAGES = {
- error: renderError,
- search: renderSearch,
- network: renderNetwork,
- default: renderMaterial
- };
- return ((_a = PRESET_IMAGES[props.image]) == null ? void 0 : _a.call(PRESET_IMAGES)) || createVNode("img", {
- "src": props.image
- }, null);
- };
- return () => createVNode("div", {
- "class": bem$E()
- }, [createVNode("div", {
- "class": bem$E("image"),
- "style": getSizeStyle(props.imageSize)
- }, [renderImage()]), renderDescription(), renderBottom()]);
- }
- });
- const Empty = withInstall(stdin_default$L);
- const [name$E, bem$D, t$8] = createNamespace("coupon-list");
- const couponListProps = {
- code: makeStringProp(""),
- coupons: makeArrayProp(),
- currency: makeStringProp("\xA5"),
- showCount: truthProp,
- emptyImage: String,
- chosenCoupon: makeNumberProp(-1),
- enabledTitle: String,
- disabledTitle: String,
- disabledCoupons: makeArrayProp(),
- showExchangeBar: truthProp,
- showCloseButton: truthProp,
- closeButtonText: String,
- inputPlaceholder: String,
- exchangeMinLength: makeNumberProp(1),
- exchangeButtonText: String,
- displayedCouponIndex: makeNumberProp(-1),
- exchangeButtonLoading: Boolean,
- exchangeButtonDisabled: Boolean
- };
- var stdin_default$K = defineComponent({
- name: name$E,
- props: couponListProps,
- emits: ["change", "exchange", "update:code"],
- setup(props, {
- emit,
- slots
- }) {
- const [couponRefs, setCouponRefs] = useRefs();
- const root = ref();
- const barRef = ref();
- const activeTab = ref(0);
- const listHeight = ref(0);
- const currentCode = ref(props.code);
- const buttonDisabled = computed(() => !props.exchangeButtonLoading && (props.exchangeButtonDisabled || !currentCode.value || currentCode.value.length < props.exchangeMinLength));
- const updateListHeight = () => {
- const TABS_HEIGHT = 44;
- const rootHeight = useRect(root).height;
- const headerHeight = useRect(barRef).height + TABS_HEIGHT;
- listHeight.value = (rootHeight > headerHeight ? rootHeight : windowHeight.value) - headerHeight;
- };
- const onExchange = () => {
- emit("exchange", currentCode.value);
- if (!props.code) {
- currentCode.value = "";
- }
- };
- const scrollToCoupon = (index) => {
- nextTick(() => {
- var _a;
- return (_a = couponRefs.value[index]) == null ? void 0 : _a.scrollIntoView();
- });
- };
- const renderEmpty = () => createVNode(Empty, {
- "image": props.emptyImage
- }, {
- default: () => [createVNode("p", {
- "class": bem$D("empty-tip")
- }, [t$8("noCoupon")])]
- });
- const renderExchangeBar = () => {
- if (props.showExchangeBar) {
- return createVNode("div", {
- "ref": barRef,
- "class": bem$D("exchange-bar")
- }, [createVNode(Field, {
- "modelValue": currentCode.value,
- "onUpdate:modelValue": ($event) => currentCode.value = $event,
- "clearable": true,
- "border": false,
- "class": bem$D("field"),
- "placeholder": props.inputPlaceholder || t$8("placeholder"),
- "maxlength": "20"
- }, null), createVNode(Button, {
- "plain": true,
- "type": "danger",
- "class": bem$D("exchange"),
- "text": props.exchangeButtonText || t$8("exchange"),
- "loading": props.exchangeButtonLoading,
- "disabled": buttonDisabled.value,
- "onClick": onExchange
- }, null)]);
- }
- };
- const renderCouponTab = () => {
- const {
- coupons
- } = props;
- const count = props.showCount ? ` (${coupons.length})` : "";
- const title = (props.enabledTitle || t$8("enable")) + count;
- return createVNode(Tab, {
- "title": title
- }, {
- default: () => {
- var _a;
- return [createVNode("div", {
- "class": bem$D("list", {
- "with-bottom": props.showCloseButton
- }),
- "style": {
- height: `${listHeight.value}px`
- }
- }, [coupons.map((coupon, index) => createVNode(Coupon, {
- "key": coupon.id,
- "ref": setCouponRefs(index),
- "coupon": coupon,
- "chosen": index === props.chosenCoupon,
- "currency": props.currency,
- "onClick": () => emit("change", index)
- }, null)), !coupons.length && renderEmpty(), (_a = slots["list-footer"]) == null ? void 0 : _a.call(slots)])];
- }
- });
- };
- const renderDisabledTab = () => {
- const {
- disabledCoupons
- } = props;
- const count = props.showCount ? ` (${disabledCoupons.length})` : "";
- const title = (props.disabledTitle || t$8("disabled")) + count;
- return createVNode(Tab, {
- "title": title
- }, {
- default: () => {
- var _a;
- return [createVNode("div", {
- "class": bem$D("list", {
- "with-bottom": props.showCloseButton
- }),
- "style": {
- height: `${listHeight.value}px`
- }
- }, [disabledCoupons.map((coupon) => createVNode(Coupon, {
- "disabled": true,
- "key": coupon.id,
- "coupon": coupon,
- "currency": props.currency
- }, null)), !disabledCoupons.length && renderEmpty(), (_a = slots["disabled-list-footer"]) == null ? void 0 : _a.call(slots)])];
- }
- });
- };
- watch(() => props.code, (value) => {
- currentCode.value = value;
- });
- watch(windowHeight, updateListHeight);
- watch(currentCode, (value) => emit("update:code", value));
- watch(() => props.displayedCouponIndex, scrollToCoupon);
- onMounted(() => {
- updateListHeight();
- scrollToCoupon(props.displayedCouponIndex);
- });
- return () => createVNode("div", {
- "ref": root,
- "class": bem$D()
- }, [renderExchangeBar(), createVNode(Tabs, {
- "active": activeTab.value,
- "onUpdate:active": ($event) => activeTab.value = $event,
- "class": bem$D("tab")
- }, {
- default: () => [renderCouponTab(), renderDisabledTab()]
- }), createVNode("div", {
- "class": bem$D("bottom")
- }, [withDirectives(createVNode(Button, {
- "round": true,
- "block": true,
- "type": "danger",
- "class": bem$D("close"),
- "text": props.closeButtonText || t$8("close"),
- "onClick": () => emit("change", -1)
- }, null), [[vShow, props.showCloseButton]])])]);
- }
- });
- const CouponList = withInstall(stdin_default$K);
- const [name$D] = createNamespace("time-picker");
- var stdin_default$J = defineComponent({
- name: name$D,
- props: extend({}, sharedProps, {
- minHour: makeNumericProp(0),
- maxHour: makeNumericProp(23),
- minMinute: makeNumericProp(0),
- maxMinute: makeNumericProp(59),
- modelValue: String
- }),
- emits: ["confirm", "cancel", "change", "update:modelValue"],
- setup(props, {
- emit,
- slots
- }) {
- const formatValue2 = (value) => {
- const {
- minHour,
- maxHour,
- maxMinute,
- minMinute
- } = props;
- if (!value) {
- value = `${padZero(minHour)}:${padZero(minMinute)}`;
- }
- let [hour, minute] = value.split(":");
- hour = padZero(clamp(+hour, +minHour, +maxHour));
- minute = padZero(clamp(+minute, +minMinute, +maxMinute));
- return `${hour}:${minute}`;
- };
- const picker = ref();
- const currentDate = ref(formatValue2(props.modelValue));
- const ranges = computed(() => [{
- type: "hour",
- range: [+props.minHour, +props.maxHour]
- }, {
- type: "minute",
- range: [+props.minMinute, +props.maxMinute]
- }]);
- const originColumns = computed(() => ranges.value.map(({
- type,
- range: rangeArr
- }) => {
- let values = times(rangeArr[1] - rangeArr[0] + 1, (index) => padZero(rangeArr[0] + index));
- if (props.filter) {
- values = props.filter(type, values);
- }
- return {
- type,
- values
- };
- }));
- const columns = computed(() => originColumns.value.map((column) => ({
- values: column.values.map((value) => props.formatter(column.type, value))
- })));
- const updateColumnValue = () => {
- const pair = currentDate.value.split(":");
- const values = [props.formatter("hour", pair[0]), props.formatter("minute", pair[1])];
- nextTick(() => {
- var _a;
- (_a = picker.value) == null ? void 0 : _a.setValues(values);
- });
- };
- const updateInnerValue = () => {
- const [hourIndex, minuteIndex] = picker.value.getIndexes();
- const [hourColumn, minuteColumn] = originColumns.value;
- const hour = hourColumn.values[hourIndex] || hourColumn.values[0];
- const minute = minuteColumn.values[minuteIndex] || minuteColumn.values[0];
- currentDate.value = formatValue2(`${hour}:${minute}`);
- updateColumnValue();
- };
- const onConfirm = () => emit("confirm", currentDate.value);
- const onCancel = () => emit("cancel");
- const onChange = () => {
- updateInnerValue();
- nextTick(() => {
- nextTick(() => emit("change", currentDate.value));
- });
- };
- onMounted(() => {
- updateColumnValue();
- nextTick(updateInnerValue);
- });
- watch(columns, updateColumnValue);
- watch(() => [props.filter, props.maxHour, props.minMinute, props.maxMinute], updateInnerValue);
- watch(() => props.minHour, () => {
- nextTick(updateInnerValue);
- });
- watch(currentDate, (value) => emit("update:modelValue", value));
- watch(() => props.modelValue, (value) => {
- value = formatValue2(value);
- if (value !== currentDate.value) {
- currentDate.value = value;
- updateColumnValue();
- }
- });
- useExpose({
- getPicker: () => picker.value && proxyPickerMethods(picker.value, updateInnerValue)
- });
- return () => createVNode(Picker, mergeProps({
- "ref": picker,
- "columns": columns.value,
- "onChange": onChange,
- "onCancel": onCancel,
- "onConfirm": onConfirm
- }, pick(props, pickerInheritKeys)), slots);
- }
- });
- const currentYear = new Date().getFullYear();
- const [name$C] = createNamespace("date-picker");
- var stdin_default$I = defineComponent({
- name: name$C,
- props: extend({}, sharedProps, {
- type: makeStringProp("datetime"),
- modelValue: Date,
- minDate: {
- type: Date,
- default: () => new Date(currentYear - 10, 0, 1),
- validator: isDate
- },
- maxDate: {
- type: Date,
- default: () => new Date(currentYear + 10, 11, 31),
- validator: isDate
- }
- }),
- emits: ["confirm", "cancel", "change", "update:modelValue"],
- setup(props, {
- emit,
- slots
- }) {
- const formatValue2 = (value) => {
- if (isDate(value)) {
- const timestamp = clamp(value.getTime(), props.minDate.getTime(), props.maxDate.getTime());
- return new Date(timestamp);
- }
- return void 0;
- };
- const picker = ref();
- const currentDate = ref(formatValue2(props.modelValue));
- const getBoundary = (type, value) => {
- const boundary = props[`${type}Date`];
- const year = boundary.getFullYear();
- let month = 1;
- let date = 1;
- let hour = 0;
- let minute = 0;
- if (type === "max") {
- month = 12;
- date = getMonthEndDay(value.getFullYear(), value.getMonth() + 1);
- hour = 23;
- minute = 59;
- }
- if (value.getFullYear() === year) {
- month = boundary.getMonth() + 1;
- if (value.getMonth() + 1 === month) {
- date = boundary.getDate();
- if (value.getDate() === date) {
- hour = boundary.getHours();
- if (value.getHours() === hour) {
- minute = boundary.getMinutes();
- }
- }
- }
- }
- return {
- [`${type}Year`]: year,
- [`${type}Month`]: month,
- [`${type}Date`]: date,
- [`${type}Hour`]: hour,
- [`${type}Minute`]: minute
- };
- };
- const ranges = computed(() => {
- const {
- maxYear,
- maxDate,
- maxMonth,
- maxHour,
- maxMinute
- } = getBoundary("max", currentDate.value || props.minDate);
- const {
- minYear,
- minDate,
- minMonth,
- minHour,
- minMinute
- } = getBoundary("min", currentDate.value || props.minDate);
- let result = [{
- type: "year",
- range: [minYear, maxYear]
- }, {
- type: "month",
- range: [minMonth, maxMonth]
- }, {
- type: "day",
- range: [minDate, maxDate]
- }, {
- type: "hour",
- range: [minHour, maxHour]
- }, {
- type: "minute",
- range: [minMinute, maxMinute]
- }];
- switch (props.type) {
- case "date":
- result = result.slice(0, 3);
- break;
- case "year-month":
- result = result.slice(0, 2);
- break;
- case "month-day":
- result = result.slice(1, 3);
- break;
- case "datehour":
- result = result.slice(0, 4);
- break;
- }
- if (props.columnsOrder) {
- const columnsOrder = props.columnsOrder.concat(result.map((column) => column.type));
- result.sort((a, b) => columnsOrder.indexOf(a.type) - columnsOrder.indexOf(b.type));
- }
- return result;
- });
- const originColumns = computed(() => ranges.value.map(({
- type,
- range: rangeArr
- }) => {
- let values = times(rangeArr[1] - rangeArr[0] + 1, (index) => padZero(rangeArr[0] + index));
- if (props.filter) {
- values = props.filter(type, values);
- }
- return {
- type,
- values
- };
- }));
- const columns = computed(() => originColumns.value.map((column) => ({
- values: column.values.map((value) => props.formatter(column.type, value))
- })));
- const updateColumnValue = () => {
- const value = currentDate.value || props.minDate;
- const {
- formatter
- } = props;
- const values = originColumns.value.map((column) => {
- switch (column.type) {
- case "year":
- return formatter("year", `${value.getFullYear()}`);
- case "month":
- return formatter("month", padZero(value.getMonth() + 1));
- case "day":
- return formatter("day", padZero(value.getDate()));
- case "hour":
- return formatter("hour", padZero(value.getHours()));
- case "minute":
- return formatter("minute", padZero(value.getMinutes()));
- default:
- return "";
- }
- });
- nextTick(() => {
- var _a;
- (_a = picker.value) == null ? void 0 : _a.setValues(values);
- });
- };
- const updateInnerValue = () => {
- const {
- type
- } = props;
- const indexes = picker.value.getIndexes();
- const getValue = (type2) => {
- let index = 0;
- originColumns.value.forEach((column, columnIndex) => {
- if (type2 === column.type) {
- index = columnIndex;
- }
- });
- const {
- values
- } = originColumns.value[index];
- return getTrueValue(values[indexes[index]]);
- };
- let year;
- let month;
- let day;
- if (type === "month-day") {
- year = (currentDate.value || props.minDate).getFullYear();
- month = getValue("month");
- day = getValue("day");
- } else {
- year = getValue("year");
- month = getValue("month");
- day = type === "year-month" ? 1 : getValue("day");
- }
- const maxDay = getMonthEndDay(year, month);
- day = day > maxDay ? maxDay : day;
- let hour = 0;
- let minute = 0;
- if (type === "datehour") {
- hour = getValue("hour");
- }
- if (type === "datetime") {
- hour = getValue("hour");
- minute = getValue("minute");
- }
- const value = new Date(year, month - 1, day, hour, minute);
- currentDate.value = formatValue2(value);
- };
- const onConfirm = () => {
- emit("update:modelValue", currentDate.value);
- emit("confirm", currentDate.value);
- };
- const onCancel = () => emit("cancel");
- const onChange = () => {
- updateInnerValue();
- nextTick(() => {
- updateInnerValue();
- nextTick(() => emit("change", currentDate.value));
- });
- };
- onMounted(() => {
- updateColumnValue();
- nextTick(updateInnerValue);
- });
- watch(columns, updateColumnValue);
- watch(currentDate, (value, oldValue) => emit("update:modelValue", oldValue ? value : null));
- watch(() => [props.filter, props.minDate, props.maxDate], () => {
- nextTick(updateInnerValue);
- });
- watch(() => props.modelValue, (value) => {
- var _a;
- value = formatValue2(value);
- if (value && value.valueOf() !== ((_a = currentDate.value) == null ? void 0 : _a.valueOf())) {
- currentDate.value = value;
- }
- });
- useExpose({
- getPicker: () => picker.value && proxyPickerMethods(picker.value, updateInnerValue)
- });
- return () => createVNode(Picker, mergeProps({
- "ref": picker,
- "columns": columns.value,
- "onChange": onChange,
- "onCancel": onCancel,
- "onConfirm": onConfirm
- }, pick(props, pickerInheritKeys)), slots);
- }
- });
- const [name$B, bem$C] = createNamespace("datetime-picker");
- const timePickerPropKeys = Object.keys(stdin_default$J.props);
- const datePickerPropKeys = Object.keys(stdin_default$I.props);
- const datetimePickerProps = extend({}, stdin_default$J.props, stdin_default$I.props, {
- modelValue: [String, Date]
- });
- var stdin_default$H = defineComponent({
- name: name$B,
- props: datetimePickerProps,
- setup(props, {
- attrs,
- slots
- }) {
- const root = ref();
- useExpose({
- getPicker: () => {
- var _a;
- return (_a = root.value) == null ? void 0 : _a.getPicker();
- }
- });
- return () => {
- const isTimePicker = props.type === "time";
- const Component = isTimePicker ? stdin_default$J : stdin_default$I;
- const inheritProps = pick(props, isTimePicker ? timePickerPropKeys : datePickerPropKeys);
- return createVNode(Component, mergeProps({
- "ref": root,
- "class": bem$C()
- }, inheritProps, attrs), slots);
- };
- }
- });
- const DatetimePicker = withInstall(stdin_default$H);
- const [name$A, bem$B, t$7] = createNamespace("dialog");
- const dialogProps = extend({}, popupSharedProps, {
- title: String,
- theme: String,
- width: numericProp,
- message: [String, Function],
- callback: Function,
- allowHtml: Boolean,
- className: unknownProp,
- transition: makeStringProp("van-dialog-bounce"),
- messageAlign: String,
- closeOnPopstate: truthProp,
- showCancelButton: Boolean,
- cancelButtonText: String,
- cancelButtonColor: String,
- cancelButtonDisabled: Boolean,
- confirmButtonText: String,
- confirmButtonColor: String,
- confirmButtonDisabled: Boolean,
- showConfirmButton: truthProp,
- closeOnClickOverlay: Boolean
- });
- const popupInheritKeys$1 = [...popupSharedPropKeys, "transition", "closeOnPopstate"];
- var stdin_default$G = defineComponent({
- name: name$A,
- props: dialogProps,
- emits: ["confirm", "cancel", "keydown", "update:show"],
- setup(props, {
- emit,
- slots
- }) {
- const root = ref();
- const loading = reactive({
- confirm: false,
- cancel: false
- });
- const updateShow = (value) => emit("update:show", value);
- const close = (action) => {
- var _a;
- updateShow(false);
- (_a = props.callback) == null ? void 0 : _a.call(props, action);
- };
- const getActionHandler = (action) => () => {
- if (!props.show) {
- return;
- }
- emit(action);
- if (props.beforeClose) {
- loading[action] = true;
- callInterceptor(props.beforeClose, {
- args: [action],
- done() {
- close(action);
- loading[action] = false;
- },
- canceled() {
- loading[action] = false;
- }
- });
- } else {
- close(action);
- }
- };
- const onCancel = getActionHandler("cancel");
- const onConfirm = getActionHandler("confirm");
- const onKeydown = withKeys((event) => {
- var _a, _b;
- if (event.target !== ((_b = (_a = root.value) == null ? void 0 : _a.popupRef) == null ? void 0 : _b.value)) {
- return;
- }
- const onEventType = {
- Enter: props.showConfirmButton ? onConfirm : noop,
- Escape: props.showCancelButton ? onCancel : noop
- };
- onEventType[event.key]();
- emit("keydown", event);
- }, ["enter", "esc"]);
- const renderTitle = () => {
- const title = slots.title ? slots.title() : props.title;
- if (title) {
- return createVNode("div", {
- "class": bem$B("header", {
- isolated: !props.message && !slots.default
- })
- }, [title]);
- }
- };
- const renderMessage = (hasTitle) => {
- const {
- message,
- allowHtml,
- messageAlign
- } = props;
- const classNames = bem$B("message", {
- "has-title": hasTitle,
- [messageAlign]: messageAlign
- });
- const content = isFunction(message) ? message() : message;
- if (allowHtml && typeof content === "string") {
- return createVNode("div", {
- "class": classNames,
- "innerHTML": content
- }, null);
- }
- return createVNode("div", {
- "class": classNames
- }, [content]);
- };
- const renderContent = () => {
- if (slots.default) {
- return createVNode("div", {
- "class": bem$B("content")
- }, [slots.default()]);
- }
- const {
- title,
- message,
- allowHtml
- } = props;
- if (message) {
- const hasTitle = !!(title || slots.title);
- return createVNode("div", {
- "key": allowHtml ? 1 : 0,
- "class": bem$B("content", {
- isolated: !hasTitle
- })
- }, [renderMessage(hasTitle)]);
- }
- };
- const renderButtons = () => createVNode("div", {
- "class": [BORDER_TOP, bem$B("footer")]
- }, [props.showCancelButton && createVNode(Button, {
- "size": "large",
- "text": props.cancelButtonText || t$7("cancel"),
- "class": bem$B("cancel"),
- "style": {
- color: props.cancelButtonColor
- },
- "loading": loading.cancel,
- "disabled": props.cancelButtonDisabled,
- "onClick": onCancel
- }, null), props.showConfirmButton && createVNode(Button, {
- "size": "large",
- "text": props.confirmButtonText || t$7("confirm"),
- "class": [bem$B("confirm"), {
- [BORDER_LEFT]: props.showCancelButton
- }],
- "style": {
- color: props.confirmButtonColor
- },
- "loading": loading.confirm,
- "disabled": props.confirmButtonDisabled,
- "onClick": onConfirm
- }, null)]);
- const renderRoundButtons = () => createVNode(ActionBar, {
- "class": bem$B("footer")
- }, {
- default: () => [props.showCancelButton && createVNode(ActionBarButton, {
- "type": "warning",
- "text": props.cancelButtonText || t$7("cancel"),
- "class": bem$B("cancel"),
- "color": props.cancelButtonColor,
- "loading": loading.cancel,
- "disabled": props.cancelButtonDisabled,
- "onClick": onCancel
- }, null), props.showConfirmButton && createVNode(ActionBarButton, {
- "type": "danger",
- "text": props.confirmButtonText || t$7("confirm"),
- "class": bem$B("confirm"),
- "color": props.confirmButtonColor,
- "loading": loading.confirm,
- "disabled": props.confirmButtonDisabled,
- "onClick": onConfirm
- }, null)]
- });
- const renderFooter = () => {
- if (slots.footer) {
- return slots.footer();
- }
- return props.theme === "round-button" ? renderRoundButtons() : renderButtons();
- };
- return () => {
- const {
- width,
- title,
- theme,
- message,
- className
- } = props;
- return createVNode(Popup, mergeProps({
- "ref": root,
- "role": "dialog",
- "class": [bem$B([theme]), className],
- "style": {
- width: addUnit(width)
- },
- "tabindex": 0,
- "aria-labelledby": title || message,
- "onKeydown": onKeydown,
- "onUpdate:show": updateShow
- }, pick(props, popupInheritKeys$1)), {
- default: () => [renderTitle(), renderContent(), renderFooter()]
- });
- };
- }
- });
- let instance$2;
- function initInstance$2() {
- const Wrapper = {
- setup() {
- const {
- state,
- toggle
- } = usePopupState();
- return () => createVNode(stdin_default$G, mergeProps(state, {
- "onUpdate:show": toggle
- }), null);
- }
- };
- ({
- instance: instance$2
- } = mountComponent(Wrapper));
- }
- function Dialog(options) {
- if (!inBrowser) {
- return Promise.resolve();
- }
- return new Promise((resolve, reject) => {
- if (!instance$2) {
- initInstance$2();
- }
- instance$2.open(extend({}, Dialog.currentOptions, options, {
- callback: (action) => {
- (action === "confirm" ? resolve : reject)(action);
- }
- }));
- });
- }
- Dialog.defaultOptions = {
- title: "",
- width: "",
- theme: null,
- message: "",
- overlay: true,
- callback: null,
- teleport: "body",
- className: "",
- allowHtml: false,
- lockScroll: true,
- transition: void 0,
- beforeClose: null,
- overlayClass: "",
- overlayStyle: void 0,
- messageAlign: "",
- cancelButtonText: "",
- cancelButtonColor: null,
- cancelButtonDisabled: false,
- confirmButtonText: "",
- confirmButtonColor: null,
- confirmButtonDisabled: false,
- showConfirmButton: true,
- showCancelButton: false,
- closeOnPopstate: true,
- closeOnClickOverlay: false
- };
- Dialog.currentOptions = extend({}, Dialog.defaultOptions);
- Dialog.alert = Dialog;
- Dialog.confirm = (options) => Dialog(extend({
- showCancelButton: true
- }, options));
- Dialog.close = () => {
- if (instance$2) {
- instance$2.toggle(false);
- }
- };
- Dialog.setDefaultOptions = (options) => {
- extend(Dialog.currentOptions, options);
- };
- Dialog.resetDefaultOptions = () => {
- Dialog.currentOptions = extend({}, Dialog.defaultOptions);
- };
- Dialog.Component = withInstall(stdin_default$G);
- Dialog.install = (app) => {
- app.use(Dialog.Component);
- app.config.globalProperties.$dialog = Dialog;
- };
- const [name$z, bem$A] = createNamespace("divider");
- const dividerProps = {
- dashed: Boolean,
- hairline: truthProp,
- contentPosition: makeStringProp("center")
- };
- var stdin_default$F = defineComponent({
- name: name$z,
- props: dividerProps,
- setup(props, {
- slots
- }) {
- return () => {
- var _a;
- return createVNode("div", {
- "role": "separator",
- "class": bem$A({
- dashed: props.dashed,
- hairline: props.hairline,
- [`content-${props.contentPosition}`]: !!slots.default
- })
- }, [(_a = slots.default) == null ? void 0 : _a.call(slots)]);
- };
- }
- });
- const Divider = withInstall(stdin_default$F);
- const [name$y, bem$z] = createNamespace("dropdown-menu");
- const dropdownMenuProps = {
- overlay: truthProp,
- zIndex: numericProp,
- duration: makeNumericProp(0.2),
- direction: makeStringProp("down"),
- activeColor: String,
- closeOnClickOutside: truthProp,
- closeOnClickOverlay: truthProp
- };
- const DROPDOWN_KEY = Symbol(name$y);
- var stdin_default$E = defineComponent({
- name: name$y,
- props: dropdownMenuProps,
- setup(props, {
- slots
- }) {
- const id = useId();
- const root = ref();
- const barRef = ref();
- const offset = ref(0);
- const {
- children,
- linkChildren
- } = useChildren(DROPDOWN_KEY);
- const scrollParent = useScrollParent(root);
- const opened = computed(() => children.some((item) => item.state.showWrapper));
- const barStyle = computed(() => {
- if (opened.value && isDef(props.zIndex)) {
- return {
- zIndex: +props.zIndex + 1
- };
- }
- });
- const onClickAway = () => {
- if (props.closeOnClickOutside) {
- children.forEach((item) => {
- item.toggle(false);
- });
- }
- };
- const updateOffset = () => {
- if (barRef.value) {
- const rect = useRect(barRef);
- if (props.direction === "down") {
- offset.value = rect.bottom;
- } else {
- offset.value = windowHeight.value - rect.top;
- }
- }
- };
- const onScroll = () => {
- if (opened.value) {
- updateOffset();
- }
- };
- const toggleItem = (active) => {
- children.forEach((item, index) => {
- if (index === active) {
- updateOffset();
- item.toggle();
- } else if (item.state.showPopup) {
- item.toggle(false, {
- immediate: true
- });
- }
- });
- };
- const renderTitle = (item, index) => {
- const {
- showPopup
- } = item.state;
- const {
- disabled,
- titleClass
- } = item;
- return createVNode("div", {
- "id": `${id}-${index}`,
- "role": "button",
- "tabindex": disabled ? void 0 : 0,
- "class": [bem$z("item", {
- disabled
- }), {
- [HAPTICS_FEEDBACK]: !disabled
- }],
- "onClick": () => {
- if (!disabled) {
- toggleItem(index);
- }
- }
- }, [createVNode("span", {
- "class": [bem$z("title", {
- down: showPopup === (props.direction === "down"),
- active: showPopup
- }), titleClass],
- "style": {
- color: showPopup ? props.activeColor : ""
- }
- }, [createVNode("div", {
- "class": "van-ellipsis"
- }, [item.renderTitle()])])]);
- };
- linkChildren({
- id,
- props,
- offset
- });
- useClickAway(root, onClickAway);
- useEventListener("scroll", onScroll, {
- target: scrollParent,
- passive: true
- });
- return () => {
- var _a;
- return createVNode("div", {
- "ref": root,
- "class": bem$z()
- }, [createVNode("div", {
- "ref": barRef,
- "style": barStyle.value,
- "class": bem$z("bar", {
- opened: opened.value
- })
- }, [children.map(renderTitle)]), (_a = slots.default) == null ? void 0 : _a.call(slots)]);
- };
- }
- });
- const [name$x, bem$y] = createNamespace("dropdown-item");
- const dropdownItemProps = {
- title: String,
- options: makeArrayProp(),
- disabled: Boolean,
- teleport: [String, Object],
- lazyRender: truthProp,
- modelValue: unknownProp,
- titleClass: unknownProp
- };
- var stdin_default$D = defineComponent({
- name: name$x,
- props: dropdownItemProps,
- emits: ["open", "opened", "close", "closed", "change", "update:modelValue"],
- setup(props, {
- emit,
- slots
- }) {
- const state = reactive({
- showPopup: false,
- transition: true,
- showWrapper: false
- });
- const {
- parent,
- index
- } = useParent(DROPDOWN_KEY);
- if (!parent) {
- if (process.env.NODE_ENV !== "production") {
- console.error("[Vant] <DropdownItem> must be a child component of <DropdownMenu>.");
- }
- return;
- }
- const getEmitter = (name2) => () => emit(name2);
- const onOpen = getEmitter("open");
- const onClose = getEmitter("close");
- const onOpened = getEmitter("opened");
- const onClosed = () => {
- state.showWrapper = false;
- emit("closed");
- };
- const onClickWrapper = (event) => {
- if (props.teleport) {
- event.stopPropagation();
- }
- };
- const toggle = (show = !state.showPopup, options = {}) => {
- if (show === state.showPopup) {
- return;
- }
- state.showPopup = show;
- state.transition = !options.immediate;
- if (show) {
- state.showWrapper = true;
- }
- };
- const renderTitle = () => {
- if (slots.title) {
- return slots.title();
- }
- if (props.title) {
- return props.title;
- }
- const match = props.options.find((option) => option.value === props.modelValue);
- return match ? match.text : "";
- };
- const renderOption = (option) => {
- const {
- activeColor
- } = parent.props;
- const active = option.value === props.modelValue;
- const onClick = () => {
- state.showPopup = false;
- if (option.value !== props.modelValue) {
- emit("update:modelValue", option.value);
- emit("change", option.value);
- }
- };
- const renderIcon = () => {
- if (active) {
- return createVNode(Icon, {
- "class": bem$y("icon"),
- "color": activeColor,
- "name": "success"
- }, null);
- }
- };
- return createVNode(Cell, {
- "role": "menuitem",
- "key": option.value,
- "icon": option.icon,
- "title": option.text,
- "class": bem$y("option", {
- active
- }),
- "style": {
- color: active ? activeColor : ""
- },
- "tabindex": active ? 0 : -1,
- "clickable": true,
- "onClick": onClick
- }, {
- value: renderIcon
- });
- };
- const renderContent = () => {
- const {
- offset
- } = parent;
- const {
- zIndex,
- overlay,
- duration,
- direction,
- closeOnClickOverlay
- } = parent.props;
- const style = getZIndexStyle(zIndex);
- if (direction === "down") {
- style.top = `${offset.value}px`;
- } else {
- style.bottom = `${offset.value}px`;
- }
- return withDirectives(createVNode("div", {
- "style": style,
- "class": bem$y([direction]),
- "onClick": onClickWrapper
- }, [createVNode(Popup, {
- "show": state.showPopup,
- "onUpdate:show": ($event) => state.showPopup = $event,
- "role": "menu",
- "class": bem$y("content"),
- "overlay": overlay,
- "position": direction === "down" ? "top" : "bottom",
- "duration": state.transition ? duration : 0,
- "lazyRender": props.lazyRender,
- "overlayStyle": {
- position: "absolute"
- },
- "aria-labelledby": `${parent.id}-${index.value}`,
- "closeOnClickOverlay": closeOnClickOverlay,
- "onOpen": onOpen,
- "onClose": onClose,
- "onOpened": onOpened,
- "onClosed": onClosed
- }, {
- default: () => {
- var _a;
- return [props.options.map(renderOption), (_a = slots.default) == null ? void 0 : _a.call(slots)];
- }
- })]), [[vShow, state.showWrapper]]);
- };
- useExpose({
- state,
- toggle,
- renderTitle
- });
- return () => {
- if (props.teleport) {
- return createVNode(Teleport, {
- "to": props.teleport
- }, {
- default: () => [renderContent()]
- });
- }
- return renderContent();
- };
- }
- });
- const DropdownItem = withInstall(stdin_default$D);
- const DropdownMenu = withInstall(stdin_default$E);
- const [name$w, bem$x] = createNamespace("grid");
- const gridProps = {
- square: Boolean,
- center: truthProp,
- border: truthProp,
- gutter: numericProp,
- reverse: Boolean,
- iconSize: numericProp,
- direction: String,
- clickable: Boolean,
- columnNum: makeNumericProp(4)
- };
- const GRID_KEY = Symbol(name$w);
- var stdin_default$C = defineComponent({
- name: name$w,
- props: gridProps,
- setup(props, {
- slots
- }) {
- const {
- linkChildren
- } = useChildren(GRID_KEY);
- linkChildren({
- props
- });
- return () => {
- var _a;
- return createVNode("div", {
- "style": {
- paddingLeft: addUnit(props.gutter)
- },
- "class": [bem$x(), {
- [BORDER_TOP]: props.border && !props.gutter
- }]
- }, [(_a = slots.default) == null ? void 0 : _a.call(slots)]);
- };
- }
- });
- const Grid = withInstall(stdin_default$C);
- const [name$v, bem$w] = createNamespace("grid-item");
- const gridItemProps = extend({}, routeProps, {
- dot: Boolean,
- text: String,
- icon: String,
- badge: numericProp,
- iconColor: String,
- iconPrefix: String,
- badgeProps: Object
- });
- var stdin_default$B = defineComponent({
- name: name$v,
- props: gridItemProps,
- setup(props, {
- slots
- }) {
- const {
- parent,
- index
- } = useParent(GRID_KEY);
- const route2 = useRoute();
- if (!parent) {
- if (process.env.NODE_ENV !== "production") {
- console.error("[Vant] <GridItem> must be a child component of <Grid>.");
- }
- return;
- }
- const rootStyle = computed(() => {
- const {
- square,
- gutter,
- columnNum
- } = parent.props;
- const percent = `${100 / +columnNum}%`;
- const style = {
- flexBasis: percent
- };
- if (square) {
- style.paddingTop = percent;
- } else if (gutter) {
- const gutterValue = addUnit(gutter);
- style.paddingRight = gutterValue;
- if (index.value >= columnNum) {
- style.marginTop = gutterValue;
- }
- }
- return style;
- });
- const contentStyle = computed(() => {
- const {
- square,
- gutter
- } = parent.props;
- if (square && gutter) {
- const gutterValue = addUnit(gutter);
- return {
- right: gutterValue,
- bottom: gutterValue,
- height: "auto"
- };
- }
- });
- const renderIcon = () => {
- if (slots.icon) {
- return createVNode(Badge, mergeProps({
- "dot": props.dot,
- "content": props.badge
- }, props.badgeProps), {
- default: slots.icon
- });
- }
- if (props.icon) {
- return createVNode(Icon, {
- "dot": props.dot,
- "name": props.icon,
- "size": parent.props.iconSize,
- "badge": props.badge,
- "class": bem$w("icon"),
- "color": props.iconColor,
- "badgeProps": props.badgeProps,
- "classPrefix": props.iconPrefix
- }, null);
- }
- };
- const renderText = () => {
- if (slots.text) {
- return slots.text();
- }
- if (props.text) {
- return createVNode("span", {
- "class": bem$w("text")
- }, [props.text]);
- }
- };
- const renderContent = () => {
- if (slots.default) {
- return slots.default();
- }
- return [renderIcon(), renderText()];
- };
- return () => {
- const {
- center,
- border,
- square,
- gutter,
- reverse,
- direction,
- clickable
- } = parent.props;
- const classes = [bem$w("content", [direction, {
- center,
- square,
- reverse,
- clickable,
- surround: border && gutter
- }]), {
- [BORDER]: border
- }];
- return createVNode("div", {
- "class": [bem$w({
- square
- })],
- "style": rootStyle.value
- }, [createVNode("div", {
- "role": clickable ? "button" : void 0,
- "class": classes,
- "style": contentStyle.value,
- "tabindex": clickable ? 0 : void 0,
- "onClick": route2
- }, [renderContent()])]);
- };
- }
- });
- const GridItem = withInstall(stdin_default$B);
- const getDistance = (touches) => Math.sqrt((touches[0].clientX - touches[1].clientX) ** 2 + (touches[0].clientY - touches[1].clientY) ** 2);
- const bem$v = createNamespace("image-preview")[1];
- var stdin_default$A = defineComponent({
- props: {
- src: String,
- show: Boolean,
- active: Number,
- minZoom: makeRequiredProp(numericProp),
- maxZoom: makeRequiredProp(numericProp),
- rootWidth: makeRequiredProp(Number),
- rootHeight: makeRequiredProp(Number)
- },
- emits: ["scale", "close"],
- setup(props, {
- emit,
- slots
- }) {
- const state = reactive({
- scale: 1,
- moveX: 0,
- moveY: 0,
- moving: false,
- zooming: false,
- imageRatio: 0,
- displayWidth: 0,
- displayHeight: 0
- });
- const touch = useTouch();
- const swipeItem = ref();
- const vertical = computed(() => {
- const {
- rootWidth,
- rootHeight
- } = props;
- const rootRatio = rootHeight / rootWidth;
- return state.imageRatio > rootRatio;
- });
- const imageStyle = computed(() => {
- const {
- scale,
- moveX,
- moveY,
- moving,
- zooming
- } = state;
- const style = {
- transitionDuration: zooming || moving ? "0s" : ".3s"
- };
- if (scale !== 1) {
- const offsetX = moveX / scale;
- const offsetY = moveY / scale;
- style.transform = `scale(${scale}, ${scale}) translate(${offsetX}px, ${offsetY}px)`;
- }
- return style;
- });
- const maxMoveX = computed(() => {
- if (state.imageRatio) {
- const {
- rootWidth,
- rootHeight
- } = props;
- const displayWidth = vertical.value ? rootHeight / state.imageRatio : rootWidth;
- return Math.max(0, (state.scale * displayWidth - rootWidth) / 2);
- }
- return 0;
- });
- const maxMoveY = computed(() => {
- if (state.imageRatio) {
- const {
- rootWidth,
- rootHeight
- } = props;
- const displayHeight = vertical.value ? rootHeight : rootWidth * state.imageRatio;
- return Math.max(0, (state.scale * displayHeight - rootHeight) / 2);
- }
- return 0;
- });
- const setScale = (scale) => {
- scale = clamp(scale, +props.minZoom, +props.maxZoom + 1);
- if (scale !== state.scale) {
- state.scale = scale;
- emit("scale", {
- scale,
- index: props.active
- });
- }
- };
- const resetScale = () => {
- setScale(1);
- state.moveX = 0;
- state.moveY = 0;
- };
- const toggleScale = () => {
- const scale = state.scale > 1 ? 1 : 2;
- setScale(scale);
- state.moveX = 0;
- state.moveY = 0;
- };
- let fingerNum;
- let startMoveX;
- let startMoveY;
- let startScale;
- let startDistance;
- let doubleTapTimer;
- let touchStartTime;
- const onTouchStart = (event) => {
- const {
- touches
- } = event;
- const {
- offsetX
- } = touch;
- touch.start(event);
- fingerNum = touches.length;
- startMoveX = state.moveX;
- startMoveY = state.moveY;
- touchStartTime = Date.now();
- state.moving = fingerNum === 1 && state.scale !== 1;
- state.zooming = fingerNum === 2 && !offsetX.value;
- if (state.zooming) {
- startScale = state.scale;
- startDistance = getDistance(event.touches);
- }
- };
- const onTouchMove = (event) => {
- const {
- touches
- } = event;
- touch.move(event);
- if (state.moving || state.zooming) {
- preventDefault(event, true);
- }
- if (state.moving) {
- const {
- deltaX,
- deltaY
- } = touch;
- const moveX = deltaX.value + startMoveX;
- const moveY = deltaY.value + startMoveY;
- state.moveX = clamp(moveX, -maxMoveX.value, maxMoveX.value);
- state.moveY = clamp(moveY, -maxMoveY.value, maxMoveY.value);
- }
- if (state.zooming && touches.length === 2) {
- const distance = getDistance(touches);
- const scale = startScale * distance / startDistance;
- setScale(scale);
- }
- };
- const checkTap = () => {
- if (fingerNum > 1) {
- return;
- }
- const {
- offsetX,
- offsetY
- } = touch;
- const deltaTime = Date.now() - touchStartTime;
- const TAP_TIME = 250;
- const TAP_OFFSET = 5;
- if (offsetX.value < TAP_OFFSET && offsetY.value < TAP_OFFSET && deltaTime < TAP_TIME) {
- if (doubleTapTimer) {
- clearTimeout(doubleTapTimer);
- doubleTapTimer = null;
- toggleScale();
- } else {
- doubleTapTimer = setTimeout(() => {
- emit("close");
- doubleTapTimer = null;
- }, TAP_TIME);
- }
- }
- };
- const onTouchEnd = (event) => {
- let stopPropagation2 = false;
- if (state.moving || state.zooming) {
- stopPropagation2 = true;
- if (state.moving && startMoveX === state.moveX && startMoveY === state.moveY) {
- stopPropagation2 = false;
- }
- if (!event.touches.length) {
- if (state.zooming) {
- state.moveX = clamp(state.moveX, -maxMoveX.value, maxMoveX.value);
- state.moveY = clamp(state.moveY, -maxMoveY.value, maxMoveY.value);
- state.zooming = false;
- }
- state.moving = false;
- startMoveX = 0;
- startMoveY = 0;
- startScale = 1;
- if (state.scale < 1) {
- resetScale();
- }
- if (state.scale > props.maxZoom) {
- state.scale = +props.maxZoom;
- }
- }
- }
- preventDefault(event, stopPropagation2);
- checkTap();
- touch.reset();
- };
- const onLoad = (event) => {
- const {
- naturalWidth,
- naturalHeight
- } = event.target;
- state.imageRatio = naturalHeight / naturalWidth;
- };
- watch(() => props.active, resetScale);
- watch(() => props.show, (value) => {
- if (!value) {
- resetScale();
- }
- });
- useEventListener("touchmove", onTouchMove, {
- target: computed(() => {
- var _a;
- return (_a = swipeItem.value) == null ? void 0 : _a.$el;
- })
- });
- return () => {
- const imageSlots = {
- loading: () => createVNode(Loading, {
- "type": "spinner"
- }, null)
- };
- return createVNode(SwipeItem, {
- "ref": swipeItem,
- "class": bem$v("swipe-item"),
- "onTouchstartPassive": onTouchStart,
- "onTouchend": onTouchEnd,
- "onTouchcancel": onTouchEnd
- }, {
- default: () => [slots.image ? createVNode("div", {
- "class": bem$v("image-wrap")
- }, [slots.image({
- src: props.src
- })]) : createVNode(Image$1, {
- "src": props.src,
- "fit": "contain",
- "class": bem$v("image", {
- vertical: vertical.value
- }),
- "style": imageStyle.value,
- "onLoad": onLoad
- }, imageSlots)]
- });
- };
- }
- });
- const [name$u, bem$u] = createNamespace("image-preview");
- const popupProps$1 = ["show", "transition", "overlayStyle", "closeOnPopstate"];
- const imagePreviewProps = {
- show: Boolean,
- loop: truthProp,
- images: makeArrayProp(),
- minZoom: makeNumericProp(1 / 3),
- maxZoom: makeNumericProp(3),
- overlay: truthProp,
- closeable: Boolean,
- showIndex: truthProp,
- className: unknownProp,
- closeIcon: makeStringProp("clear"),
- transition: String,
- beforeClose: Function,
- overlayClass: unknownProp,
- overlayStyle: Object,
- swipeDuration: makeNumericProp(300),
- startPosition: makeNumericProp(0),
- showIndicators: Boolean,
- closeOnPopstate: truthProp,
- closeIconPosition: makeStringProp("top-right")
- };
- var stdin_default$z = defineComponent({
- name: name$u,
- props: imagePreviewProps,
- emits: ["scale", "close", "closed", "change", "update:show"],
- setup(props, {
- emit,
- slots
- }) {
- const swipeRef = ref();
- const state = reactive({
- active: 0,
- rootWidth: 0,
- rootHeight: 0
- });
- const resize = () => {
- if (swipeRef.value) {
- const rect = useRect(swipeRef.value.$el);
- state.rootWidth = rect.width;
- state.rootHeight = rect.height;
- swipeRef.value.resize();
- }
- };
- const emitScale = (args) => emit("scale", args);
- const updateShow = (show) => emit("update:show", show);
- const emitClose = () => {
- callInterceptor(props.beforeClose, {
- args: [state.active],
- done: () => updateShow(false)
- });
- };
- const setActive = (active) => {
- if (active !== state.active) {
- state.active = active;
- emit("change", active);
- }
- };
- const renderIndex = () => {
- if (props.showIndex) {
- return createVNode("div", {
- "class": bem$u("index")
- }, [slots.index ? slots.index({
- index: state.active
- }) : `${state.active + 1} / ${props.images.length}`]);
- }
- };
- const renderCover = () => {
- if (slots.cover) {
- return createVNode("div", {
- "class": bem$u("cover")
- }, [slots.cover()]);
- }
- };
- const renderImages = () => createVNode(Swipe, {
- "ref": swipeRef,
- "lazyRender": true,
- "loop": props.loop,
- "class": bem$u("swipe"),
- "duration": props.swipeDuration,
- "initialSwipe": props.startPosition,
- "showIndicators": props.showIndicators,
- "indicatorColor": "white",
- "onChange": setActive
- }, {
- default: () => [props.images.map((image) => createVNode(stdin_default$A, {
- "src": image,
- "show": props.show,
- "active": state.active,
- "maxZoom": props.maxZoom,
- "minZoom": props.minZoom,
- "rootWidth": state.rootWidth,
- "rootHeight": state.rootHeight,
- "onScale": emitScale,
- "onClose": emitClose
- }, {
- image: slots.image
- }))]
- });
- const renderClose = () => {
- if (props.closeable) {
- return createVNode(Icon, {
- "role": "button",
- "name": props.closeIcon,
- "class": [bem$u("close-icon", props.closeIconPosition), HAPTICS_FEEDBACK],
- "onClick": emitClose
- }, null);
- }
- };
- const onClosed = () => emit("closed");
- const swipeTo = (index, options) => {
- var _a;
- return (_a = swipeRef.value) == null ? void 0 : _a.swipeTo(index, options);
- };
- useExpose({
- swipeTo
- });
- onMounted(resize);
- watch([windowWidth, windowHeight], resize);
- watch(() => props.startPosition, (value) => setActive(+value));
- watch(() => props.show, (value) => {
- const {
- images,
- startPosition
- } = props;
- if (value) {
- setActive(+startPosition);
- nextTick(() => {
- resize();
- swipeTo(+startPosition, {
- immediate: true
- });
- });
- } else {
- emit("close", {
- index: state.active,
- url: images[state.active]
- });
- }
- });
- return () => createVNode(Popup, mergeProps({
- "class": [bem$u(), props.className],
- "overlayClass": [bem$u("overlay"), props.overlayClass],
- "onClosed": onClosed,
- "onUpdate:show": updateShow
- }, pick(props, popupProps$1)), {
- default: () => [renderClose(), renderImages(), renderIndex(), renderCover()]
- });
- }
- });
- let instance$1;
- const defaultConfig = {
- loop: true,
- images: [],
- maxZoom: 3,
- minZoom: 1 / 3,
- onScale: void 0,
- onClose: void 0,
- onChange: void 0,
- teleport: "body",
- className: "",
- showIndex: true,
- closeable: false,
- closeIcon: "clear",
- transition: void 0,
- beforeClose: void 0,
- overlayStyle: void 0,
- overlayClass: void 0,
- startPosition: 0,
- swipeDuration: 300,
- showIndicators: false,
- closeOnPopstate: true,
- closeIconPosition: "top-right"
- };
- function initInstance$1() {
- ({
- instance: instance$1
- } = mountComponent({
- setup() {
- const {
- state,
- toggle
- } = usePopupState();
- const onClosed = () => {
- state.images = [];
- };
- return () => createVNode(stdin_default$z, mergeProps(state, {
- "onClosed": onClosed,
- "onUpdate:show": toggle
- }), null);
- }
- }));
- }
- const ImagePreview = (options, startPosition = 0) => {
- if (!inBrowser) {
- return;
- }
- if (!instance$1) {
- initInstance$1();
- }
- options = Array.isArray(options) ? {
- images: options,
- startPosition
- } : options;
- instance$1.open(extend({}, defaultConfig, options));
- return instance$1;
- };
- ImagePreview.Component = withInstall(stdin_default$z);
- ImagePreview.install = (app) => {
- app.use(ImagePreview.Component);
- };
- function genAlphabet() {
- const charCodeOfA = "A".charCodeAt(0);
- const indexList = Array(26).fill("").map((_, i) => String.fromCharCode(charCodeOfA + i));
- return indexList;
- }
- const [name$t, bem$t] = createNamespace("index-bar");
- const indexBarProps = {
- sticky: truthProp,
- zIndex: numericProp,
- teleport: [String, Object],
- highlightColor: String,
- stickyOffsetTop: makeNumberProp(0),
- indexList: {
- type: Array,
- default: genAlphabet
- }
- };
- const INDEX_BAR_KEY = Symbol(name$t);
- var stdin_default$y = defineComponent({
- name: name$t,
- props: indexBarProps,
- emits: ["select", "change"],
- setup(props, {
- emit,
- slots
- }) {
- const root = ref();
- const sidebar = ref();
- const activeAnchor = ref("");
- const touch = useTouch();
- const scrollParent = useScrollParent(root);
- const {
- children,
- linkChildren
- } = useChildren(INDEX_BAR_KEY);
- let selectActiveIndex;
- linkChildren({
- props
- });
- const sidebarStyle = computed(() => {
- if (isDef(props.zIndex)) {
- return {
- zIndex: +props.zIndex + 1
- };
- }
- });
- const highlightStyle = computed(() => {
- if (props.highlightColor) {
- return {
- color: props.highlightColor
- };
- }
- });
- const getActiveAnchor = (scrollTop, rects) => {
- for (let i = children.length - 1; i >= 0; i--) {
- const prevHeight = i > 0 ? rects[i - 1].height : 0;
- const reachTop = props.sticky ? prevHeight + props.stickyOffsetTop : 0;
- if (scrollTop + reachTop >= rects[i].top) {
- return i;
- }
- }
- return -1;
- };
- const getMatchAnchor = (index) => children.find((item) => String(item.index) === index);
- const onScroll = () => {
- if (isHidden(root)) {
- return;
- }
- const {
- sticky,
- indexList
- } = props;
- const scrollTop = getScrollTop(scrollParent.value);
- const scrollParentRect = useRect(scrollParent);
- const rects = children.map((item) => item.getRect(scrollParent.value, scrollParentRect));
- let active = -1;
- if (selectActiveIndex) {
- const match = getMatchAnchor(selectActiveIndex);
- if (match) {
- const rect = match.getRect(scrollParent.value, scrollParentRect);
- active = getActiveAnchor(rect.top, rects);
- }
- } else {
- active = getActiveAnchor(scrollTop, rects);
- }
- activeAnchor.value = indexList[active];
- if (sticky) {
- children.forEach((item, index) => {
- const {
- state,
- $el
- } = item;
- if (index === active || index === active - 1) {
- const rect = $el.getBoundingClientRect();
- state.left = rect.left;
- state.width = rect.width;
- } else {
- state.left = null;
- state.width = null;
- }
- if (index === active) {
- state.active = true;
- state.top = Math.max(props.stickyOffsetTop, rects[index].top - scrollTop) + scrollParentRect.top;
- } else if (index === active - 1 && selectActiveIndex === "") {
- const activeItemTop = rects[active].top - scrollTop;
- state.active = activeItemTop > 0;
- state.top = activeItemTop + scrollParentRect.top - rects[index].height;
- } else {
- state.active = false;
- }
- });
- }
- selectActiveIndex = "";
- };
- const init = () => {
- nextTick(onScroll);
- };
- useEventListener("scroll", onScroll, {
- target: scrollParent,
- passive: true
- });
- onMounted(init);
- watch(() => props.indexList, init);
- watch(activeAnchor, (value) => {
- if (value) {
- emit("change", value);
- }
- });
- const renderIndexes = () => props.indexList.map((index) => {
- const active = index === activeAnchor.value;
- return createVNode("span", {
- "class": bem$t("index", {
- active
- }),
- "style": active ? highlightStyle.value : void 0,
- "data-index": index
- }, [index]);
- });
- const scrollTo = (index) => {
- selectActiveIndex = String(index);
- const match = getMatchAnchor(selectActiveIndex);
- if (match) {
- const scrollTop = getScrollTop(scrollParent.value);
- const scrollParentRect = useRect(scrollParent);
- const {
- offsetHeight
- } = document.documentElement;
- match.$el.scrollIntoView();
- if (scrollTop === offsetHeight - scrollParentRect.height) {
- onScroll();
- return;
- }
- if (props.sticky && props.stickyOffsetTop) {
- setRootScrollTop(getRootScrollTop() - props.stickyOffsetTop);
- }
- emit("select", match.index);
- }
- };
- const scrollToElement = (element) => {
- const {
- index
- } = element.dataset;
- if (index) {
- scrollTo(index);
- }
- };
- const onClickSidebar = (event) => {
- scrollToElement(event.target);
- };
- let touchActiveIndex;
- const onTouchMove = (event) => {
- touch.move(event);
- if (touch.isVertical()) {
- preventDefault(event);
- const {
- clientX,
- clientY
- } = event.touches[0];
- const target = document.elementFromPoint(clientX, clientY);
- if (target) {
- const {
- index
- } = target.dataset;
- if (index && touchActiveIndex !== index) {
- touchActiveIndex = index;
- scrollToElement(target);
- }
- }
- }
- };
- const renderSidebar = () => createVNode("div", {
- "ref": sidebar,
- "class": bem$t("sidebar"),
- "style": sidebarStyle.value,
- "onClick": onClickSidebar,
- "onTouchstartPassive": touch.start
- }, [renderIndexes()]);
- useExpose({
- scrollTo
- });
- useEventListener("touchmove", onTouchMove, {
- target: sidebar
- });
- return () => {
- var _a;
- return createVNode("div", {
- "ref": root,
- "class": bem$t()
- }, [props.teleport ? createVNode(Teleport, {
- "to": props.teleport
- }, {
- default: () => [renderSidebar()]
- }) : renderSidebar(), (_a = slots.default) == null ? void 0 : _a.call(slots)]);
- };
- }
- });
- const [name$s, bem$s] = createNamespace("index-anchor");
- const indexAnchorProps = {
- index: numericProp
- };
- var stdin_default$x = defineComponent({
- name: name$s,
- props: indexAnchorProps,
- setup(props, {
- slots
- }) {
- const state = reactive({
- top: 0,
- left: null,
- rect: {
- top: 0,
- height: 0
- },
- width: null,
- active: false
- });
- const root = ref();
- const {
- parent
- } = useParent(INDEX_BAR_KEY);
- if (!parent) {
- if (process.env.NODE_ENV !== "production") {
- console.error("[Vant] <IndexAnchor> must be a child component of <IndexBar>.");
- }
- return;
- }
- const isSticky = () => state.active && parent.props.sticky;
- const anchorStyle = computed(() => {
- const {
- zIndex,
- highlightColor
- } = parent.props;
- if (isSticky()) {
- return extend(getZIndexStyle(zIndex), {
- left: state.left ? `${state.left}px` : void 0,
- width: state.width ? `${state.width}px` : void 0,
- transform: state.top ? `translate3d(0, ${state.top}px, 0)` : void 0,
- color: highlightColor
- });
- }
- });
- const getRect = (scrollParent, scrollParentRect) => {
- const rootRect = useRect(root);
- state.rect.height = rootRect.height;
- if (scrollParent === window || scrollParent === document.body) {
- state.rect.top = rootRect.top + getRootScrollTop();
- } else {
- state.rect.top = rootRect.top + getScrollTop(scrollParent) - scrollParentRect.top;
- }
- return state.rect;
- };
- useExpose({
- state,
- getRect
- });
- return () => {
- const sticky = isSticky();
- return createVNode("div", {
- "ref": root,
- "style": {
- height: sticky ? `${state.rect.height}px` : void 0
- }
- }, [createVNode("div", {
- "style": anchorStyle.value,
- "class": [bem$s({
- sticky
- }), {
- [BORDER_BOTTOM]: sticky
- }]
- }, [slots.default ? slots.default() : props.index])]);
- };
- }
- });
- const IndexAnchor = withInstall(stdin_default$x);
- const IndexBar = withInstall(stdin_default$y);
- const [name$r, bem$r, t$6] = createNamespace("list");
- const listProps = {
- error: Boolean,
- offset: makeNumericProp(300),
- loading: Boolean,
- finished: Boolean,
- errorText: String,
- direction: makeStringProp("down"),
- loadingText: String,
- finishedText: String,
- immediateCheck: truthProp
- };
- var stdin_default$w = defineComponent({
- name: name$r,
- props: listProps,
- emits: ["load", "update:error", "update:loading"],
- setup(props, {
- emit,
- slots
- }) {
- const loading = ref(props.loading);
- const root = ref();
- const placeholder = ref();
- const tabStatus = useTabStatus();
- const scrollParent = useScrollParent(root);
- const check = () => {
- nextTick(() => {
- if (loading.value || props.finished || props.error || (tabStatus == null ? void 0 : tabStatus.value) === false) {
- return;
- }
- const {
- offset,
- direction
- } = props;
- const scrollParentRect = useRect(scrollParent);
- if (!scrollParentRect.height || isHidden(root)) {
- return;
- }
- let isReachEdge = false;
- const placeholderRect = useRect(placeholder);
- if (direction === "up") {
- isReachEdge = scrollParentRect.top - placeholderRect.top <= offset;
- } else {
- isReachEdge = placeholderRect.bottom - scrollParentRect.bottom <= offset;
- }
- if (isReachEdge) {
- loading.value = true;
- emit("update:loading", true);
- emit("load");
- }
- });
- };
- const renderFinishedText = () => {
- if (props.finished) {
- const text = slots.finished ? slots.finished() : props.finishedText;
- if (text) {
- return createVNode("div", {
- "class": bem$r("finished-text")
- }, [text]);
- }
- }
- };
- const clickErrorText = () => {
- emit("update:error", false);
- check();
- };
- const renderErrorText = () => {
- if (props.error) {
- const text = slots.error ? slots.error() : props.errorText;
- if (text) {
- return createVNode("div", {
- "role": "button",
- "class": bem$r("error-text"),
- "tabindex": 0,
- "onClick": clickErrorText
- }, [text]);
- }
- }
- };
- const renderLoading = () => {
- if (loading.value && !props.finished) {
- return createVNode("div", {
- "class": bem$r("loading")
- }, [slots.loading ? slots.loading() : createVNode(Loading, {
- "class": bem$r("loading-icon")
- }, {
- default: () => [props.loadingText || t$6("loading")]
- })]);
- }
- };
- watch(() => [props.loading, props.finished, props.error], check);
- if (tabStatus) {
- watch(tabStatus, (tabActive) => {
- if (tabActive) {
- check();
- }
- });
- }
- onUpdated(() => {
- loading.value = props.loading;
- });
- onMounted(() => {
- if (props.immediateCheck) {
- check();
- }
- });
- useExpose({
- check
- });
- useEventListener("scroll", check, {
- target: scrollParent,
- passive: true
- });
- return () => {
- var _a;
- const Content = (_a = slots.default) == null ? void 0 : _a.call(slots);
- const Placeholder = createVNode("div", {
- "ref": placeholder,
- "class": bem$r("placeholder")
- }, null);
- return createVNode("div", {
- "ref": root,
- "role": "feed",
- "class": bem$r(),
- "aria-busy": loading.value
- }, [props.direction === "down" ? Content : Placeholder, renderLoading(), renderFinishedText(), renderErrorText(), props.direction === "up" ? Content : Placeholder]);
- };
- }
- });
- const List = withInstall(stdin_default$w);
- const [name$q, bem$q] = createNamespace("nav-bar");
- const navBarProps = {
- title: String,
- fixed: Boolean,
- zIndex: numericProp,
- border: truthProp,
- leftText: String,
- rightText: String,
- leftArrow: Boolean,
- placeholder: Boolean,
- safeAreaInsetTop: Boolean
- };
- var stdin_default$v = defineComponent({
- name: name$q,
- props: navBarProps,
- emits: ["click-left", "click-right"],
- setup(props, {
- emit,
- slots
- }) {
- const navBarRef = ref();
- const renderPlaceholder = usePlaceholder(navBarRef, bem$q);
- const onClickLeft = (event) => emit("click-left", event);
- const onClickRight = (event) => emit("click-right", event);
- const renderLeft = () => {
- if (slots.left) {
- return slots.left();
- }
- return [props.leftArrow && createVNode(Icon, {
- "class": bem$q("arrow"),
- "name": "arrow-left"
- }, null), props.leftText && createVNode("span", {
- "class": bem$q("text")
- }, [props.leftText])];
- };
- const renderRight = () => {
- if (slots.right) {
- return slots.right();
- }
- return createVNode("span", {
- "class": bem$q("text")
- }, [props.rightText]);
- };
- const renderNavBar = () => {
- const {
- title,
- fixed,
- border,
- zIndex
- } = props;
- const style = getZIndexStyle(zIndex);
- const hasLeft = props.leftArrow || props.leftText || slots.left;
- const hasRight = props.rightText || slots.right;
- return createVNode("div", {
- "ref": navBarRef,
- "style": style,
- "class": [bem$q({
- fixed
- }), {
- [BORDER_BOTTOM]: border,
- "van-safe-area-top": props.safeAreaInsetTop
- }]
- }, [createVNode("div", {
- "class": bem$q("content")
- }, [hasLeft && createVNode("div", {
- "class": [bem$q("left"), HAPTICS_FEEDBACK],
- "onClick": onClickLeft
- }, [renderLeft()]), createVNode("div", {
- "class": [bem$q("title"), "van-ellipsis"]
- }, [slots.title ? slots.title() : title]), hasRight && createVNode("div", {
- "class": [bem$q("right"), HAPTICS_FEEDBACK],
- "onClick": onClickRight
- }, [renderRight()])])]);
- };
- return () => {
- if (props.fixed && props.placeholder) {
- return renderPlaceholder(renderNavBar);
- }
- return renderNavBar();
- };
- }
- });
- const NavBar = withInstall(stdin_default$v);
- const [name$p, bem$p] = createNamespace("notice-bar");
- const noticeBarProps = {
- text: String,
- mode: String,
- color: String,
- delay: makeNumericProp(1),
- speed: makeNumericProp(60),
- leftIcon: String,
- wrapable: Boolean,
- background: String,
- scrollable: {
- type: Boolean,
- default: null
- }
- };
- var stdin_default$u = defineComponent({
- name: name$p,
- props: noticeBarProps,
- emits: ["close", "replay"],
- setup(props, {
- emit,
- slots
- }) {
- let wrapWidth = 0;
- let contentWidth = 0;
- let startTimer;
- const wrapRef = ref();
- const contentRef = ref();
- const state = reactive({
- show: true,
- offset: 0,
- duration: 0
- });
- const renderLeftIcon = () => {
- if (slots["left-icon"]) {
- return slots["left-icon"]();
- }
- if (props.leftIcon) {
- return createVNode(Icon, {
- "class": bem$p("left-icon"),
- "name": props.leftIcon
- }, null);
- }
- };
- const getRightIconName = () => {
- if (props.mode === "closeable") {
- return "cross";
- }
- if (props.mode === "link") {
- return "arrow";
- }
- };
- const onClickRightIcon = (event) => {
- if (props.mode === "closeable") {
- state.show = false;
- emit("close", event);
- }
- };
- const renderRightIcon = () => {
- if (slots["right-icon"]) {
- return slots["right-icon"]();
- }
- const name2 = getRightIconName();
- if (name2) {
- return createVNode(Icon, {
- "name": name2,
- "class": bem$p("right-icon"),
- "onClick": onClickRightIcon
- }, null);
- }
- };
- const onTransitionEnd = () => {
- state.offset = wrapWidth;
- state.duration = 0;
- raf(() => {
- doubleRaf(() => {
- state.offset = -contentWidth;
- state.duration = (contentWidth + wrapWidth) / +props.speed;
- emit("replay");
- });
- });
- };
- const renderMarquee = () => {
- const ellipsis = props.scrollable === false && !props.wrapable;
- const style = {
- transform: state.offset ? `translateX(${state.offset}px)` : "",
- transitionDuration: `${state.duration}s`
- };
- return createVNode("div", {
- "ref": wrapRef,
- "role": "marquee",
- "class": bem$p("wrap")
- }, [createVNode("div", {
- "ref": contentRef,
- "style": style,
- "class": [bem$p("content"), {
- "van-ellipsis": ellipsis
- }],
- "onTransitionend": onTransitionEnd
- }, [slots.default ? slots.default() : props.text])]);
- };
- const reset = () => {
- const {
- delay,
- speed,
- scrollable
- } = props;
- const ms = isDef(delay) ? +delay * 1e3 : 0;
- wrapWidth = 0;
- contentWidth = 0;
- state.offset = 0;
- state.duration = 0;
- clearTimeout(startTimer);
- startTimer = setTimeout(() => {
- if (!wrapRef.value || !contentRef.value || scrollable === false) {
- return;
- }
- const wrapRefWidth = useRect(wrapRef).width;
- const contentRefWidth = useRect(contentRef).width;
- if (scrollable || contentRefWidth > wrapRefWidth) {
- doubleRaf(() => {
- wrapWidth = wrapRefWidth;
- contentWidth = contentRefWidth;
- state.offset = -contentWidth;
- state.duration = contentWidth / +speed;
- });
- }
- }, ms);
- };
- onPopupReopen(reset);
- onMountedOrActivated(reset);
- useEventListener("pageshow", reset);
- useExpose({
- reset
- });
- watch(() => [props.text, props.scrollable], reset);
- return () => {
- const {
- color,
- wrapable,
- background
- } = props;
- return withDirectives(createVNode("div", {
- "role": "alert",
- "class": bem$p({
- wrapable
- }),
- "style": {
- color,
- background
- }
- }, [renderLeftIcon(), renderMarquee(), renderRightIcon()]), [[vShow, state.show]]);
- };
- }
- });
- const NoticeBar = withInstall(stdin_default$u);
- const [name$o, bem$o] = createNamespace("notify");
- const notifyProps = extend({}, popupSharedProps, {
- type: makeStringProp("danger"),
- color: String,
- message: numericProp,
- position: makeStringProp("top"),
- className: unknownProp,
- background: String,
- lockScroll: Boolean
- });
- var stdin_default$t = defineComponent({
- name: name$o,
- props: notifyProps,
- emits: ["update:show"],
- setup(props, {
- emit,
- slots
- }) {
- const updateShow = (show) => emit("update:show", show);
- return () => createVNode(Popup, {
- "show": props.show,
- "class": [bem$o([props.type]), props.className],
- "style": {
- color: props.color,
- background: props.background
- },
- "overlay": false,
- "position": props.position,
- "duration": 0.2,
- "lockScroll": props.lockScroll,
- "onUpdate:show": updateShow
- }, {
- default: () => [slots.default ? slots.default() : props.message]
- });
- }
- });
- let timer;
- let instance;
- const parseOptions = (message) => isObject(message) ? message : {
- message
- };
- function initInstance() {
- ({
- instance
- } = mountComponent({
- setup() {
- const {
- state,
- toggle
- } = usePopupState();
- return () => createVNode(stdin_default$t, mergeProps(state, {
- "onUpdate:show": toggle
- }), null);
- }
- }));
- }
- function Notify(options) {
- if (!inBrowser) {
- return;
- }
- if (!instance) {
- initInstance();
- }
- options = extend({}, Notify.currentOptions, parseOptions(options));
- instance.open(options);
- clearTimeout(timer);
- if (options.duration > 0) {
- timer = window.setTimeout(Notify.clear, options.duration);
- }
- return instance;
- }
- const getDefaultOptions = () => ({
- type: "danger",
- color: void 0,
- message: "",
- onClose: void 0,
- onClick: void 0,
- onOpened: void 0,
- duration: 3e3,
- position: void 0,
- className: "",
- lockScroll: false,
- background: void 0
- });
- Notify.clear = () => {
- if (instance) {
- instance.toggle(false);
- }
- };
- Notify.currentOptions = getDefaultOptions();
- Notify.setDefaultOptions = (options) => {
- extend(Notify.currentOptions, options);
- };
- Notify.resetDefaultOptions = () => {
- Notify.currentOptions = getDefaultOptions();
- };
- Notify.Component = withInstall(stdin_default$t);
- Notify.install = (app) => {
- app.use(Notify.Component);
- app.config.globalProperties.$notify = Notify;
- };
- const [name$n, bem$n] = createNamespace("key");
- const CollapseIcon = createVNode("svg", {
- "class": bem$n("collapse-icon"),
- "viewBox": "0 0 30 24"
- }, [createVNode("path", {
- "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",
- "fill": "currentColor"
- }, null)]);
- const DeleteIcon = createVNode("svg", {
- "class": bem$n("delete-icon"),
- "viewBox": "0 0 32 22"
- }, [createVNode("path", {
- "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",
- "fill": "currentColor"
- }, null)]);
- var stdin_default$s = defineComponent({
- name: name$n,
- props: {
- type: String,
- text: numericProp,
- color: String,
- wider: Boolean,
- large: Boolean,
- loading: Boolean
- },
- emits: ["press"],
- setup(props, {
- emit,
- slots
- }) {
- const active = ref(false);
- const touch = useTouch();
- const onTouchStart = (event) => {
- touch.start(event);
- active.value = true;
- };
- const onTouchMove = (event) => {
- touch.move(event);
- if (touch.direction.value) {
- active.value = false;
- }
- };
- const onTouchEnd = (event) => {
- if (active.value) {
- if (!slots.default) {
- preventDefault(event);
- }
- active.value = false;
- emit("press", props.text, props.type);
- }
- };
- const renderContent = () => {
- if (props.loading) {
- return createVNode(Loading, {
- "class": bem$n("loading-icon")
- }, null);
- }
- const text = slots.default ? slots.default() : props.text;
- switch (props.type) {
- case "delete":
- return text || DeleteIcon;
- case "extra":
- return text || CollapseIcon;
- default:
- return text;
- }
- };
- return () => createVNode("div", {
- "class": bem$n("wrapper", {
- wider: props.wider
- }),
- "onTouchstartPassive": onTouchStart,
- "onTouchmovePassive": onTouchMove,
- "onTouchend": onTouchEnd,
- "onTouchcancel": onTouchEnd
- }, [createVNode("div", {
- "role": "button",
- "tabindex": 0,
- "class": bem$n([props.color, {
- large: props.large,
- active: active.value,
- delete: props.type === "delete"
- }])
- }, [renderContent()])]);
- }
- });
- const [name$m, bem$m] = createNamespace("number-keyboard");
- const numberKeyboardProps = {
- show: Boolean,
- title: String,
- theme: makeStringProp("default"),
- zIndex: numericProp,
- teleport: [String, Object],
- maxlength: makeNumericProp(Infinity),
- modelValue: makeStringProp(""),
- transition: truthProp,
- blurOnClose: truthProp,
- showDeleteKey: truthProp,
- randomKeyOrder: Boolean,
- closeButtonText: String,
- deleteButtonText: String,
- closeButtonLoading: Boolean,
- hideOnClickOutside: truthProp,
- safeAreaInsetBottom: truthProp,
- extraKey: {
- type: [String, Array],
- default: ""
- }
- };
- function shuffle(array) {
- for (let i = array.length - 1; i > 0; i--) {
- const j = Math.floor(Math.random() * (i + 1));
- const temp = array[i];
- array[i] = array[j];
- array[j] = temp;
- }
- return array;
- }
- var stdin_default$r = defineComponent({
- name: name$m,
- inheritAttrs: false,
- props: numberKeyboardProps,
- emits: ["show", "hide", "blur", "input", "close", "delete", "update:modelValue"],
- setup(props, {
- emit,
- slots,
- attrs
- }) {
- const root = ref();
- const genBasicKeys = () => {
- const keys2 = Array(9).fill("").map((_, i) => ({
- text: i + 1
- }));
- if (props.randomKeyOrder) {
- shuffle(keys2);
- }
- return keys2;
- };
- const genDefaultKeys = () => [...genBasicKeys(), {
- text: props.extraKey,
- type: "extra"
- }, {
- text: 0
- }, {
- text: props.showDeleteKey ? props.deleteButtonText : "",
- type: props.showDeleteKey ? "delete" : ""
- }];
- const genCustomKeys = () => {
- const keys2 = genBasicKeys();
- const {
- extraKey
- } = props;
- const extraKeys = Array.isArray(extraKey) ? extraKey : [extraKey];
- if (extraKeys.length === 1) {
- keys2.push({
- text: 0,
- wider: true
- }, {
- text: extraKeys[0],
- type: "extra"
- });
- } else if (extraKeys.length === 2) {
- keys2.push({
- text: extraKeys[0],
- type: "extra"
- }, {
- text: 0
- }, {
- text: extraKeys[1],
- type: "extra"
- });
- }
- return keys2;
- };
- const keys = computed(() => props.theme === "custom" ? genCustomKeys() : genDefaultKeys());
- const onBlur = () => {
- if (props.show) {
- emit("blur");
- }
- };
- const onClose = () => {
- emit("close");
- if (props.blurOnClose) {
- onBlur();
- }
- };
- const onAnimationEnd = () => emit(props.show ? "show" : "hide");
- const onPress = (text, type) => {
- if (text === "") {
- if (type === "extra") {
- onBlur();
- }
- return;
- }
- const value = props.modelValue;
- if (type === "delete") {
- emit("delete");
- emit("update:modelValue", value.slice(0, value.length - 1));
- } else if (type === "close") {
- onClose();
- } else if (value.length < props.maxlength) {
- emit("input", text);
- emit("update:modelValue", value + text);
- }
- };
- const renderTitle = () => {
- const {
- title,
- theme,
- closeButtonText
- } = props;
- const leftSlot = slots["title-left"];
- const showClose = closeButtonText && theme === "default";
- const showTitle = title || showClose || leftSlot;
- if (!showTitle) {
- return;
- }
- return createVNode("div", {
- "class": bem$m("header")
- }, [leftSlot && createVNode("span", {
- "class": bem$m("title-left")
- }, [leftSlot()]), title && createVNode("h2", {
- "class": bem$m("title")
- }, [title]), showClose && createVNode("button", {
- "type": "button",
- "class": [bem$m("close"), HAPTICS_FEEDBACK],
- "onClick": onClose
- }, [closeButtonText])]);
- };
- const renderKeys = () => keys.value.map((key) => {
- const keySlots = {};
- if (key.type === "delete") {
- keySlots.default = slots.delete;
- }
- if (key.type === "extra") {
- keySlots.default = slots["extra-key"];
- }
- return createVNode(stdin_default$s, {
- "key": key.text,
- "text": key.text,
- "type": key.type,
- "wider": key.wider,
- "color": key.color,
- "onPress": onPress
- }, keySlots);
- });
- const renderSidebar = () => {
- if (props.theme === "custom") {
- return createVNode("div", {
- "class": bem$m("sidebar")
- }, [props.showDeleteKey && createVNode(stdin_default$s, {
- "large": true,
- "text": props.deleteButtonText,
- "type": "delete",
- "onPress": onPress
- }, {
- delete: slots.delete
- }), createVNode(stdin_default$s, {
- "large": true,
- "text": props.closeButtonText,
- "type": "close",
- "color": "blue",
- "loading": props.closeButtonLoading,
- "onPress": onPress
- }, null)]);
- }
- };
- watch(() => props.show, (value) => {
- if (!props.transition) {
- emit(value ? "show" : "hide");
- }
- });
- if (props.hideOnClickOutside) {
- useClickAway(root, onBlur, {
- eventName: "touchstart"
- });
- }
- return () => {
- const Title = renderTitle();
- const Content = createVNode(Transition, {
- "name": props.transition ? "van-slide-up" : ""
- }, {
- default: () => [withDirectives(createVNode("div", mergeProps({
- "ref": root,
- "style": getZIndexStyle(props.zIndex),
- "class": bem$m({
- unfit: !props.safeAreaInsetBottom,
- "with-title": !!Title
- }),
- "onAnimationend": onAnimationEnd,
- "onTouchstartPassive": stopPropagation
- }, attrs), [Title, createVNode("div", {
- "class": bem$m("body")
- }, [createVNode("div", {
- "class": bem$m("keys")
- }, [renderKeys()]), renderSidebar()])]), [[vShow, props.show]])]
- });
- if (props.teleport) {
- return createVNode(Teleport, {
- "to": props.teleport
- }, {
- default: () => [Content]
- });
- }
- return Content;
- };
- }
- });
- const NumberKeyboard = withInstall(stdin_default$r);
- const [name$l, bem$l, t$5] = createNamespace("pagination");
- const makePage = (number, text, active) => ({
- number,
- text,
- active
- });
- const paginationProps = {
- mode: makeStringProp("multi"),
- prevText: String,
- nextText: String,
- pageCount: makeNumericProp(0),
- modelValue: makeNumberProp(0),
- totalItems: makeNumericProp(0),
- showPageSize: makeNumericProp(5),
- itemsPerPage: makeNumericProp(10),
- forceEllipses: Boolean
- };
- var stdin_default$q = defineComponent({
- name: name$l,
- props: paginationProps,
- emits: ["change", "update:modelValue"],
- setup(props, {
- emit,
- slots
- }) {
- const count = computed(() => {
- const {
- pageCount,
- totalItems,
- itemsPerPage
- } = props;
- const count2 = +pageCount || Math.ceil(+totalItems / +itemsPerPage);
- return Math.max(1, count2);
- });
- const pages = computed(() => {
- const items = [];
- const pageCount = count.value;
- const showPageSize = +props.showPageSize;
- const {
- modelValue,
- forceEllipses
- } = props;
- let startPage = 1;
- let endPage = pageCount;
- const isMaxSized = showPageSize < pageCount;
- if (isMaxSized) {
- startPage = Math.max(modelValue - Math.floor(showPageSize / 2), 1);
- endPage = startPage + showPageSize - 1;
- if (endPage > pageCount) {
- endPage = pageCount;
- startPage = endPage - showPageSize + 1;
- }
- }
- for (let number = startPage; number <= endPage; number++) {
- const page = makePage(number, number, number === modelValue);
- items.push(page);
- }
- if (isMaxSized && showPageSize > 0 && forceEllipses) {
- if (startPage > 1) {
- const prevPages = makePage(startPage - 1, "...");
- items.unshift(prevPages);
- }
- if (endPage < pageCount) {
- const nextPages = makePage(endPage + 1, "...");
- items.push(nextPages);
- }
- }
- return items;
- });
- const updateModelValue = (value, emitChange) => {
- value = clamp(value, 1, count.value);
- if (props.modelValue !== value) {
- emit("update:modelValue", value);
- if (emitChange) {
- emit("change", value);
- }
- }
- };
- watchEffect(() => updateModelValue(props.modelValue));
- const renderDesc = () => createVNode("li", {
- "class": bem$l("page-desc")
- }, [slots.pageDesc ? slots.pageDesc() : `${props.modelValue}/${count.value}`]);
- const renderPrevButton = () => {
- const {
- mode,
- modelValue
- } = props;
- const slot = slots["prev-text"];
- const disabled = modelValue === 1;
- return createVNode("li", {
- "class": [bem$l("item", {
- disabled,
- border: mode === "simple",
- prev: true
- }), BORDER_SURROUND]
- }, [createVNode("button", {
- "type": "button",
- "disabled": disabled,
- "onClick": () => updateModelValue(modelValue - 1, true)
- }, [slot ? slot() : props.prevText || t$5("prev")])]);
- };
- const renderNextButton = () => {
- const {
- mode,
- modelValue
- } = props;
- const slot = slots["next-text"];
- const disabled = modelValue === count.value;
- return createVNode("li", {
- "class": [bem$l("item", {
- disabled,
- border: mode === "simple",
- next: true
- }), BORDER_SURROUND]
- }, [createVNode("button", {
- "type": "button",
- "disabled": disabled,
- "onClick": () => updateModelValue(modelValue + 1, true)
- }, [slot ? slot() : props.nextText || t$5("next")])]);
- };
- const renderPages = () => pages.value.map((page) => createVNode("li", {
- "class": [bem$l("item", {
- active: page.active,
- page: true
- }), BORDER_SURROUND]
- }, [createVNode("button", {
- "type": "button",
- "aria-current": page.active || void 0,
- "onClick": () => updateModelValue(page.number, true)
- }, [slots.page ? slots.page(page) : page.text])]));
- return () => createVNode("nav", {
- "role": "navigation",
- "class": bem$l()
- }, [createVNode("ul", {
- "class": bem$l("items")
- }, [renderPrevButton(), props.mode === "simple" ? renderDesc() : renderPages(), renderNextButton()])]);
- }
- });
- const Pagination = withInstall(stdin_default$q);
- const [name$k, bem$k] = createNamespace("password-input");
- const passwordInputProps = {
- info: String,
- mask: truthProp,
- value: makeStringProp(""),
- gutter: numericProp,
- length: makeNumericProp(6),
- focused: Boolean,
- errorInfo: String
- };
- var stdin_default$p = defineComponent({
- name: name$k,
- props: passwordInputProps,
- emits: ["focus"],
- setup(props, {
- emit
- }) {
- const onTouchStart = (event) => {
- event.stopPropagation();
- emit("focus", event);
- };
- const renderPoints = () => {
- const Points = [];
- const {
- mask,
- value,
- length,
- gutter,
- focused
- } = props;
- for (let i = 0; i < length; i++) {
- const char = value[i];
- const showBorder = i !== 0 && !gutter;
- const showCursor = focused && i === value.length;
- let style;
- if (i !== 0 && gutter) {
- style = {
- marginLeft: addUnit(gutter)
- };
- }
- Points.push(createVNode("li", {
- "class": [{
- [BORDER_LEFT]: showBorder
- }, bem$k("item", {
- focus: showCursor
- })],
- "style": style
- }, [mask ? createVNode("i", {
- "style": {
- visibility: char ? "visible" : "hidden"
- }
- }, null) : char, showCursor && createVNode("div", {
- "class": bem$k("cursor")
- }, null)]));
- }
- return Points;
- };
- return () => {
- const info = props.errorInfo || props.info;
- return createVNode("div", {
- "class": bem$k()
- }, [createVNode("ul", {
- "class": [bem$k("security"), {
- [BORDER_SURROUND]: !props.gutter
- }],
- "onTouchstartPassive": onTouchStart
- }, [renderPoints()]), info && createVNode("div", {
- "class": bem$k(props.errorInfo ? "error-info" : "info")
- }, [info])]);
- };
- }
- });
- const PasswordInput = withInstall(stdin_default$p);
- const [name$j, bem$j] = createNamespace("popover");
- const popupProps = ["show", "overlay", "duration", "teleport", "overlayStyle", "overlayClass", "closeOnClickOverlay"];
- const popoverProps = {
- show: Boolean,
- theme: makeStringProp("light"),
- overlay: Boolean,
- actions: makeArrayProp(),
- trigger: makeStringProp("click"),
- duration: numericProp,
- showArrow: truthProp,
- placement: makeStringProp("bottom"),
- iconPrefix: String,
- overlayClass: unknownProp,
- overlayStyle: Object,
- closeOnClickAction: truthProp,
- closeOnClickOverlay: truthProp,
- closeOnClickOutside: truthProp,
- offset: {
- type: Array,
- default: () => [0, 8]
- },
- teleport: {
- type: [String, Object],
- default: "body"
- }
- };
- var stdin_default$o = defineComponent({
- name: name$j,
- props: popoverProps,
- emits: ["select", "touchstart", "update:show"],
- setup(props, {
- emit,
- slots,
- attrs
- }) {
- let popper;
- const popupRef = ref();
- const wrapperRef = ref();
- const popoverRef = ref();
- const getPopoverOptions = () => ({
- placement: props.placement,
- modifiers: [{
- name: "computeStyles",
- options: {
- adaptive: false,
- gpuAcceleration: false
- }
- }, extend({}, offsetModifier, {
- options: {
- offset: props.offset
- }
- })]
- });
- const createPopperInstance = () => {
- if (wrapperRef.value && popoverRef.value) {
- return createPopper(wrapperRef.value, popoverRef.value.popupRef.value, getPopoverOptions());
- }
- return null;
- };
- const updateLocation = () => {
- nextTick(() => {
- if (!props.show) {
- return;
- }
- if (!popper) {
- popper = createPopperInstance();
- } else {
- popper.setOptions(getPopoverOptions());
- }
- });
- };
- const updateShow = (value) => emit("update:show", value);
- const onClickWrapper = () => {
- if (props.trigger === "click") {
- updateShow(!props.show);
- }
- };
- const onClickAction = (action, index) => {
- if (action.disabled) {
- return;
- }
- emit("select", action, index);
- if (props.closeOnClickAction) {
- updateShow(false);
- }
- };
- const onClickAway = () => {
- if (props.show && props.closeOnClickOutside && (!props.overlay || props.closeOnClickOverlay)) {
- updateShow(false);
- }
- };
- const renderActionContent = (action, index) => {
- if (slots.action) {
- return slots.action({
- action,
- index
- });
- }
- return [action.icon && createVNode(Icon, {
- "name": action.icon,
- "classPrefix": props.iconPrefix,
- "class": bem$j("action-icon")
- }, null), createVNode("div", {
- "class": [bem$j("action-text"), BORDER_BOTTOM]
- }, [action.text])];
- };
- const renderAction = (action, index) => {
- const {
- icon,
- color,
- disabled,
- className
- } = action;
- return createVNode("div", {
- "role": "menuitem",
- "class": [bem$j("action", {
- disabled,
- "with-icon": icon
- }), className],
- "style": {
- color
- },
- "tabindex": disabled ? void 0 : 0,
- "aria-disabled": disabled || void 0,
- "onClick": () => onClickAction(action, index)
- }, [renderActionContent(action, index)]);
- };
- onMounted(() => {
- updateLocation();
- watchEffect(() => {
- var _a;
- popupRef.value = (_a = popoverRef.value) == null ? void 0 : _a.popupRef.value;
- });
- });
- onBeforeUnmount(() => {
- if (popper) {
- popper.destroy();
- popper = null;
- }
- });
- watch(() => [props.show, props.offset, props.placement], updateLocation);
- useClickAway([wrapperRef, popupRef], onClickAway, {
- eventName: "touchstart"
- });
- return () => {
- var _a;
- return createVNode(Fragment, null, [createVNode("span", {
- "ref": wrapperRef,
- "class": bem$j("wrapper"),
- "onClick": onClickWrapper
- }, [(_a = slots.reference) == null ? void 0 : _a.call(slots)]), createVNode(Popup, mergeProps({
- "ref": popoverRef,
- "class": bem$j([props.theme]),
- "position": "",
- "transition": "van-popover-zoom",
- "lockScroll": false,
- "onUpdate:show": updateShow
- }, attrs, pick(props, popupProps)), {
- default: () => [props.showArrow && createVNode("div", {
- "class": bem$j("arrow")
- }, null), createVNode("div", {
- "role": "menu",
- "class": bem$j("content")
- }, [slots.default ? slots.default() : props.actions.map(renderAction)])]
- })]);
- };
- }
- });
- const Popover = withInstall(stdin_default$o);
- const [name$i, bem$i] = createNamespace("progress");
- const progressProps = {
- color: String,
- inactive: Boolean,
- pivotText: String,
- textColor: String,
- showPivot: truthProp,
- pivotColor: String,
- trackColor: String,
- strokeWidth: numericProp,
- percentage: {
- type: numericProp,
- default: 0,
- validator: (value) => value >= 0 && value <= 100
- }
- };
- var stdin_default$n = defineComponent({
- name: name$i,
- props: progressProps,
- setup(props) {
- const background = computed(() => props.inactive ? void 0 : props.color);
- const renderPivot = () => {
- const {
- textColor,
- pivotText,
- pivotColor,
- percentage
- } = props;
- const text = pivotText != null ? pivotText : `${percentage}%`;
- if (props.showPivot && text) {
- const style = {
- color: textColor,
- left: `${+percentage}%`,
- transform: `translate(-${+percentage}%,-50%)`,
- background: pivotColor || background.value
- };
- return createVNode("span", {
- "style": style,
- "class": bem$i("pivot", {
- inactive: props.inactive
- })
- }, [text]);
- }
- };
- return () => {
- const {
- trackColor,
- percentage,
- strokeWidth
- } = props;
- const rootStyle = {
- background: trackColor,
- height: addUnit(strokeWidth)
- };
- const portionStyle = {
- width: `${percentage}%`,
- background: background.value
- };
- return createVNode("div", {
- "class": bem$i(),
- "style": rootStyle
- }, [createVNode("span", {
- "class": bem$i("portion", {
- inactive: props.inactive
- }),
- "style": portionStyle
- }, null), renderPivot()]);
- };
- }
- });
- const Progress = withInstall(stdin_default$n);
- const [name$h, bem$h, t$4] = createNamespace("pull-refresh");
- const DEFAULT_HEAD_HEIGHT = 50;
- const TEXT_STATUS = ["pulling", "loosing", "success"];
- const pullRefreshProps = {
- disabled: Boolean,
- modelValue: Boolean,
- headHeight: makeNumericProp(DEFAULT_HEAD_HEIGHT),
- successText: String,
- pullingText: String,
- loosingText: String,
- loadingText: String,
- pullDistance: numericProp,
- successDuration: makeNumericProp(500),
- animationDuration: makeNumericProp(300)
- };
- var stdin_default$m = defineComponent({
- name: name$h,
- props: pullRefreshProps,
- emits: ["change", "refresh", "update:modelValue"],
- setup(props, {
- emit,
- slots
- }) {
- let reachTop;
- const root = ref();
- const track = ref();
- const scrollParent = useScrollParent(root);
- const state = reactive({
- status: "normal",
- distance: 0,
- duration: 0
- });
- const touch = useTouch();
- const getHeadStyle = () => {
- if (props.headHeight !== DEFAULT_HEAD_HEIGHT) {
- return {
- height: `${props.headHeight}px`
- };
- }
- };
- const isTouchable = () => state.status !== "loading" && state.status !== "success" && !props.disabled;
- const ease = (distance) => {
- const pullDistance = +(props.pullDistance || props.headHeight);
- if (distance > pullDistance) {
- if (distance < pullDistance * 2) {
- distance = pullDistance + (distance - pullDistance) / 2;
- } else {
- distance = pullDistance * 1.5 + (distance - pullDistance * 2) / 4;
- }
- }
- return Math.round(distance);
- };
- const setStatus = (distance, isLoading) => {
- const pullDistance = +(props.pullDistance || props.headHeight);
- state.distance = distance;
- if (isLoading) {
- state.status = "loading";
- } else if (distance === 0) {
- state.status = "normal";
- } else if (distance < pullDistance) {
- state.status = "pulling";
- } else {
- state.status = "loosing";
- }
- emit("change", {
- status: state.status,
- distance
- });
- };
- const getStatusText = () => {
- const {
- status
- } = state;
- if (status === "normal") {
- return "";
- }
- return props[`${status}Text`] || t$4(status);
- };
- const renderStatus = () => {
- const {
- status,
- distance
- } = state;
- if (slots[status]) {
- return slots[status]({
- distance
- });
- }
- const nodes = [];
- if (TEXT_STATUS.includes(status)) {
- nodes.push(createVNode("div", {
- "class": bem$h("text")
- }, [getStatusText()]));
- }
- if (status === "loading") {
- nodes.push(createVNode(Loading, {
- "class": bem$h("loading")
- }, {
- default: getStatusText
- }));
- }
- return nodes;
- };
- const showSuccessTip = () => {
- state.status = "success";
- setTimeout(() => {
- setStatus(0);
- }, +props.successDuration);
- };
- const checkPosition = (event) => {
- reachTop = getScrollTop(scrollParent.value) === 0;
- if (reachTop) {
- state.duration = 0;
- touch.start(event);
- }
- };
- const onTouchStart = (event) => {
- if (isTouchable()) {
- checkPosition(event);
- }
- };
- const onTouchMove = (event) => {
- if (isTouchable()) {
- if (!reachTop) {
- checkPosition(event);
- }
- const {
- deltaY
- } = touch;
- touch.move(event);
- if (reachTop && deltaY.value >= 0 && touch.isVertical()) {
- preventDefault(event);
- setStatus(ease(deltaY.value));
- }
- }
- };
- const onTouchEnd = () => {
- if (reachTop && touch.deltaY.value && isTouchable()) {
- state.duration = +props.animationDuration;
- if (state.status === "loosing") {
- setStatus(+props.headHeight, true);
- emit("update:modelValue", true);
- nextTick(() => emit("refresh"));
- } else {
- setStatus(0);
- }
- }
- };
- watch(() => props.modelValue, (value) => {
- state.duration = +props.animationDuration;
- if (value) {
- setStatus(+props.headHeight, true);
- } else if (slots.success || props.successText) {
- showSuccessTip();
- } else {
- setStatus(0, false);
- }
- });
- useEventListener("touchmove", onTouchMove, {
- target: track
- });
- return () => {
- var _a;
- const trackStyle = {
- transitionDuration: `${state.duration}ms`,
- transform: state.distance ? `translate3d(0,${state.distance}px, 0)` : ""
- };
- return createVNode("div", {
- "ref": root,
- "class": bem$h()
- }, [createVNode("div", {
- "ref": track,
- "class": bem$h("track"),
- "style": trackStyle,
- "onTouchstartPassive": onTouchStart,
- "onTouchend": onTouchEnd,
- "onTouchcancel": onTouchEnd
- }, [createVNode("div", {
- "class": bem$h("head"),
- "style": getHeadStyle()
- }, [renderStatus()]), (_a = slots.default) == null ? void 0 : _a.call(slots)])]);
- };
- }
- });
- const PullRefresh = withInstall(stdin_default$m);
- const [name$g, bem$g] = createNamespace("rate");
- function getRateStatus(value, index, allowHalf, readonly) {
- if (value >= index) {
- return {
- status: "full",
- value: 1
- };
- }
- if (value + 0.5 >= index && allowHalf && !readonly) {
- return {
- status: "half",
- value: 0.5
- };
- }
- if (value + 1 >= index && allowHalf && readonly) {
- const cardinal = 10 ** 10;
- return {
- status: "half",
- value: Math.round((value - index + 1) * cardinal) / cardinal
- };
- }
- return {
- status: "void",
- value: 0
- };
- }
- const rateProps = {
- size: numericProp,
- icon: makeStringProp("star"),
- color: String,
- count: makeNumericProp(5),
- gutter: numericProp,
- readonly: Boolean,
- disabled: Boolean,
- voidIcon: makeStringProp("star-o"),
- allowHalf: Boolean,
- voidColor: String,
- touchable: truthProp,
- iconPrefix: String,
- modelValue: makeNumberProp(0),
- disabledColor: String
- };
- var stdin_default$l = defineComponent({
- name: name$g,
- props: rateProps,
- emits: ["change", "update:modelValue"],
- setup(props, {
- emit
- }) {
- const touch = useTouch();
- const [itemRefs, setItemRefs] = useRefs();
- const groupRef = ref();
- const untouchable = () => props.readonly || props.disabled || !props.touchable;
- const list = computed(() => Array(+props.count).fill("").map((_, i) => getRateStatus(props.modelValue, i + 1, props.allowHalf, props.readonly)));
- let ranges;
- let groupRefRect;
- let minRectTop = Number.MAX_SAFE_INTEGER;
- let maxRectTop = Number.MIN_SAFE_INTEGER;
- const updateRanges = () => {
- groupRefRect = useRect(groupRef);
- const rects = itemRefs.value.map(useRect);
- ranges = [];
- rects.forEach((rect, index) => {
- minRectTop = Math.min(rect.top, minRectTop);
- maxRectTop = Math.max(rect.top, maxRectTop);
- if (props.allowHalf) {
- ranges.push({
- score: index + 0.5,
- left: rect.left,
- top: rect.top,
- height: rect.height
- }, {
- score: index + 1,
- left: rect.left + rect.width / 2,
- top: rect.top,
- height: rect.height
- });
- } else {
- ranges.push({
- score: index + 1,
- left: rect.left,
- top: rect.top,
- height: rect.height
- });
- }
- });
- };
- const getScoreByPosition = (x, y) => {
- for (let i = ranges.length - 1; i > 0; i--) {
- if (y >= groupRefRect.top && y <= groupRefRect.bottom) {
- if (x > ranges[i].left && y >= ranges[i].top && y <= ranges[i].top + ranges[i].height) {
- return ranges[i].score;
- }
- } else {
- const curTop = y < groupRefRect.top ? minRectTop : maxRectTop;
- if (x > ranges[i].left && ranges[i].top === curTop) {
- return ranges[i].score;
- }
- }
- }
- return props.allowHalf ? 0.5 : 1;
- };
- const select = (index) => {
- if (!props.disabled && !props.readonly && index !== props.modelValue) {
- emit("update:modelValue", index);
- emit("change", index);
- }
- };
- const onTouchStart = (event) => {
- if (untouchable()) {
- return;
- }
- touch.start(event);
- updateRanges();
- };
- const onTouchMove = (event) => {
- if (untouchable()) {
- return;
- }
- touch.move(event);
- if (touch.isHorizontal()) {
- const {
- clientX,
- clientY
- } = event.touches[0];
- preventDefault(event);
- select(getScoreByPosition(clientX, clientY));
- }
- };
- const renderStar = (item, index) => {
- const {
- icon,
- size,
- color,
- count,
- gutter,
- voidIcon,
- disabled,
- voidColor,
- allowHalf,
- iconPrefix,
- disabledColor
- } = props;
- const score = index + 1;
- const isFull = item.status === "full";
- const isVoid = item.status === "void";
- const renderHalf = allowHalf && item.value > 0 && item.value < 1;
- let style;
- if (gutter && score !== +count) {
- style = {
- paddingRight: addUnit(gutter)
- };
- }
- const onClickItem = (event) => {
- updateRanges();
- select(allowHalf ? getScoreByPosition(event.clientX, event.clientY) : score);
- };
- return createVNode("div", {
- "key": index,
- "ref": setItemRefs(index),
- "role": "radio",
- "style": style,
- "class": bem$g("item"),
- "tabindex": disabled ? void 0 : 0,
- "aria-setsize": count,
- "aria-posinset": score,
- "aria-checked": !isVoid,
- "onClick": onClickItem
- }, [createVNode(Icon, {
- "size": size,
- "name": isFull ? icon : voidIcon,
- "class": bem$g("icon", {
- disabled,
- full: isFull
- }),
- "color": disabled ? disabledColor : isFull ? color : voidColor,
- "classPrefix": iconPrefix
- }, null), renderHalf && createVNode(Icon, {
- "size": size,
- "style": {
- width: item.value + "em"
- },
- "name": isVoid ? voidIcon : icon,
- "class": bem$g("icon", ["half", {
- disabled,
- full: !isVoid
- }]),
- "color": disabled ? disabledColor : isVoid ? voidColor : color,
- "classPrefix": iconPrefix
- }, null)]);
- };
- useCustomFieldValue(() => props.modelValue);
- useEventListener("touchmove", onTouchMove, {
- target: groupRef
- });
- return () => createVNode("div", {
- "ref": groupRef,
- "role": "radiogroup",
- "class": bem$g({
- readonly: props.readonly,
- disabled: props.disabled
- }),
- "tabindex": props.disabled ? void 0 : 0,
- "aria-disabled": props.disabled,
- "aria-readonly": props.readonly,
- "onTouchstartPassive": onTouchStart
- }, [list.value.map(renderStar)]);
- }
- });
- const Rate = withInstall(stdin_default$l);
- const Row = withInstall(stdin_default$V);
- const [name$f, bem$f, t$3] = createNamespace("search");
- const searchProps = extend({}, fieldSharedProps, {
- label: String,
- shape: makeStringProp("square"),
- leftIcon: makeStringProp("search"),
- clearable: truthProp,
- actionText: String,
- background: String,
- showAction: Boolean
- });
- var stdin_default$k = defineComponent({
- name: name$f,
- props: searchProps,
- emits: ["blur", "focus", "clear", "search", "cancel", "click-input", "click-left-icon", "click-right-icon", "update:modelValue"],
- setup(props, {
- emit,
- slots,
- attrs
- }) {
- const id = useId();
- const filedRef = ref();
- const onCancel = () => {
- if (!slots.action) {
- emit("update:modelValue", "");
- emit("cancel");
- }
- };
- const onKeypress = (event) => {
- const ENTER_CODE = 13;
- if (event.keyCode === ENTER_CODE) {
- preventDefault(event);
- emit("search", props.modelValue);
- }
- };
- const getInputId = () => props.id || `${id}-input`;
- const renderLabel = () => {
- if (slots.label || props.label) {
- return createVNode("label", {
- "class": bem$f("label"),
- "for": getInputId()
- }, [slots.label ? slots.label() : props.label]);
- }
- };
- const renderAction = () => {
- if (props.showAction) {
- const text = props.actionText || t$3("cancel");
- return createVNode("div", {
- "class": bem$f("action"),
- "role": "button",
- "tabindex": 0,
- "onClick": onCancel
- }, [slots.action ? slots.action() : text]);
- }
- };
- const blur = () => {
- var _a;
- return (_a = filedRef.value) == null ? void 0 : _a.blur();
- };
- const focus = () => {
- var _a;
- return (_a = filedRef.value) == null ? void 0 : _a.focus();
- };
- const onBlur = (event) => emit("blur", event);
- const onFocus = (event) => emit("focus", event);
- const onClear = (event) => emit("clear", event);
- const onClickInput = (event) => emit("click-input", event);
- const onClickLeftIcon = (event) => emit("click-left-icon", event);
- const onClickRightIcon = (event) => emit("click-right-icon", event);
- const fieldPropNames = Object.keys(fieldSharedProps);
- const renderField = () => {
- const fieldAttrs = extend({}, attrs, pick(props, fieldPropNames), {
- id: getInputId()
- });
- const onInput = (value) => emit("update:modelValue", value);
- return createVNode(Field, mergeProps({
- "ref": filedRef,
- "type": "search",
- "class": bem$f("field"),
- "border": false,
- "onBlur": onBlur,
- "onFocus": onFocus,
- "onClear": onClear,
- "onKeypress": onKeypress,
- "onClick-input": onClickInput,
- "onClick-left-icon": onClickLeftIcon,
- "onClick-right-icon": onClickRightIcon,
- "onUpdate:modelValue": onInput
- }, fieldAttrs), pick(slots, ["left-icon", "right-icon"]));
- };
- useExpose({
- focus,
- blur
- });
- return () => {
- var _a;
- return createVNode("div", {
- "class": bem$f({
- "show-action": props.showAction
- }),
- "style": {
- background: props.background
- }
- }, [(_a = slots.left) == null ? void 0 : _a.call(slots), createVNode("div", {
- "class": bem$f("content", props.shape)
- }, [renderLabel(), renderField()]), renderAction()]);
- };
- }
- });
- const Search = withInstall(stdin_default$k);
- const popupInheritKeys = [...popupSharedPropKeys, "round", "closeOnPopstate", "safeAreaInsetBottom"];
- const iconMap = {
- qq: "qq",
- link: "link-o",
- weibo: "weibo",
- qrcode: "qr",
- poster: "photo-o",
- wechat: "wechat",
- "weapp-qrcode": "miniprogram-o",
- "wechat-moments": "wechat-moments"
- };
- const [name$e, bem$e, t$2] = createNamespace("share-sheet");
- const shareSheetProps = extend({}, popupSharedProps, {
- title: String,
- round: truthProp,
- options: makeArrayProp(),
- cancelText: String,
- description: String,
- closeOnPopstate: truthProp,
- safeAreaInsetBottom: truthProp
- });
- var stdin_default$j = defineComponent({
- name: name$e,
- props: shareSheetProps,
- emits: ["cancel", "select", "update:show"],
- setup(props, {
- emit,
- slots
- }) {
- const updateShow = (value) => emit("update:show", value);
- const onCancel = () => {
- updateShow(false);
- emit("cancel");
- };
- const onSelect = (option, index) => emit("select", option, index);
- const renderHeader = () => {
- const title = slots.title ? slots.title() : props.title;
- const description = slots.description ? slots.description() : props.description;
- if (title || description) {
- return createVNode("div", {
- "class": bem$e("header")
- }, [title && createVNode("h2", {
- "class": bem$e("title")
- }, [title]), description && createVNode("span", {
- "class": bem$e("description")
- }, [description])]);
- }
- };
- const renderIcon = (icon) => {
- if (iconMap[icon]) {
- return createVNode("div", {
- "class": bem$e("icon", [icon])
- }, [createVNode(Icon, {
- "name": iconMap[icon] || icon
- }, null)]);
- }
- return createVNode("img", {
- "src": icon,
- "class": bem$e("image-icon")
- }, null);
- };
- const renderOption = (option, index) => {
- const {
- name: name2,
- icon,
- className,
- description
- } = option;
- return createVNode("div", {
- "role": "button",
- "tabindex": 0,
- "class": [bem$e("option"), className, HAPTICS_FEEDBACK],
- "onClick": () => onSelect(option, index)
- }, [renderIcon(icon), name2 && createVNode("span", {
- "class": bem$e("name")
- }, [name2]), description && createVNode("span", {
- "class": bem$e("option-description")
- }, [description])]);
- };
- const renderOptions = (options, border) => createVNode("div", {
- "class": bem$e("options", {
- border
- })
- }, [options.map(renderOption)]);
- const renderRows = () => {
- const {
- options
- } = props;
- if (Array.isArray(options[0])) {
- return options.map((item, index) => renderOptions(item, index !== 0));
- }
- return renderOptions(options);
- };
- const renderCancelButton = () => {
- var _a;
- const cancelText = (_a = props.cancelText) != null ? _a : t$2("cancel");
- if (slots.cancel || cancelText) {
- return createVNode("button", {
- "type": "button",
- "class": bem$e("cancel"),
- "onClick": onCancel
- }, [slots.cancel ? slots.cancel() : cancelText]);
- }
- };
- return () => createVNode(Popup, mergeProps({
- "class": bem$e(),
- "position": "bottom",
- "onUpdate:show": updateShow
- }, pick(props, popupInheritKeys)), {
- default: () => [renderHeader(), renderRows(), renderCancelButton()]
- });
- }
- });
- const ShareSheet = withInstall(stdin_default$j);
- const [name$d, bem$d] = createNamespace("sidebar");
- const SIDEBAR_KEY = Symbol(name$d);
- const sidebarProps = {
- modelValue: makeNumericProp(0)
- };
- var stdin_default$i = defineComponent({
- name: name$d,
- props: sidebarProps,
- emits: ["change", "update:modelValue"],
- setup(props, {
- emit,
- slots
- }) {
- const {
- linkChildren
- } = useChildren(SIDEBAR_KEY);
- const getActive = () => +props.modelValue;
- const setActive = (value) => {
- if (value !== getActive()) {
- emit("update:modelValue", value);
- emit("change", value);
- }
- };
- linkChildren({
- getActive,
- setActive
- });
- return () => {
- var _a;
- return createVNode("div", {
- "role": "tablist",
- "class": bem$d()
- }, [(_a = slots.default) == null ? void 0 : _a.call(slots)]);
- };
- }
- });
- const Sidebar = withInstall(stdin_default$i);
- const [name$c, bem$c] = createNamespace("sidebar-item");
- const sidebarItemProps = extend({}, routeProps, {
- dot: Boolean,
- title: String,
- badge: numericProp,
- disabled: Boolean,
- badgeProps: Object
- });
- var stdin_default$h = defineComponent({
- name: name$c,
- props: sidebarItemProps,
- emits: ["click"],
- setup(props, {
- emit,
- slots
- }) {
- const route2 = useRoute();
- const {
- parent,
- index
- } = useParent(SIDEBAR_KEY);
- if (!parent) {
- if (process.env.NODE_ENV !== "production") {
- console.error("[Vant] <SidebarItem> must be a child component of <Sidebar>.");
- }
- return;
- }
- const onClick = () => {
- if (props.disabled) {
- return;
- }
- emit("click", index.value);
- parent.setActive(index.value);
- route2();
- };
- return () => {
- const {
- dot,
- badge,
- title,
- disabled
- } = props;
- const selected = index.value === parent.getActive();
- return createVNode("div", {
- "role": "tab",
- "class": bem$c({
- select: selected,
- disabled
- }),
- "tabindex": disabled ? void 0 : 0,
- "aria-selected": selected,
- "onClick": onClick
- }, [createVNode(Badge, mergeProps({
- "dot": dot,
- "class": bem$c("text"),
- "content": badge
- }, props.badgeProps), {
- default: () => [slots.title ? slots.title() : title]
- })]);
- };
- }
- });
- const SidebarItem = withInstall(stdin_default$h);
- const [name$b, bem$b] = createNamespace("skeleton");
- const DEFAULT_ROW_WIDTH = "100%";
- const DEFAULT_LAST_ROW_WIDTH = "60%";
- const skeletonProps = {
- row: makeNumericProp(0),
- title: Boolean,
- round: Boolean,
- avatar: Boolean,
- loading: truthProp,
- animate: truthProp,
- avatarSize: numericProp,
- titleWidth: numericProp,
- avatarShape: makeStringProp("round"),
- rowWidth: {
- type: [Number, String, Array],
- default: DEFAULT_ROW_WIDTH
- }
- };
- var stdin_default$g = defineComponent({
- name: name$b,
- inheritAttrs: false,
- props: skeletonProps,
- setup(props, {
- slots,
- attrs
- }) {
- const renderAvatar = () => {
- if (props.avatar) {
- return createVNode("div", {
- "class": bem$b("avatar", props.avatarShape),
- "style": getSizeStyle(props.avatarSize)
- }, null);
- }
- };
- const renderTitle = () => {
- if (props.title) {
- return createVNode("h3", {
- "class": bem$b("title"),
- "style": {
- width: addUnit(props.titleWidth)
- }
- }, null);
- }
- };
- const getRowWidth = (index) => {
- const {
- rowWidth
- } = props;
- if (rowWidth === DEFAULT_ROW_WIDTH && index === +props.row - 1) {
- return DEFAULT_LAST_ROW_WIDTH;
- }
- if (Array.isArray(rowWidth)) {
- return rowWidth[index];
- }
- return rowWidth;
- };
- const renderRows = () => Array(+props.row).fill("").map((_, i) => createVNode("div", {
- "class": bem$b("row"),
- "style": {
- width: addUnit(getRowWidth(i))
- }
- }, null));
- return () => {
- var _a;
- if (!props.loading) {
- return (_a = slots.default) == null ? void 0 : _a.call(slots);
- }
- return createVNode("div", mergeProps({
- "class": bem$b({
- animate: props.animate,
- round: props.round
- })
- }, attrs), [renderAvatar(), createVNode("div", {
- "class": bem$b("content")
- }, [renderTitle(), renderRows()])]);
- };
- }
- });
- const Skeleton = withInstall(stdin_default$g);
- const [name$a, bem$a] = createNamespace("slider");
- const sliderProps = {
- min: makeNumericProp(0),
- max: makeNumericProp(100),
- step: makeNumericProp(1),
- range: Boolean,
- reverse: Boolean,
- disabled: Boolean,
- readonly: Boolean,
- vertical: Boolean,
- barHeight: numericProp,
- buttonSize: numericProp,
- activeColor: String,
- inactiveColor: String,
- modelValue: {
- type: [Number, Array],
- default: 0
- }
- };
- var stdin_default$f = defineComponent({
- name: name$a,
- props: sliderProps,
- emits: ["change", "drag-end", "drag-start", "update:modelValue"],
- setup(props, {
- emit,
- slots
- }) {
- let buttonIndex;
- let current2;
- let startValue;
- const root = ref();
- const slider = ref();
- const dragStatus = ref();
- const touch = useTouch();
- const scope = computed(() => Number(props.max) - Number(props.min));
- const wrapperStyle = computed(() => {
- const crossAxis = props.vertical ? "width" : "height";
- return {
- background: props.inactiveColor,
- [crossAxis]: addUnit(props.barHeight)
- };
- });
- const isRange = (val) => props.range && Array.isArray(val);
- const calcMainAxis = () => {
- const {
- modelValue,
- min
- } = props;
- if (isRange(modelValue)) {
- return `${(modelValue[1] - modelValue[0]) * 100 / scope.value}%`;
- }
- return `${(modelValue - Number(min)) * 100 / scope.value}%`;
- };
- const calcOffset = () => {
- const {
- modelValue,
- min
- } = props;
- if (isRange(modelValue)) {
- return `${(modelValue[0] - Number(min)) * 100 / scope.value}%`;
- }
- return "0%";
- };
- const barStyle = computed(() => {
- const mainAxis = props.vertical ? "height" : "width";
- const style = {
- [mainAxis]: calcMainAxis(),
- background: props.activeColor
- };
- if (dragStatus.value) {
- style.transition = "none";
- }
- const getPositionKey = () => {
- if (props.vertical) {
- return props.reverse ? "bottom" : "top";
- }
- return props.reverse ? "right" : "left";
- };
- style[getPositionKey()] = calcOffset();
- return style;
- });
- const format2 = (value) => {
- const min = +props.min;
- const max = +props.max;
- const step = +props.step;
- value = clamp(value, min, max);
- const diff = Math.round((value - min) / step) * step;
- return addNumber(min, diff);
- };
- const isSameValue = (newValue, oldValue) => JSON.stringify(newValue) === JSON.stringify(oldValue);
- const handleRangeValue = (value) => {
- var _a, _b;
- const left = (_a = value[0]) != null ? _a : Number(props.min);
- const right = (_b = value[1]) != null ? _b : Number(props.max);
- return left > right ? [right, left] : [left, right];
- };
- const updateValue = (value, end) => {
- if (isRange(value)) {
- value = handleRangeValue(value).map(format2);
- } else {
- value = format2(value);
- }
- if (!isSameValue(value, props.modelValue)) {
- emit("update:modelValue", value);
- }
- if (end && !isSameValue(value, startValue)) {
- emit("change", value);
- }
- };
- const onClick = (event) => {
- event.stopPropagation();
- if (props.disabled || props.readonly) {
- return;
- }
- const {
- min,
- reverse,
- vertical,
- modelValue
- } = props;
- const rect = useRect(root);
- const getDelta = () => {
- if (vertical) {
- if (reverse) {
- return rect.bottom - event.clientY;
- }
- return event.clientY - rect.top;
- }
- if (reverse) {
- return rect.right - event.clientX;
- }
- return event.clientX - rect.left;
- };
- const total = vertical ? rect.height : rect.width;
- const value = Number(min) + getDelta() / total * scope.value;
- if (isRange(modelValue)) {
- const [left, right] = modelValue;
- const middle = (left + right) / 2;
- if (value <= middle) {
- updateValue([value, right], true);
- } else {
- updateValue([left, value], true);
- }
- } else {
- updateValue(value, true);
- }
- };
- const onTouchStart = (event) => {
- if (props.disabled || props.readonly) {
- return;
- }
- touch.start(event);
- current2 = props.modelValue;
- if (isRange(current2)) {
- startValue = current2.map(format2);
- } else {
- startValue = format2(current2);
- }
- dragStatus.value = "start";
- };
- const onTouchMove = (event) => {
- if (props.disabled || props.readonly) {
- return;
- }
- if (dragStatus.value === "start") {
- emit("drag-start", event);
- }
- preventDefault(event, true);
- touch.move(event);
- dragStatus.value = "dragging";
- const rect = useRect(root);
- const delta = props.vertical ? touch.deltaY.value : touch.deltaX.value;
- const total = props.vertical ? rect.height : rect.width;
- let diff = delta / total * scope.value;
- if (props.reverse) {
- diff = -diff;
- }
- if (isRange(startValue)) {
- const index = props.reverse ? 1 - buttonIndex : buttonIndex;
- current2[index] = startValue[index] + diff;
- } else {
- current2 = startValue + diff;
- }
- updateValue(current2);
- };
- const onTouchEnd = (event) => {
- if (props.disabled || props.readonly) {
- return;
- }
- if (dragStatus.value === "dragging") {
- updateValue(current2, true);
- emit("drag-end", event);
- }
- dragStatus.value = "";
- };
- const getButtonClassName = (index) => {
- if (typeof index === "number") {
- const position = ["left", "right"];
- return bem$a(`button-wrapper`, position[index]);
- }
- return bem$a("button-wrapper", props.reverse ? "left" : "right");
- };
- const renderButtonContent = (value, index) => {
- if (typeof index === "number") {
- const slot = slots[index === 0 ? "left-button" : "right-button"];
- if (slot) {
- return slot({
- value
- });
- }
- }
- if (slots.button) {
- return slots.button({
- value
- });
- }
- return createVNode("div", {
- "class": bem$a("button"),
- "style": getSizeStyle(props.buttonSize)
- }, null);
- };
- const renderButton = (index) => {
- const current22 = typeof index === "number" ? props.modelValue[index] : props.modelValue;
- return createVNode("div", {
- "ref": slider,
- "role": "slider",
- "class": getButtonClassName(index),
- "tabindex": props.disabled ? void 0 : 0,
- "aria-valuemin": props.min,
- "aria-valuenow": current22,
- "aria-valuemax": props.max,
- "aria-disabled": props.disabled || void 0,
- "aria-readonly": props.readonly || void 0,
- "aria-orientation": props.vertical ? "vertical" : "horizontal",
- "onTouchstartPassive": (event) => {
- if (typeof index === "number") {
- buttonIndex = index;
- }
- onTouchStart(event);
- },
- "onTouchend": onTouchEnd,
- "onTouchcancel": onTouchEnd,
- "onClick": stopPropagation
- }, [renderButtonContent(current22, index)]);
- };
- updateValue(props.modelValue);
- useCustomFieldValue(() => props.modelValue);
- useEventListener("touchmove", onTouchMove, {
- target: slider
- });
- return () => createVNode("div", {
- "ref": root,
- "style": wrapperStyle.value,
- "class": bem$a({
- vertical: props.vertical,
- disabled: props.disabled
- }),
- "onClick": onClick
- }, [createVNode("div", {
- "class": bem$a("bar"),
- "style": barStyle.value
- }, [props.range ? [renderButton(0), renderButton(1)] : renderButton()])]);
- }
- });
- const Slider = withInstall(stdin_default$f);
- const [name$9, bem$9] = createNamespace("space");
- const spaceProps = {
- align: String,
- direction: {
- type: String,
- default: "horizontal"
- },
- size: {
- type: [Number, String, Array],
- default: 8
- },
- wrap: Boolean,
- fill: Boolean
- };
- function filterEmpty(children = []) {
- const nodes = [];
- children.forEach((child) => {
- if (Array.isArray(child)) {
- nodes.push(...child);
- } else if (child.type === Fragment) {
- nodes.push(...filterEmpty(child.children));
- } else {
- nodes.push(child);
- }
- });
- return nodes.filter((c) => {
- var _a;
- 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() === ""));
- });
- }
- var stdin_default$e = defineComponent({
- name: name$9,
- props: spaceProps,
- setup(props, {
- slots
- }) {
- const mergedAlign = computed(() => {
- var _a;
- return (_a = props.align) != null ? _a : props.direction === "horizontal" ? "center" : "";
- });
- const getMargin = (size) => {
- if (typeof size === "number") {
- return size + "px";
- }
- return size;
- };
- const getMarginStyle = (isLast) => {
- const style = {};
- const marginRight = `${getMargin(Array.isArray(props.size) ? props.size[0] : props.size)}`;
- const marginBottom = `${getMargin(Array.isArray(props.size) ? props.size[1] : props.size)}`;
- if (isLast) {
- return props.wrap ? {
- marginBottom
- } : {};
- }
- if (props.direction === "horizontal") {
- style.marginRight = marginRight;
- }
- if (props.direction === "vertical" || props.wrap) {
- style.marginBottom = marginBottom;
- }
- return style;
- };
- return () => {
- var _a;
- const children = filterEmpty((_a = slots.default) == null ? void 0 : _a.call(slots));
- return createVNode("div", {
- "class": [bem$9({
- [props.direction]: props.direction,
- [`align-${mergedAlign.value}`]: mergedAlign.value,
- wrap: props.wrap,
- fill: props.fill
- })]
- }, [children.map((c, i) => createVNode("div", {
- "key": `item-${i}`,
- "class": `${name$9}-item`,
- "style": getMarginStyle(i === children.length - 1)
- }, [c]))]);
- };
- }
- });
- const Space = withInstall(stdin_default$e);
- const [name$8, bem$8] = createNamespace("steps");
- const stepsProps = {
- active: makeNumericProp(0),
- direction: makeStringProp("horizontal"),
- activeIcon: makeStringProp("checked"),
- iconPrefix: String,
- finishIcon: String,
- activeColor: String,
- inactiveIcon: String,
- inactiveColor: String
- };
- const STEPS_KEY = Symbol(name$8);
- var stdin_default$d = defineComponent({
- name: name$8,
- props: stepsProps,
- emits: ["click-step"],
- setup(props, {
- emit,
- slots
- }) {
- const {
- linkChildren
- } = useChildren(STEPS_KEY);
- const onClickStep = (index) => emit("click-step", index);
- linkChildren({
- props,
- onClickStep
- });
- return () => {
- var _a;
- return createVNode("div", {
- "class": bem$8([props.direction])
- }, [createVNode("div", {
- "class": bem$8("items")
- }, [(_a = slots.default) == null ? void 0 : _a.call(slots)])]);
- };
- }
- });
- const [name$7, bem$7] = createNamespace("step");
- var stdin_default$c = defineComponent({
- name: name$7,
- setup(props, {
- slots
- }) {
- const {
- parent,
- index
- } = useParent(STEPS_KEY);
- if (!parent) {
- if (process.env.NODE_ENV !== "production") {
- console.error("[Vant] <Step> must be a child component of <Steps>.");
- }
- return;
- }
- const parentProps = parent.props;
- const getStatus = () => {
- const active = +parentProps.active;
- if (index.value < active) {
- return "finish";
- }
- return index.value === active ? "process" : "waiting";
- };
- const isActive = () => getStatus() === "process";
- const lineStyle = computed(() => ({
- background: getStatus() === "finish" ? parentProps.activeColor : parentProps.inactiveColor
- }));
- const titleStyle = computed(() => {
- if (isActive()) {
- return {
- color: parentProps.activeColor
- };
- }
- if (getStatus() === "waiting") {
- return {
- color: parentProps.inactiveColor
- };
- }
- });
- const onClickStep = () => parent.onClickStep(index.value);
- const renderCircle = () => {
- const {
- iconPrefix,
- finishIcon,
- activeIcon,
- activeColor,
- inactiveIcon
- } = parentProps;
- if (isActive()) {
- if (slots["active-icon"]) {
- return slots["active-icon"]();
- }
- return createVNode(Icon, {
- "class": bem$7("icon", "active"),
- "name": activeIcon,
- "color": activeColor,
- "classPrefix": iconPrefix
- }, null);
- }
- if (getStatus() === "finish" && (finishIcon || slots["finish-icon"])) {
- if (slots["finish-icon"]) {
- return slots["finish-icon"]();
- }
- return createVNode(Icon, {
- "class": bem$7("icon", "finish"),
- "name": finishIcon,
- "color": activeColor,
- "classPrefix": iconPrefix
- }, null);
- }
- if (slots["inactive-icon"]) {
- return slots["inactive-icon"]();
- }
- if (inactiveIcon) {
- return createVNode(Icon, {
- "class": bem$7("icon"),
- "name": inactiveIcon,
- "classPrefix": iconPrefix
- }, null);
- }
- return createVNode("i", {
- "class": bem$7("circle"),
- "style": lineStyle.value
- }, null);
- };
- return () => {
- var _a;
- const status = getStatus();
- return createVNode("div", {
- "class": [BORDER, bem$7([parentProps.direction, {
- [status]: status
- }])]
- }, [createVNode("div", {
- "class": bem$7("title", {
- active: isActive()
- }),
- "style": titleStyle.value,
- "onClick": onClickStep
- }, [(_a = slots.default) == null ? void 0 : _a.call(slots)]), createVNode("div", {
- "class": bem$7("circle-container"),
- "onClick": onClickStep
- }, [renderCircle()]), createVNode("div", {
- "class": bem$7("line"),
- "style": lineStyle.value
- }, null)]);
- };
- }
- });
- const Step = withInstall(stdin_default$c);
- const [name$6, bem$6] = createNamespace("stepper");
- const LONG_PRESS_INTERVAL = 200;
- const LONG_PRESS_START_TIME = 600;
- const isEqual = (value1, value2) => String(value1) === String(value2);
- const stepperProps = {
- min: makeNumericProp(1),
- max: makeNumericProp(Infinity),
- name: makeNumericProp(""),
- step: makeNumericProp(1),
- theme: String,
- integer: Boolean,
- disabled: Boolean,
- showPlus: truthProp,
- showMinus: truthProp,
- showInput: truthProp,
- longPress: truthProp,
- allowEmpty: Boolean,
- modelValue: numericProp,
- inputWidth: numericProp,
- buttonSize: numericProp,
- placeholder: String,
- disablePlus: Boolean,
- disableMinus: Boolean,
- disableInput: Boolean,
- beforeChange: Function,
- defaultValue: makeNumericProp(1),
- decimalLength: numericProp
- };
- var stdin_default$b = defineComponent({
- name: name$6,
- props: stepperProps,
- emits: ["plus", "blur", "minus", "focus", "change", "overlimit", "update:modelValue"],
- setup(props, {
- emit
- }) {
- const format2 = (value) => {
- const {
- min,
- max,
- allowEmpty,
- decimalLength
- } = props;
- if (allowEmpty && value === "") {
- return value;
- }
- value = formatNumber(String(value), !props.integer);
- value = value === "" ? 0 : +value;
- value = Number.isNaN(value) ? +min : value;
- value = Math.max(Math.min(+max, value), +min);
- if (isDef(decimalLength)) {
- value = value.toFixed(+decimalLength);
- }
- return value;
- };
- const getInitialValue = () => {
- var _a;
- const defaultValue = (_a = props.modelValue) != null ? _a : props.defaultValue;
- const value = format2(defaultValue);
- if (!isEqual(value, props.modelValue)) {
- emit("update:modelValue", value);
- }
- return value;
- };
- let actionType;
- const inputRef = ref();
- const current2 = ref(getInitialValue());
- const minusDisabled = computed(() => props.disabled || props.disableMinus || current2.value <= +props.min);
- const plusDisabled = computed(() => props.disabled || props.disablePlus || current2.value >= +props.max);
- const inputStyle = computed(() => ({
- width: addUnit(props.inputWidth),
- height: addUnit(props.buttonSize)
- }));
- const buttonStyle = computed(() => getSizeStyle(props.buttonSize));
- const check = () => {
- const value = format2(current2.value);
- if (!isEqual(value, current2.value)) {
- current2.value = value;
- }
- };
- const setValue = (value) => {
- if (props.beforeChange) {
- callInterceptor(props.beforeChange, {
- args: [value],
- done() {
- current2.value = value;
- }
- });
- } else {
- current2.value = value;
- }
- };
- const onChange = () => {
- if (actionType === "plus" && plusDisabled.value || actionType === "minus" && minusDisabled.value) {
- emit("overlimit", actionType);
- return;
- }
- const diff = actionType === "minus" ? -props.step : +props.step;
- const value = format2(addNumber(+current2.value, diff));
- setValue(value);
- emit(actionType);
- };
- const onInput = (event) => {
- const input = event.target;
- const {
- value
- } = input;
- const {
- decimalLength
- } = props;
- let formatted = formatNumber(String(value), !props.integer);
- if (isDef(decimalLength) && formatted.includes(".")) {
- const pair = formatted.split(".");
- formatted = `${pair[0]}.${pair[1].slice(0, +decimalLength)}`;
- }
- if (props.beforeChange) {
- input.value = String(current2.value);
- } else if (!isEqual(value, formatted)) {
- input.value = formatted;
- }
- const isNumeric2 = formatted === String(+formatted);
- setValue(isNumeric2 ? +formatted : formatted);
- };
- const onFocus = (event) => {
- var _a;
- if (props.disableInput) {
- (_a = inputRef.value) == null ? void 0 : _a.blur();
- } else {
- emit("focus", event);
- }
- };
- const onBlur = (event) => {
- const input = event.target;
- const value = format2(input.value);
- input.value = String(value);
- current2.value = value;
- nextTick(() => {
- emit("blur", event);
- resetScroll();
- });
- };
- let isLongPress;
- let longPressTimer;
- const longPressStep = () => {
- longPressTimer = setTimeout(() => {
- onChange();
- longPressStep();
- }, LONG_PRESS_INTERVAL);
- };
- const onTouchStart = () => {
- if (props.longPress) {
- isLongPress = false;
- clearTimeout(longPressTimer);
- longPressTimer = setTimeout(() => {
- isLongPress = true;
- onChange();
- longPressStep();
- }, LONG_PRESS_START_TIME);
- }
- };
- const onTouchEnd = (event) => {
- if (props.longPress) {
- clearTimeout(longPressTimer);
- if (isLongPress) {
- preventDefault(event);
- }
- }
- };
- const onMousedown = (event) => {
- if (props.disableInput) {
- preventDefault(event);
- }
- };
- const createListeners = (type) => ({
- onClick: (event) => {
- preventDefault(event);
- actionType = type;
- onChange();
- },
- onTouchstartPassive: () => {
- actionType = type;
- onTouchStart();
- },
- onTouchend: onTouchEnd,
- onTouchcancel: onTouchEnd
- });
- watch(() => [props.max, props.min, props.integer, props.decimalLength], check);
- watch(() => props.modelValue, (value) => {
- if (!isEqual(value, current2.value)) {
- current2.value = format2(value);
- }
- });
- watch(current2, (value) => {
- emit("update:modelValue", value);
- emit("change", value, {
- name: props.name
- });
- });
- useCustomFieldValue(() => props.modelValue);
- return () => createVNode("div", {
- "role": "group",
- "class": bem$6([props.theme])
- }, [withDirectives(createVNode("button", mergeProps({
- "type": "button",
- "style": buttonStyle.value,
- "class": [bem$6("minus", {
- disabled: minusDisabled.value
- }), {
- [HAPTICS_FEEDBACK]: !minusDisabled.value
- }],
- "aria-disabled": minusDisabled.value || void 0
- }, createListeners("minus")), null), [[vShow, props.showMinus]]), withDirectives(createVNode("input", {
- "ref": inputRef,
- "type": props.integer ? "tel" : "text",
- "role": "spinbutton",
- "class": bem$6("input"),
- "value": current2.value,
- "style": inputStyle.value,
- "disabled": props.disabled,
- "readonly": props.disableInput,
- "inputmode": props.integer ? "numeric" : "decimal",
- "placeholder": props.placeholder,
- "aria-valuemax": props.max,
- "aria-valuemin": props.min,
- "aria-valuenow": current2.value,
- "onBlur": onBlur,
- "onInput": onInput,
- "onFocus": onFocus,
- "onMousedown": onMousedown
- }, null), [[vShow, props.showInput]]), withDirectives(createVNode("button", mergeProps({
- "type": "button",
- "style": buttonStyle.value,
- "class": [bem$6("plus", {
- disabled: plusDisabled.value
- }), {
- [HAPTICS_FEEDBACK]: !plusDisabled.value
- }],
- "aria-disabled": plusDisabled.value || void 0
- }, createListeners("plus")), null), [[vShow, props.showPlus]])]);
- }
- });
- const Stepper = withInstall(stdin_default$b);
- const Steps = withInstall(stdin_default$d);
- const [name$5, bem$5, t$1] = createNamespace("submit-bar");
- const submitBarProps = {
- tip: String,
- label: String,
- price: Number,
- tipIcon: String,
- loading: Boolean,
- currency: makeStringProp("\xA5"),
- disabled: Boolean,
- textAlign: String,
- buttonText: String,
- buttonType: makeStringProp("danger"),
- buttonColor: String,
- suffixLabel: String,
- placeholder: Boolean,
- decimalLength: makeNumericProp(2),
- safeAreaInsetBottom: truthProp
- };
- var stdin_default$a = defineComponent({
- name: name$5,
- props: submitBarProps,
- emits: ["submit"],
- setup(props, {
- emit,
- slots
- }) {
- const root = ref();
- const renderPlaceholder = usePlaceholder(root, bem$5);
- const renderText = () => {
- const {
- price,
- label,
- currency,
- textAlign,
- suffixLabel,
- decimalLength
- } = props;
- if (typeof price === "number") {
- const pricePair = (price / 100).toFixed(+decimalLength).split(".");
- const decimal = decimalLength ? `.${pricePair[1]}` : "";
- return createVNode("div", {
- "class": bem$5("text"),
- "style": {
- textAlign
- }
- }, [createVNode("span", null, [label || t$1("label")]), createVNode("span", {
- "class": bem$5("price")
- }, [currency, createVNode("span", {
- "class": bem$5("price-integer")
- }, [pricePair[0]]), decimal]), suffixLabel && createVNode("span", {
- "class": bem$5("suffix-label")
- }, [suffixLabel])]);
- }
- };
- const renderTip = () => {
- var _a;
- const {
- tip,
- tipIcon
- } = props;
- if (slots.tip || tip) {
- return createVNode("div", {
- "class": bem$5("tip")
- }, [tipIcon && createVNode(Icon, {
- "class": bem$5("tip-icon"),
- "name": tipIcon
- }, null), tip && createVNode("span", {
- "class": bem$5("tip-text")
- }, [tip]), (_a = slots.tip) == null ? void 0 : _a.call(slots)]);
- }
- };
- const onClickButton = () => emit("submit");
- const renderButton = () => {
- if (slots.button) {
- return slots.button();
- }
- return createVNode(Button, {
- "round": true,
- "type": props.buttonType,
- "text": props.buttonText,
- "class": bem$5("button", props.buttonType),
- "color": props.buttonColor,
- "loading": props.loading,
- "disabled": props.disabled,
- "onClick": onClickButton
- }, null);
- };
- const renderSubmitBar = () => {
- var _a, _b;
- return createVNode("div", {
- "ref": root,
- "class": [bem$5(), {
- "van-safe-area-bottom": props.safeAreaInsetBottom
- }]
- }, [(_a = slots.top) == null ? void 0 : _a.call(slots), renderTip(), createVNode("div", {
- "class": bem$5("bar")
- }, [(_b = slots.default) == null ? void 0 : _b.call(slots), renderText(), renderButton()])]);
- };
- return () => {
- if (props.placeholder) {
- return renderPlaceholder(renderSubmitBar);
- }
- return renderSubmitBar();
- };
- }
- });
- const SubmitBar = withInstall(stdin_default$a);
- const [name$4, bem$4] = createNamespace("swipe-cell");
- const swipeCellProps = {
- name: makeNumericProp(""),
- disabled: Boolean,
- leftWidth: numericProp,
- rightWidth: numericProp,
- beforeClose: Function,
- stopPropagation: Boolean
- };
- var stdin_default$9 = defineComponent({
- name: name$4,
- props: swipeCellProps,
- emits: ["open", "close", "click"],
- setup(props, {
- emit,
- slots
- }) {
- let opened;
- let lockClick2;
- let startOffset;
- const root = ref();
- const leftRef = ref();
- const rightRef = ref();
- const state = reactive({
- offset: 0,
- dragging: false
- });
- const touch = useTouch();
- const getWidthByRef = (ref2) => ref2.value ? useRect(ref2).width : 0;
- const leftWidth = computed(() => isDef(props.leftWidth) ? +props.leftWidth : getWidthByRef(leftRef));
- const rightWidth = computed(() => isDef(props.rightWidth) ? +props.rightWidth : getWidthByRef(rightRef));
- const open = (side) => {
- state.offset = side === "left" ? leftWidth.value : -rightWidth.value;
- if (!opened) {
- opened = true;
- emit("open", {
- name: props.name,
- position: side
- });
- }
- };
- const close = (position) => {
- state.offset = 0;
- if (opened) {
- opened = false;
- emit("close", {
- name: props.name,
- position
- });
- }
- };
- const toggle = (side) => {
- const offset = Math.abs(state.offset);
- const THRESHOLD = 0.15;
- const threshold = opened ? 1 - THRESHOLD : THRESHOLD;
- const width = side === "left" ? leftWidth.value : rightWidth.value;
- if (width && offset > width * threshold) {
- open(side);
- } else {
- close(side);
- }
- };
- const onTouchStart = (event) => {
- if (!props.disabled) {
- startOffset = state.offset;
- touch.start(event);
- }
- };
- const onTouchMove = (event) => {
- if (props.disabled) {
- return;
- }
- const {
- deltaX
- } = touch;
- touch.move(event);
- if (touch.isHorizontal()) {
- lockClick2 = true;
- state.dragging = true;
- const isEdge = !opened || deltaX.value * startOffset < 0;
- if (isEdge) {
- preventDefault(event, props.stopPropagation);
- }
- state.offset = clamp(deltaX.value + startOffset, -rightWidth.value, leftWidth.value);
- }
- };
- const onTouchEnd = () => {
- if (state.dragging) {
- state.dragging = false;
- toggle(state.offset > 0 ? "left" : "right");
- setTimeout(() => {
- lockClick2 = false;
- }, 0);
- }
- };
- const onClick = (position = "outside") => {
- emit("click", position);
- if (opened && !lockClick2) {
- callInterceptor(props.beforeClose, {
- args: [{
- name: props.name,
- position
- }],
- done: () => close(position)
- });
- }
- };
- const getClickHandler = (position, stop) => (event) => {
- if (stop) {
- event.stopPropagation();
- }
- onClick(position);
- };
- const renderSideContent = (side, ref2) => {
- const contentSlot = slots[side];
- if (contentSlot) {
- return createVNode("div", {
- "ref": ref2,
- "class": bem$4(side),
- "onClick": getClickHandler(side, true)
- }, [contentSlot()]);
- }
- };
- useExpose({
- open,
- close
- });
- useClickAway(root, () => onClick("outside"), {
- eventName: "touchstart"
- });
- useEventListener("touchmove", onTouchMove, {
- target: root
- });
- return () => {
- var _a;
- const wrapperStyle = {
- transform: `translate3d(${state.offset}px, 0, 0)`,
- transitionDuration: state.dragging ? "0s" : ".6s"
- };
- return createVNode("div", {
- "ref": root,
- "class": bem$4(),
- "onClick": getClickHandler("cell", lockClick2),
- "onTouchstartPassive": onTouchStart,
- "onTouchend": onTouchEnd,
- "onTouchcancel": onTouchEnd
- }, [createVNode("div", {
- "class": bem$4("wrapper"),
- "style": wrapperStyle
- }, [renderSideContent("left", leftRef), (_a = slots.default) == null ? void 0 : _a.call(slots), renderSideContent("right", rightRef)])]);
- };
- }
- });
- const SwipeCell = withInstall(stdin_default$9);
- const [name$3, bem$3] = createNamespace("tabbar");
- const tabbarProps = {
- route: Boolean,
- fixed: truthProp,
- border: truthProp,
- zIndex: numericProp,
- placeholder: Boolean,
- activeColor: String,
- beforeChange: Function,
- inactiveColor: String,
- modelValue: makeNumericProp(0),
- safeAreaInsetBottom: {
- type: Boolean,
- default: null
- }
- };
- const TABBAR_KEY = Symbol(name$3);
- var stdin_default$8 = defineComponent({
- name: name$3,
- props: tabbarProps,
- emits: ["change", "update:modelValue"],
- setup(props, {
- emit,
- slots
- }) {
- const root = ref();
- const {
- linkChildren
- } = useChildren(TABBAR_KEY);
- const renderPlaceholder = usePlaceholder(root, bem$3);
- const enableSafeArea = () => {
- var _a;
- return (_a = props.safeAreaInsetBottom) != null ? _a : props.fixed;
- };
- const renderTabbar = () => {
- var _a;
- const {
- fixed,
- zIndex,
- border
- } = props;
- return createVNode("div", {
- "ref": root,
- "role": "tablist",
- "style": getZIndexStyle(zIndex),
- "class": [bem$3({
- fixed
- }), {
- [BORDER_TOP_BOTTOM]: border,
- "van-safe-area-bottom": enableSafeArea()
- }]
- }, [(_a = slots.default) == null ? void 0 : _a.call(slots)]);
- };
- const setActive = (active, afterChange) => {
- callInterceptor(props.beforeChange, {
- args: [active],
- done() {
- emit("update:modelValue", active);
- emit("change", active);
- afterChange();
- }
- });
- };
- linkChildren({
- props,
- setActive
- });
- return () => {
- if (props.fixed && props.placeholder) {
- return renderPlaceholder(renderTabbar);
- }
- return renderTabbar();
- };
- }
- });
- const Tabbar = withInstall(stdin_default$8);
- const [name$2, bem$2] = createNamespace("tabbar-item");
- const tabbarItemProps = extend({}, routeProps, {
- dot: Boolean,
- icon: String,
- name: numericProp,
- badge: numericProp,
- badgeProps: Object,
- iconPrefix: String
- });
- var stdin_default$7 = defineComponent({
- name: name$2,
- props: tabbarItemProps,
- emits: ["click"],
- setup(props, {
- emit,
- slots
- }) {
- const route2 = useRoute();
- const vm = getCurrentInstance().proxy;
- const {
- parent,
- index
- } = useParent(TABBAR_KEY);
- if (!parent) {
- if (process.env.NODE_ENV !== "production") {
- console.error("[Vant] <TabbarItem> must be a child component of <Tabbar>.");
- }
- return;
- }
- const active = computed(() => {
- var _a;
- const {
- route: route22,
- modelValue
- } = parent.props;
- if (route22 && "$route" in vm) {
- const {
- $route
- } = vm;
- const {
- to
- } = props;
- const config = isObject(to) ? to : {
- path: to
- };
- return !!$route.matched.find((val) => {
- const pathMatched = "path" in config && config.path === val.path;
- const nameMatched = "name" in config && config.name === val.name;
- return pathMatched || nameMatched;
- });
- }
- return ((_a = props.name) != null ? _a : index.value) === modelValue;
- });
- const onClick = (event) => {
- var _a;
- if (!active.value) {
- parent.setActive((_a = props.name) != null ? _a : index.value, route2);
- }
- emit("click", event);
- };
- const renderIcon = () => {
- if (slots.icon) {
- return slots.icon({
- active: active.value
- });
- }
- if (props.icon) {
- return createVNode(Icon, {
- "name": props.icon,
- "classPrefix": props.iconPrefix
- }, null);
- }
- };
- return () => {
- var _a;
- const {
- dot,
- badge
- } = props;
- const {
- activeColor,
- inactiveColor
- } = parent.props;
- const color = active.value ? activeColor : inactiveColor;
- return createVNode("div", {
- "role": "tab",
- "class": bem$2({
- active: active.value
- }),
- "style": {
- color
- },
- "tabindex": 0,
- "aria-selected": active.value,
- "onClick": onClick
- }, [createVNode(Badge, mergeProps({
- "dot": dot,
- "class": bem$2("icon"),
- "content": badge
- }, props.badgeProps), {
- default: renderIcon
- }), createVNode("div", {
- "class": bem$2("text")
- }, [(_a = slots.default) == null ? void 0 : _a.call(slots, {
- active: active.value
- })])]);
- };
- }
- });
- const TabbarItem = withInstall(stdin_default$7);
- const [name$1, bem$1] = createNamespace("tree-select");
- const treeSelectProps = {
- max: makeNumericProp(Infinity),
- items: makeArrayProp(),
- height: makeNumericProp(300),
- selectedIcon: makeStringProp("success"),
- mainActiveIndex: makeNumericProp(0),
- activeId: {
- type: [Number, String, Array],
- default: 0
- }
- };
- var stdin_default$6 = defineComponent({
- name: name$1,
- props: treeSelectProps,
- emits: ["click-nav", "click-item", "update:activeId", "update:mainActiveIndex"],
- setup(props, {
- emit,
- slots
- }) {
- const isActiveItem = (id) => Array.isArray(props.activeId) ? props.activeId.includes(id) : props.activeId === id;
- const renderSubItem = (item) => {
- const onClick = () => {
- if (item.disabled) {
- return;
- }
- let activeId;
- if (Array.isArray(props.activeId)) {
- activeId = props.activeId.slice();
- const index = activeId.indexOf(item.id);
- if (index !== -1) {
- activeId.splice(index, 1);
- } else if (activeId.length < props.max) {
- activeId.push(item.id);
- }
- } else {
- activeId = item.id;
- }
- emit("update:activeId", activeId);
- emit("click-item", item);
- };
- return createVNode("div", {
- "key": item.id,
- "class": ["van-ellipsis", bem$1("item", {
- active: isActiveItem(item.id),
- disabled: item.disabled
- })],
- "onClick": onClick
- }, [item.text, isActiveItem(item.id) && createVNode(Icon, {
- "name": props.selectedIcon,
- "class": bem$1("selected")
- }, null)]);
- };
- const onSidebarChange = (index) => {
- emit("update:mainActiveIndex", index);
- };
- const onClickSidebarItem = (index) => emit("click-nav", index);
- const renderSidebar = () => {
- const Items = props.items.map((item) => createVNode(SidebarItem, {
- "dot": item.dot,
- "title": item.text,
- "badge": item.badge,
- "class": [bem$1("nav-item"), item.className],
- "disabled": item.disabled,
- "onClick": onClickSidebarItem
- }, null));
- return createVNode(Sidebar, {
- "class": bem$1("nav"),
- "modelValue": props.mainActiveIndex,
- "onChange": onSidebarChange
- }, {
- default: () => [Items]
- });
- };
- const renderContent = () => {
- if (slots.content) {
- return slots.content();
- }
- const selected = props.items[+props.mainActiveIndex] || {};
- if (selected.children) {
- return selected.children.map(renderSubItem);
- }
- };
- return () => createVNode("div", {
- "class": bem$1(),
- "style": {
- height: addUnit(props.height)
- }
- }, [renderSidebar(), createVNode("div", {
- "class": bem$1("content")
- }, [renderContent()])]);
- }
- });
- const TreeSelect = withInstall(stdin_default$6);
- const [name, bem, t] = createNamespace("uploader");
- function readFileContent(file, resultType) {
- return new Promise((resolve) => {
- if (resultType === "file") {
- resolve();
- return;
- }
- const reader = new FileReader();
- reader.onload = (event) => {
- resolve(event.target.result);
- };
- if (resultType === "dataUrl") {
- reader.readAsDataURL(file);
- } else if (resultType === "text") {
- reader.readAsText(file);
- }
- });
- }
- function isOversize(items, maxSize) {
- return toArray(items).some((item) => {
- if (item.file) {
- if (isFunction(maxSize)) {
- return maxSize(item.file);
- }
- return item.file.size > maxSize;
- }
- return false;
- });
- }
- function filterFiles(items, maxSize) {
- const valid = [];
- const invalid = [];
- items.forEach((item) => {
- if (isOversize(item, maxSize)) {
- invalid.push(item);
- } else {
- valid.push(item);
- }
- });
- return { valid, invalid };
- }
- const IMAGE_REGEXP = /\.(jpeg|jpg|gif|png|svg|webp|jfif|bmp|dpg)/i;
- const isImageUrl = (url) => IMAGE_REGEXP.test(url);
- function isImageFile(item) {
- if (item.isImage) {
- return true;
- }
- if (item.file && item.file.type) {
- return item.file.type.indexOf("image") === 0;
- }
- if (item.url) {
- return isImageUrl(item.url);
- }
- if (typeof item.content === "string") {
- return item.content.indexOf("data:image") === 0;
- }
- return false;
- }
- var stdin_default$5 = defineComponent({
- props: {
- name: numericProp,
- item: makeRequiredProp(Object),
- index: Number,
- imageFit: String,
- lazyLoad: Boolean,
- deletable: Boolean,
- previewSize: [Number, String, Array],
- beforeDelete: Function
- },
- emits: ["delete", "preview"],
- setup(props, {
- emit,
- slots
- }) {
- const renderMask = () => {
- const {
- status,
- message
- } = props.item;
- if (status === "uploading" || status === "failed") {
- const MaskIcon = status === "failed" ? createVNode(Icon, {
- "name": "close",
- "class": bem("mask-icon")
- }, null) : createVNode(Loading, {
- "class": bem("loading")
- }, null);
- const showMessage = isDef(message) && message !== "";
- return createVNode("div", {
- "class": bem("mask")
- }, [MaskIcon, showMessage && createVNode("div", {
- "class": bem("mask-message")
- }, [message])]);
- }
- };
- const onDelete = (event) => {
- const {
- name: name2,
- item,
- index,
- beforeDelete
- } = props;
- event.stopPropagation();
- callInterceptor(beforeDelete, {
- args: [item, {
- name: name2,
- index
- }],
- done: () => emit("delete")
- });
- };
- const onPreview = () => emit("preview");
- const renderDeleteIcon = () => {
- if (props.deletable && props.item.status !== "uploading") {
- const slot = slots["preview-delete"];
- return createVNode("div", {
- "role": "button",
- "class": bem("preview-delete", {
- shadow: !slot
- }),
- "tabindex": 0,
- "aria-label": t("delete"),
- "onClick": onDelete
- }, [slot ? slot() : createVNode(Icon, {
- "name": "cross",
- "class": bem("preview-delete-icon")
- }, null)]);
- }
- };
- const renderCover = () => {
- if (slots["preview-cover"]) {
- const {
- index,
- item
- } = props;
- return createVNode("div", {
- "class": bem("preview-cover")
- }, [slots["preview-cover"](extend({
- index
- }, item))]);
- }
- };
- const renderPreview = () => {
- const {
- item,
- lazyLoad,
- imageFit,
- previewSize
- } = props;
- if (isImageFile(item)) {
- return createVNode(Image$1, {
- "fit": imageFit,
- "src": item.content || item.url,
- "class": bem("preview-image"),
- "width": Array.isArray(previewSize) ? previewSize[0] : previewSize,
- "height": Array.isArray(previewSize) ? previewSize[1] : previewSize,
- "lazyLoad": lazyLoad,
- "onClick": onPreview
- }, {
- default: renderCover
- });
- }
- return createVNode("div", {
- "class": bem("file"),
- "style": getSizeStyle(props.previewSize)
- }, [createVNode(Icon, {
- "class": bem("file-icon"),
- "name": "description"
- }, null), createVNode("div", {
- "class": [bem("file-name"), "van-ellipsis"]
- }, [item.file ? item.file.name : item.url]), renderCover()]);
- };
- return () => createVNode("div", {
- "class": bem("preview")
- }, [renderPreview(), renderMask(), renderDeleteIcon()]);
- }
- });
- const uploaderProps = {
- name: makeNumericProp(""),
- accept: makeStringProp("image/*"),
- capture: String,
- multiple: Boolean,
- disabled: Boolean,
- readonly: Boolean,
- lazyLoad: Boolean,
- maxCount: makeNumericProp(Infinity),
- imageFit: makeStringProp("cover"),
- resultType: makeStringProp("dataUrl"),
- uploadIcon: makeStringProp("photograph"),
- uploadText: String,
- deletable: truthProp,
- afterRead: Function,
- showUpload: truthProp,
- modelValue: makeArrayProp(),
- beforeRead: Function,
- beforeDelete: Function,
- previewSize: [Number, String, Array],
- previewImage: truthProp,
- previewOptions: Object,
- previewFullImage: truthProp,
- maxSize: {
- type: [Number, String, Function],
- default: Infinity
- }
- };
- var stdin_default$4 = defineComponent({
- name,
- props: uploaderProps,
- emits: ["delete", "oversize", "click-upload", "close-preview", "click-preview", "update:modelValue"],
- setup(props, {
- emit,
- slots
- }) {
- const inputRef = ref();
- const urls = [];
- const getDetail = (index = props.modelValue.length) => ({
- name: props.name,
- index
- });
- const resetInput = () => {
- if (inputRef.value) {
- inputRef.value.value = "";
- }
- };
- const onAfterRead = (items) => {
- resetInput();
- if (isOversize(items, props.maxSize)) {
- if (Array.isArray(items)) {
- const result = filterFiles(items, props.maxSize);
- items = result.valid;
- emit("oversize", result.invalid, getDetail());
- if (!items.length) {
- return;
- }
- } else {
- emit("oversize", items, getDetail());
- return;
- }
- }
- items = reactive(items);
- emit("update:modelValue", [...props.modelValue, ...toArray(items)]);
- if (props.afterRead) {
- props.afterRead(items, getDetail());
- }
- };
- const readFile = (files) => {
- const {
- maxCount,
- modelValue,
- resultType
- } = props;
- if (Array.isArray(files)) {
- const remainCount = +maxCount - modelValue.length;
- if (files.length > remainCount) {
- files = files.slice(0, remainCount);
- }
- Promise.all(files.map((file) => readFileContent(file, resultType))).then((contents) => {
- const fileList = files.map((file, index) => {
- const result = {
- file,
- status: "",
- message: ""
- };
- if (contents[index]) {
- result.content = contents[index];
- }
- return result;
- });
- onAfterRead(fileList);
- });
- } else {
- readFileContent(files, resultType).then((content) => {
- const result = {
- file: files,
- status: "",
- message: ""
- };
- if (content) {
- result.content = content;
- }
- onAfterRead(result);
- });
- }
- };
- const onChange = (event) => {
- const {
- files
- } = event.target;
- if (props.disabled || !files || !files.length) {
- return;
- }
- const file = files.length === 1 ? files[0] : [].slice.call(files);
- if (props.beforeRead) {
- const response = props.beforeRead(file, getDetail());
- if (!response) {
- resetInput();
- return;
- }
- if (isPromise(response)) {
- response.then((data) => {
- if (data) {
- readFile(data);
- } else {
- readFile(file);
- }
- }).catch(resetInput);
- return;
- }
- }
- readFile(file);
- };
- let imagePreview;
- const onClosePreview = () => emit("close-preview");
- const previewImage = (item) => {
- if (props.previewFullImage) {
- const imageFiles = props.modelValue.filter(isImageFile);
- const images = imageFiles.map((item2) => {
- if (item2.file && !item2.url && item2.status !== "failed") {
- item2.url = URL.createObjectURL(item2.file);
- urls.push(item2.url);
- }
- return item2.url;
- }).filter(Boolean);
- imagePreview = ImagePreview(extend({
- images,
- startPosition: imageFiles.indexOf(item),
- onClose: onClosePreview
- }, props.previewOptions));
- }
- };
- const closeImagePreview = () => {
- if (imagePreview) {
- imagePreview.close();
- }
- };
- const deleteFile = (item, index) => {
- const fileList = props.modelValue.slice(0);
- fileList.splice(index, 1);
- emit("update:modelValue", fileList);
- emit("delete", item, getDetail(index));
- };
- const renderPreviewItem = (item, index) => {
- const needPickData = ["imageFit", "deletable", "previewSize", "beforeDelete"];
- const previewData = extend(pick(props, needPickData), pick(item, needPickData, true));
- return createVNode(stdin_default$5, mergeProps({
- "item": item,
- "index": index,
- "onClick": () => emit("click-preview", item, getDetail(index)),
- "onDelete": () => deleteFile(item, index),
- "onPreview": () => previewImage(item)
- }, pick(props, ["name", "lazyLoad"]), previewData), pick(slots, ["preview-cover", "preview-delete"]));
- };
- const renderPreviewList = () => {
- if (props.previewImage) {
- return props.modelValue.map(renderPreviewItem);
- }
- };
- const onClickUpload = (event) => emit("click-upload", event);
- const renderUpload = () => {
- if (props.modelValue.length >= props.maxCount || !props.showUpload) {
- return;
- }
- const Input = props.readonly ? null : createVNode("input", {
- "ref": inputRef,
- "type": "file",
- "class": bem("input"),
- "accept": props.accept,
- "capture": props.capture,
- "multiple": props.multiple,
- "disabled": props.disabled,
- "onChange": onChange
- }, null);
- if (slots.default) {
- return createVNode("div", {
- "class": bem("input-wrapper"),
- "onClick": onClickUpload
- }, [slots.default(), Input]);
- }
- return createVNode("div", {
- "class": bem("upload", {
- readonly: props.readonly
- }),
- "style": getSizeStyle(props.previewSize),
- "onClick": onClickUpload
- }, [createVNode(Icon, {
- "name": props.uploadIcon,
- "class": bem("upload-icon")
- }, null), props.uploadText && createVNode("span", {
- "class": bem("upload-text")
- }, [props.uploadText]), Input]);
- };
- const chooseFile = () => {
- if (inputRef.value && !props.disabled) {
- inputRef.value.click();
- }
- };
- onBeforeUnmount(() => {
- urls.forEach((url) => URL.revokeObjectURL(url));
- });
- useExpose({
- chooseFile,
- closeImagePreview
- });
- useCustomFieldValue(() => props.modelValue);
- return () => createVNode("div", {
- "class": bem()
- }, [createVNode("div", {
- "class": bem("wrapper", {
- disabled: props.disabled
- })
- }, [renderPreviewList(), renderUpload()])]);
- }
- });
- const Uploader = withInstall(stdin_default$4);
- const hasIntersectionObserver = inBrowser$1 && "IntersectionObserver" in window && "IntersectionObserverEntry" in window && "intersectionRatio" in window.IntersectionObserverEntry.prototype;
- const modeType = {
- event: "event",
- observer: "observer"
- };
- function remove(arr, item) {
- if (!arr.length)
- return;
- const index = arr.indexOf(item);
- if (index > -1)
- return arr.splice(index, 1);
- }
- function getBestSelectionFromSrcset(el, scale) {
- if (el.tagName !== "IMG" || !el.getAttribute("data-srcset"))
- return;
- let options = el.getAttribute("data-srcset");
- const container = el.parentNode;
- const containerWidth = container.offsetWidth * scale;
- let spaceIndex;
- let tmpSrc;
- let tmpWidth;
- options = options.trim().split(",");
- const result = options.map((item) => {
- item = item.trim();
- spaceIndex = item.lastIndexOf(" ");
- if (spaceIndex === -1) {
- tmpSrc = item;
- tmpWidth = 999998;
- } else {
- tmpSrc = item.substr(0, spaceIndex);
- tmpWidth = parseInt(
- item.substr(spaceIndex + 1, item.length - spaceIndex - 2),
- 10
- );
- }
- return [tmpWidth, tmpSrc];
- });
- result.sort((a, b) => {
- if (a[0] < b[0]) {
- return 1;
- }
- if (a[0] > b[0]) {
- return -1;
- }
- if (a[0] === b[0]) {
- if (b[1].indexOf(".webp", b[1].length - 5) !== -1) {
- return 1;
- }
- if (a[1].indexOf(".webp", a[1].length - 5) !== -1) {
- return -1;
- }
- }
- return 0;
- });
- let bestSelectedSrc = "";
- let tmpOption;
- for (let i = 0; i < result.length; i++) {
- tmpOption = result[i];
- bestSelectedSrc = tmpOption[1];
- const next = result[i + 1];
- if (next && next[0] < containerWidth) {
- bestSelectedSrc = tmpOption[1];
- break;
- } else if (!next) {
- bestSelectedSrc = tmpOption[1];
- break;
- }
- }
- return bestSelectedSrc;
- }
- const getDPR = (scale = 1) => inBrowser$1 ? window.devicePixelRatio || scale : scale;
- function supportWebp() {
- if (!inBrowser$1)
- return false;
- let support = true;
- try {
- const elem = document.createElement("canvas");
- if (elem.getContext && elem.getContext("2d")) {
- support = elem.toDataURL("image/webp").indexOf("data:image/webp") === 0;
- }
- } catch (err) {
- support = false;
- }
- return support;
- }
- function throttle(action, delay) {
- let timeout = null;
- let lastRun = 0;
- return function(...args) {
- if (timeout) {
- return;
- }
- const elapsed = Date.now() - lastRun;
- const runCallback = () => {
- lastRun = Date.now();
- timeout = false;
- action.apply(this, args);
- };
- if (elapsed >= delay) {
- runCallback();
- } else {
- timeout = setTimeout(runCallback, delay);
- }
- };
- }
- function on(el, type, func) {
- el.addEventListener(type, func, {
- capture: false,
- passive: true
- });
- }
- function off(el, type, func) {
- el.removeEventListener(type, func, false);
- }
- const loadImageAsync = (item, resolve, reject) => {
- const image = new Image();
- if (!item || !item.src) {
- return reject(new Error("image src is required"));
- }
- image.src = item.src;
- if (item.cors) {
- image.crossOrigin = item.cors;
- }
- image.onload = () => resolve({
- naturalHeight: image.naturalHeight,
- naturalWidth: image.naturalWidth,
- src: image.src
- });
- image.onerror = (e) => reject(e);
- };
- class ImageCache {
- constructor({ max }) {
- this.options = {
- max: max || 100
- };
- this.caches = [];
- }
- has(key) {
- return this.caches.indexOf(key) > -1;
- }
- add(key) {
- if (this.has(key))
- return;
- this.caches.push(key);
- if (this.caches.length > this.options.max) {
- this.free();
- }
- }
- free() {
- this.caches.shift();
- }
- }
- class ReactiveListener {
- constructor({
- el,
- src,
- error,
- loading,
- bindType,
- $parent,
- options,
- cors,
- elRenderer,
- imageCache
- }) {
- this.el = el;
- this.src = src;
- this.error = error;
- this.loading = loading;
- this.bindType = bindType;
- this.attempt = 0;
- this.cors = cors;
- this.naturalHeight = 0;
- this.naturalWidth = 0;
- this.options = options;
- this.$parent = $parent;
- this.elRenderer = elRenderer;
- this.imageCache = imageCache;
- this.performanceData = {
- loadStart: 0,
- loadEnd: 0
- };
- this.filter();
- this.initState();
- this.render("loading", false);
- }
- initState() {
- if ("dataset" in this.el) {
- this.el.dataset.src = this.src;
- } else {
- this.el.setAttribute("data-src", this.src);
- }
- this.state = {
- loading: false,
- error: false,
- loaded: false,
- rendered: false
- };
- }
- record(event) {
- this.performanceData[event] = Date.now();
- }
- update({ src, loading, error }) {
- const oldSrc = this.src;
- this.src = src;
- this.loading = loading;
- this.error = error;
- this.filter();
- if (oldSrc !== this.src) {
- this.attempt = 0;
- this.initState();
- }
- }
- checkInView() {
- const rect = useRect(this.el);
- return rect.top < window.innerHeight * this.options.preLoad && rect.bottom > this.options.preLoadTop && rect.left < window.innerWidth * this.options.preLoad && rect.right > 0;
- }
- filter() {
- Object.keys(this.options.filter).forEach((key) => {
- this.options.filter[key](this, this.options);
- });
- }
- renderLoading(cb) {
- this.state.loading = true;
- loadImageAsync(
- {
- src: this.loading,
- cors: this.cors
- },
- () => {
- this.render("loading", false);
- this.state.loading = false;
- cb();
- },
- () => {
- cb();
- this.state.loading = false;
- if (process.env.NODE_ENV !== "production" && !this.options.silent)
- console.warn(
- `[@vant/lazyload] load failed with loading image(${this.loading})`
- );
- }
- );
- }
- load(onFinish = noop) {
- if (this.attempt > this.options.attempt - 1 && this.state.error) {
- if (process.env.NODE_ENV !== "production" && !this.options.silent) {
- console.log(
- `[@vant/lazyload] ${this.src} tried too more than ${this.options.attempt} times`
- );
- }
- onFinish();
- return;
- }
- if (this.state.rendered && this.state.loaded)
- return;
- if (this.imageCache.has(this.src)) {
- this.state.loaded = true;
- this.render("loaded", true);
- this.state.rendered = true;
- return onFinish();
- }
- this.renderLoading(() => {
- var _a, _b;
- this.attempt++;
- (_b = (_a = this.options.adapter).beforeLoad) == null ? void 0 : _b.call(_a, this, this.options);
- this.record("loadStart");
- loadImageAsync(
- {
- src: this.src,
- cors: this.cors
- },
- (data) => {
- this.naturalHeight = data.naturalHeight;
- this.naturalWidth = data.naturalWidth;
- this.state.loaded = true;
- this.state.error = false;
- this.record("loadEnd");
- this.render("loaded", false);
- this.state.rendered = true;
- this.imageCache.add(this.src);
- onFinish();
- },
- (err) => {
- !this.options.silent && console.error(err);
- this.state.error = true;
- this.state.loaded = false;
- this.render("error", false);
- }
- );
- });
- }
- render(state, cache) {
- this.elRenderer(this, state, cache);
- }
- performance() {
- let state = "loading";
- let time = 0;
- if (this.state.loaded) {
- state = "loaded";
- time = (this.performanceData.loadEnd - this.performanceData.loadStart) / 1e3;
- }
- if (this.state.error)
- state = "error";
- return {
- src: this.src,
- state,
- time
- };
- }
- $destroy() {
- this.el = null;
- this.src = null;
- this.error = null;
- this.loading = null;
- this.bindType = null;
- this.attempt = 0;
- }
- }
- const DEFAULT_URL = "data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7";
- const DEFAULT_EVENTS = [
- "scroll",
- "wheel",
- "mousewheel",
- "resize",
- "animationend",
- "transitionend",
- "touchmove"
- ];
- const DEFAULT_OBSERVER_OPTIONS = {
- rootMargin: "0px",
- threshold: 0
- };
- function stdin_default$3() {
- return class Lazy {
- constructor({
- preLoad,
- error,
- throttleWait,
- preLoadTop,
- dispatchEvent,
- loading,
- attempt,
- silent = true,
- scale,
- listenEvents,
- filter,
- adapter,
- observer,
- observerOptions
- }) {
- this.mode = modeType.event;
- this.listeners = [];
- this.targetIndex = 0;
- this.targets = [];
- this.options = {
- silent,
- dispatchEvent: !!dispatchEvent,
- throttleWait: throttleWait || 200,
- preLoad: preLoad || 1.3,
- preLoadTop: preLoadTop || 0,
- error: error || DEFAULT_URL,
- loading: loading || DEFAULT_URL,
- attempt: attempt || 3,
- scale: scale || getDPR(scale),
- ListenEvents: listenEvents || DEFAULT_EVENTS,
- supportWebp: supportWebp(),
- filter: filter || {},
- adapter: adapter || {},
- observer: !!observer,
- observerOptions: observerOptions || DEFAULT_OBSERVER_OPTIONS
- };
- this.initEvent();
- this.imageCache = new ImageCache({ max: 200 });
- this.lazyLoadHandler = throttle(
- this.lazyLoadHandler.bind(this),
- this.options.throttleWait
- );
- this.setMode(this.options.observer ? modeType.observer : modeType.event);
- }
- config(options = {}) {
- Object.assign(this.options, options);
- }
- performance() {
- return this.listeners.map((item) => item.performance());
- }
- addLazyBox(vm) {
- this.listeners.push(vm);
- if (inBrowser$1) {
- this.addListenerTarget(window);
- this.observer && this.observer.observe(vm.el);
- if (vm.$el && vm.$el.parentNode) {
- this.addListenerTarget(vm.$el.parentNode);
- }
- }
- }
- add(el, binding, vnode) {
- if (this.listeners.some((item) => item.el === el)) {
- this.update(el, binding);
- return nextTick(this.lazyLoadHandler);
- }
- const value = this.valueFormatter(binding.value);
- let { src } = value;
- nextTick(() => {
- src = getBestSelectionFromSrcset(el, this.options.scale) || src;
- this.observer && this.observer.observe(el);
- const container = Object.keys(binding.modifiers)[0];
- let $parent;
- if (container) {
- $parent = vnode.context.$refs[container];
- $parent = $parent ? $parent.$el || $parent : document.getElementById(container);
- }
- if (!$parent) {
- $parent = getScrollParent(el);
- }
- const newListener = new ReactiveListener({
- bindType: binding.arg,
- $parent,
- el,
- src,
- loading: value.loading,
- error: value.error,
- cors: value.cors,
- elRenderer: this.elRenderer.bind(this),
- options: this.options,
- imageCache: this.imageCache
- });
- this.listeners.push(newListener);
- if (inBrowser$1) {
- this.addListenerTarget(window);
- this.addListenerTarget($parent);
- }
- this.lazyLoadHandler();
- nextTick(() => this.lazyLoadHandler());
- });
- }
- update(el, binding, vnode) {
- const value = this.valueFormatter(binding.value);
- let { src } = value;
- src = getBestSelectionFromSrcset(el, this.options.scale) || src;
- const exist = this.listeners.find((item) => item.el === el);
- if (!exist) {
- this.add(el, binding, vnode);
- } else {
- exist.update({
- src,
- error: value.error,
- loading: value.loading
- });
- }
- if (this.observer) {
- this.observer.unobserve(el);
- this.observer.observe(el);
- }
- this.lazyLoadHandler();
- nextTick(() => this.lazyLoadHandler());
- }
- remove(el) {
- if (!el)
- return;
- this.observer && this.observer.unobserve(el);
- const existItem = this.listeners.find((item) => item.el === el);
- if (existItem) {
- this.removeListenerTarget(existItem.$parent);
- this.removeListenerTarget(window);
- remove(this.listeners, existItem);
- existItem.$destroy();
- }
- }
- removeComponent(vm) {
- if (!vm)
- return;
- remove(this.listeners, vm);
- this.observer && this.observer.unobserve(vm.el);
- if (vm.$parent && vm.$el.parentNode) {
- this.removeListenerTarget(vm.$el.parentNode);
- }
- this.removeListenerTarget(window);
- }
- setMode(mode) {
- if (!hasIntersectionObserver && mode === modeType.observer) {
- mode = modeType.event;
- }
- this.mode = mode;
- if (mode === modeType.event) {
- if (this.observer) {
- this.listeners.forEach((listener) => {
- this.observer.unobserve(listener.el);
- });
- this.observer = null;
- }
- this.targets.forEach((target) => {
- this.initListen(target.el, true);
- });
- } else {
- this.targets.forEach((target) => {
- this.initListen(target.el, false);
- });
- this.initIntersectionObserver();
- }
- }
- addListenerTarget(el) {
- if (!el)
- return;
- let target = this.targets.find((target2) => target2.el === el);
- if (!target) {
- target = {
- el,
- id: ++this.targetIndex,
- childrenCount: 1,
- listened: true
- };
- this.mode === modeType.event && this.initListen(target.el, true);
- this.targets.push(target);
- } else {
- target.childrenCount++;
- }
- return this.targetIndex;
- }
- removeListenerTarget(el) {
- this.targets.forEach((target, index) => {
- if (target.el === el) {
- target.childrenCount--;
- if (!target.childrenCount) {
- this.initListen(target.el, false);
- this.targets.splice(index, 1);
- target = null;
- }
- }
- });
- }
- initListen(el, start) {
- this.options.ListenEvents.forEach(
- (evt) => (start ? on : off)(el, evt, this.lazyLoadHandler)
- );
- }
- initEvent() {
- this.Event = {
- listeners: {
- loading: [],
- loaded: [],
- error: []
- }
- };
- this.$on = (event, func) => {
- if (!this.Event.listeners[event])
- this.Event.listeners[event] = [];
- this.Event.listeners[event].push(func);
- };
- this.$once = (event, func) => {
- const on2 = (...args) => {
- this.$off(event, on2);
- func.apply(this, args);
- };
- this.$on(event, on2);
- };
- this.$off = (event, func) => {
- if (!func) {
- if (!this.Event.listeners[event])
- return;
- this.Event.listeners[event].length = 0;
- return;
- }
- remove(this.Event.listeners[event], func);
- };
- this.$emit = (event, context, inCache) => {
- if (!this.Event.listeners[event])
- return;
- this.Event.listeners[event].forEach((func) => func(context, inCache));
- };
- }
- lazyLoadHandler() {
- const freeList = [];
- this.listeners.forEach((listener) => {
- if (!listener.el || !listener.el.parentNode) {
- freeList.push(listener);
- }
- const catIn = listener.checkInView();
- if (!catIn)
- return;
- listener.load();
- });
- freeList.forEach((item) => {
- remove(this.listeners, item);
- item.$destroy();
- });
- }
- initIntersectionObserver() {
- if (!hasIntersectionObserver) {
- return;
- }
- this.observer = new IntersectionObserver(
- this.observerHandler.bind(this),
- this.options.observerOptions
- );
- if (this.listeners.length) {
- this.listeners.forEach((listener) => {
- this.observer.observe(listener.el);
- });
- }
- }
- observerHandler(entries) {
- entries.forEach((entry) => {
- if (entry.isIntersecting) {
- this.listeners.forEach((listener) => {
- if (listener.el === entry.target) {
- if (listener.state.loaded)
- return this.observer.unobserve(listener.el);
- listener.load();
- }
- });
- }
- });
- }
- elRenderer(listener, state, cache) {
- if (!listener.el)
- return;
- const { el, bindType } = listener;
- let src;
- switch (state) {
- case "loading":
- src = listener.loading;
- break;
- case "error":
- src = listener.error;
- break;
- default:
- ({ src } = listener);
- break;
- }
- if (bindType) {
- el.style[bindType] = 'url("' + src + '")';
- } else if (el.getAttribute("src") !== src) {
- el.setAttribute("src", src);
- }
- el.setAttribute("lazy", state);
- this.$emit(state, listener, cache);
- this.options.adapter[state] && this.options.adapter[state](listener, this.options);
- if (this.options.dispatchEvent) {
- const event = new CustomEvent(state, {
- detail: listener
- });
- el.dispatchEvent(event);
- }
- }
- valueFormatter(value) {
- let src = value;
- let { loading, error } = this.options;
- if (isObject(value)) {
- if (process.env.NODE_ENV !== "production" && !value.src && !this.options.silent) {
- console.error("[@vant/lazyload] miss src with " + value);
- }
- ({ src } = value);
- loading = value.loading || this.options.loading;
- error = value.error || this.options.error;
- }
- return {
- src,
- loading,
- error
- };
- }
- };
- }
- var stdin_default$2 = (lazy) => ({
- props: {
- tag: {
- type: String,
- default: "div"
- }
- },
- emits: ["show"],
- render() {
- return h(
- this.tag,
- this.show && this.$slots.default ? this.$slots.default() : null
- );
- },
- data() {
- return {
- el: null,
- state: {
- loaded: false
- },
- show: false
- };
- },
- mounted() {
- this.el = this.$el;
- lazy.addLazyBox(this);
- lazy.lazyLoadHandler();
- },
- beforeUnmount() {
- lazy.removeComponent(this);
- },
- methods: {
- checkInView() {
- const rect = useRect(this.$el);
- return inBrowser$1 && rect.top < window.innerHeight * lazy.options.preLoad && rect.bottom > 0 && rect.left < window.innerWidth * lazy.options.preLoad && rect.right > 0;
- },
- load() {
- this.show = true;
- this.state.loaded = true;
- this.$emit("show", this);
- },
- destroy() {
- return this.$destroy;
- }
- }
- });
- const defaultOptions = {
- selector: "img"
- };
- class LazyContainer {
- constructor({ el, binding, vnode, lazy }) {
- this.el = null;
- this.vnode = vnode;
- this.binding = binding;
- this.options = {};
- this.lazy = lazy;
- this.queue = [];
- this.update({ el, binding });
- }
- update({ el, binding }) {
- this.el = el;
- this.options = Object.assign({}, defaultOptions, binding.value);
- const imgs = this.getImgs();
- imgs.forEach((el2) => {
- this.lazy.add(
- el2,
- Object.assign({}, this.binding, {
- value: {
- src: "dataset" in el2 ? el2.dataset.src : el2.getAttribute("data-src"),
- error: ("dataset" in el2 ? el2.dataset.error : el2.getAttribute("data-error")) || this.options.error,
- loading: ("dataset" in el2 ? el2.dataset.loading : el2.getAttribute("data-loading")) || this.options.loading
- }
- }),
- this.vnode
- );
- });
- }
- getImgs() {
- return Array.from(this.el.querySelectorAll(this.options.selector));
- }
- clear() {
- const imgs = this.getImgs();
- imgs.forEach((el) => this.lazy.remove(el));
- this.vnode = null;
- this.binding = null;
- this.lazy = null;
- }
- }
- class LazyContainerManager {
- constructor({ lazy }) {
- this.lazy = lazy;
- this.queue = [];
- }
- bind(el, binding, vnode) {
- const container = new LazyContainer({
- el,
- binding,
- vnode,
- lazy: this.lazy
- });
- this.queue.push(container);
- }
- update(el, binding, vnode) {
- const container = this.queue.find((item) => item.el === el);
- if (!container)
- return;
- container.update({ el, binding, vnode });
- }
- unbind(el) {
- const container = this.queue.find((item) => item.el === el);
- if (!container)
- return;
- container.clear();
- remove(this.queue, container);
- }
- }
- var stdin_default$1 = (lazyManager) => ({
- props: {
- src: [String, Object],
- tag: {
- type: String,
- default: "img"
- }
- },
- render() {
- var _a, _b;
- return h(
- this.tag,
- {
- src: this.renderSrc
- },
- (_b = (_a = this.$slots).default) == null ? void 0 : _b.call(_a)
- );
- },
- data() {
- return {
- el: null,
- options: {
- src: "",
- error: "",
- loading: "",
- attempt: lazyManager.options.attempt
- },
- state: {
- loaded: false,
- error: false,
- attempt: 0
- },
- renderSrc: ""
- };
- },
- watch: {
- src() {
- this.init();
- lazyManager.addLazyBox(this);
- lazyManager.lazyLoadHandler();
- }
- },
- created() {
- this.init();
- this.renderSrc = this.options.loading;
- },
- mounted() {
- this.el = this.$el;
- lazyManager.addLazyBox(this);
- lazyManager.lazyLoadHandler();
- },
- beforeUnmount() {
- lazyManager.removeComponent(this);
- },
- methods: {
- init() {
- const { src, loading, error } = lazyManager.valueFormatter(this.src);
- this.state.loaded = false;
- this.options.src = src;
- this.options.error = error;
- this.options.loading = loading;
- this.renderSrc = this.options.loading;
- },
- checkInView() {
- const rect = useRect(this.$el);
- return rect.top < window.innerHeight * lazyManager.options.preLoad && rect.bottom > 0 && rect.left < window.innerWidth * lazyManager.options.preLoad && rect.right > 0;
- },
- load(onFinish = noop) {
- if (this.state.attempt > this.options.attempt - 1 && this.state.error) {
- if (process.env.NODE_ENV !== "production" && !lazyManager.options.silent) {
- console.log(
- `[@vant/lazyload] ${this.options.src} tried too more than ${this.options.attempt} times`
- );
- }
- onFinish();
- return;
- }
- const { src } = this.options;
- loadImageAsync(
- { src },
- ({ src: src2 }) => {
- this.renderSrc = src2;
- this.state.loaded = true;
- },
- () => {
- this.state.attempt++;
- this.renderSrc = this.options.error;
- this.state.error = true;
- }
- );
- }
- }
- });
- const Lazyload = {
- install(app, options = {}) {
- const LazyClass = stdin_default$3();
- const lazy = new LazyClass(options);
- const lazyContainer = new LazyContainerManager({ lazy });
- app.config.globalProperties.$Lazyload = lazy;
- if (options.lazyComponent) {
- app.component("LazyComponent", stdin_default$2(lazy));
- }
- if (options.lazyImage) {
- app.component("LazyImage", stdin_default$1(lazy));
- }
- app.directive("lazy", {
- beforeMount: lazy.add.bind(lazy),
- updated: lazy.update.bind(lazy),
- unmounted: lazy.remove.bind(lazy)
- });
- app.directive("lazy-container", {
- beforeMount: lazyContainer.bind.bind(lazyContainer),
- updated: lazyContainer.update.bind(lazyContainer),
- unmounted: lazyContainer.unbind.bind(lazyContainer)
- });
- }
- };
- const version = "3.6.10";
- function install(app) {
- const components = [
- ActionBar,
- ActionBarButton,
- ActionBarIcon,
- ActionSheet,
- AddressEdit,
- AddressList,
- Area,
- Badge,
- Button,
- Calendar,
- Card,
- Cascader,
- Cell,
- CellGroup,
- Checkbox,
- CheckboxGroup,
- Circle,
- Col,
- Collapse,
- CollapseItem,
- ConfigProvider,
- ContactCard,
- ContactEdit,
- ContactList,
- CountDown,
- Coupon,
- CouponCell,
- CouponList,
- DatetimePicker,
- Dialog,
- Divider,
- DropdownItem,
- DropdownMenu,
- Empty,
- Field,
- Form,
- Grid,
- GridItem,
- Icon,
- Image$1,
- ImagePreview,
- IndexAnchor,
- IndexBar,
- List,
- Loading,
- Locale,
- NavBar,
- NoticeBar,
- Notify,
- NumberKeyboard,
- Overlay,
- Pagination,
- PasswordInput,
- Picker,
- Popover,
- Popup,
- Progress,
- PullRefresh,
- Radio,
- RadioGroup,
- Rate,
- Row,
- Search,
- ShareSheet,
- Sidebar,
- SidebarItem,
- Skeleton,
- Slider,
- Space,
- Step,
- Stepper,
- Steps,
- Sticky,
- SubmitBar,
- Swipe,
- SwipeCell,
- SwipeItem,
- Switch,
- Tab,
- Tabbar,
- TabbarItem,
- Tabs,
- Tag,
- Toast,
- TreeSelect,
- Uploader
- ];
- components.forEach((item) => {
- if (item.install) {
- app.use(item);
- } else if (item.name) {
- app.component(item.name, item);
- }
- });
- }
- var stdin_default = {
- install,
- version
- };
- export {
- ActionBar,
- ActionBarButton,
- ActionBarIcon,
- ActionSheet,
- AddressEdit,
- AddressList,
- Area,
- Badge,
- Button,
- Calendar,
- Card,
- Cascader,
- Cell,
- CellGroup,
- Checkbox,
- CheckboxGroup,
- Circle,
- Col,
- Collapse,
- CollapseItem,
- ConfigProvider,
- ContactCard,
- ContactEdit,
- ContactList,
- CountDown,
- Coupon,
- CouponCell,
- CouponList,
- DatetimePicker,
- Dialog,
- Divider,
- DropdownItem,
- DropdownMenu,
- Empty,
- Field,
- Form,
- Grid,
- GridItem,
- Icon,
- Image$1 as Image,
- ImagePreview,
- IndexAnchor,
- IndexBar,
- Lazyload,
- List,
- Loading,
- Locale,
- NavBar,
- NoticeBar,
- Notify,
- NumberKeyboard,
- Overlay,
- Pagination,
- PasswordInput,
- Picker,
- Popover,
- Popup,
- Progress,
- PullRefresh,
- Radio,
- RadioGroup,
- Rate,
- Row,
- Search,
- ShareSheet,
- Sidebar,
- SidebarItem,
- Skeleton,
- Slider,
- Space,
- Step,
- Stepper,
- Steps,
- Sticky,
- SubmitBar,
- Swipe,
- SwipeCell,
- SwipeItem,
- Switch,
- Tab,
- Tabbar,
- TabbarItem,
- Tabs,
- Tag,
- Toast,
- TreeSelect,
- Uploader,
- stdin_default as default,
- install,
- version
- };
|