index.d.ts 188 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706
  1. import * as _$_vueuse_shared0 from "@vueuse/shared";
  2. import { Arrayable, Awaitable, ConfigurableEventFilter, ConfigurableFlush, ConfigurableFlushSync, EventHookOn, Fn, IsAny, Pausable, ReadonlyRefOrGetter, RemovableRef, ShallowOrDeepRef, Stoppable, UseTimeoutFnOptions } from "@vueuse/shared";
  3. import * as _$vue from "vue";
  4. import { App, Component, ComponentObjectPropsOptions, ComponentPublicInstance, ComputedRef, DeepReadonly, DefineComponent, InjectionKey, MaybeRef, MaybeRefOrGetter, MultiWatchSources, Ref, ShallowRef, Slot, StyleValue, ToRefs, TransitionGroupProps, UnwrapNestedRefs, UnwrapRef, WatchOptions, WatchOptionsBase, WatchSource, WatchStopHandle, WritableComputedRef } from "vue";
  5. export * from "@vueuse/shared";
  6. //#region computedAsync/index.d.ts
  7. /**
  8. * Handle overlapping async evaluations.
  9. *
  10. * @param cancelCallback The provided callback is invoked when a re-evaluation of the computed value is triggered before the previous one finished
  11. */
  12. type AsyncComputedOnCancel = (cancelCallback: Fn) => void;
  13. interface AsyncComputedOptions<Lazy = boolean> extends ConfigurableFlushSync {
  14. /**
  15. * Should value be evaluated lazily
  16. *
  17. * @default false
  18. */
  19. lazy?: Lazy;
  20. /**
  21. * Ref passed to receive the updated of async evaluation
  22. */
  23. evaluating?: Ref<boolean>;
  24. /**
  25. * Use shallowRef
  26. *
  27. * @default true
  28. */
  29. shallow?: boolean;
  30. /**
  31. * Callback when error is caught.
  32. */
  33. onError?: (e: unknown) => void;
  34. }
  35. /**
  36. * Create an asynchronous computed dependency.
  37. *
  38. * @see https://vueuse.org/computedAsync
  39. * @param evaluationCallback The promise-returning callback which generates the computed value
  40. * @param initialState The initial state, used until the first evaluation finishes
  41. * @param optionsOrRef Additional options or a ref passed to receive the updates of the async evaluation
  42. */
  43. declare function computedAsync<T>(evaluationCallback: (onCancel: AsyncComputedOnCancel) => T | Promise<T>, initialState: T, optionsOrRef: AsyncComputedOptions<true>): ComputedRef<T>;
  44. declare function computedAsync<T>(evaluationCallback: (onCancel: AsyncComputedOnCancel) => T | Promise<T>, initialState: undefined, optionsOrRef: AsyncComputedOptions<true>): ComputedRef<T | undefined>;
  45. declare function computedAsync<T>(evaluationCallback: (onCancel: AsyncComputedOnCancel) => T | Promise<T>, initialState: T, optionsOrRef?: Ref<boolean> | AsyncComputedOptions): Ref<T>;
  46. declare function computedAsync<T>(evaluationCallback: (onCancel: AsyncComputedOnCancel) => T | Promise<T>, initialState?: undefined, optionsOrRef?: Ref<boolean> | AsyncComputedOptions): Ref<T | undefined>;
  47. /** @deprecated use `computedAsync` instead */
  48. declare const asyncComputed: typeof computedAsync;
  49. //#endregion
  50. //#region computedInject/index.d.ts
  51. type ComputedInjectGetter<T, K> = (source: T | undefined, oldValue?: K) => K;
  52. type ComputedInjectGetterWithDefault<T, K> = (source: T, oldValue?: K) => K;
  53. type ComputedInjectSetter<T> = (v: T) => void;
  54. interface WritableComputedInjectOptions<T, K> {
  55. get: ComputedInjectGetter<T, K>;
  56. set: ComputedInjectSetter<K>;
  57. }
  58. interface WritableComputedInjectOptionsWithDefault<T, K> {
  59. get: ComputedInjectGetterWithDefault<T, K>;
  60. set: ComputedInjectSetter<K>;
  61. }
  62. declare function computedInject<T, K = any>(key: InjectionKey<T> | string, getter: ComputedInjectGetter<T, K>): ComputedRef<K | undefined>;
  63. declare function computedInject<T, K = any>(key: InjectionKey<T> | string, options: WritableComputedInjectOptions<T, K>): ComputedRef<K | undefined>;
  64. declare function computedInject<T, K = any>(key: InjectionKey<T> | string, getter: ComputedInjectGetterWithDefault<T, K>, defaultSource: T, treatDefaultAsFactory?: false): ComputedRef<K>;
  65. declare function computedInject<T, K = any>(key: InjectionKey<T> | string, options: WritableComputedInjectOptionsWithDefault<T, K>, defaultSource: T | (() => T), treatDefaultAsFactory: true): ComputedRef<K>;
  66. //#endregion
  67. //#region createReusableTemplate/index.d.ts
  68. type ObjectLiteralWithPotentialObjectLiterals = Record<string, Record<string, any> | undefined>;
  69. type GenerateSlotsFromSlotMap<T extends ObjectLiteralWithPotentialObjectLiterals> = { [K in keyof T]: Slot<T[K]> };
  70. type DefineTemplateComponent<Bindings extends Record<string, any>, MapSlotNameToSlotProps extends ObjectLiteralWithPotentialObjectLiterals> = DefineComponent & {
  71. new (): {
  72. $slots: {
  73. default: (_: Bindings & {
  74. $slots: GenerateSlotsFromSlotMap<MapSlotNameToSlotProps>;
  75. }) => any;
  76. };
  77. };
  78. };
  79. type ReuseTemplateComponent<Bindings extends Record<string, any>, MapSlotNameToSlotProps extends ObjectLiteralWithPotentialObjectLiterals> = DefineComponent<Bindings> & {
  80. new (): {
  81. $slots: GenerateSlotsFromSlotMap<MapSlotNameToSlotProps>;
  82. };
  83. };
  84. type ReusableTemplatePair<Bindings extends Record<string, any>, MapSlotNameToSlotProps extends ObjectLiteralWithPotentialObjectLiterals> = [DefineTemplateComponent<Bindings, MapSlotNameToSlotProps>, ReuseTemplateComponent<Bindings, MapSlotNameToSlotProps>] & {
  85. define: DefineTemplateComponent<Bindings, MapSlotNameToSlotProps>;
  86. reuse: ReuseTemplateComponent<Bindings, MapSlotNameToSlotProps>;
  87. };
  88. interface CreateReusableTemplateOptions<Props extends Record<string, any>> {
  89. /**
  90. * Inherit attrs from reuse component.
  91. *
  92. * @default true
  93. */
  94. inheritAttrs?: boolean;
  95. /**
  96. * Name for the reuse component (useful for devtools).
  97. */
  98. name?: string;
  99. /**
  100. * Props definition for reuse component.
  101. */
  102. props?: ComponentObjectPropsOptions<Props>;
  103. }
  104. /**
  105. * This function creates `define` and `reuse` components in pair,
  106. * It also allow to pass a generic to bind with type.
  107. *
  108. * @see https://vueuse.org/createReusableTemplate
  109. *
  110. * @__NO_SIDE_EFFECTS__
  111. */
  112. declare function createReusableTemplate<Bindings extends Record<string, any>, MapSlotNameToSlotProps extends ObjectLiteralWithPotentialObjectLiterals = Record<'default', undefined>>(options?: CreateReusableTemplateOptions<Bindings>): ReusableTemplatePair<Bindings, MapSlotNameToSlotProps>;
  113. //#endregion
  114. //#region createTemplatePromise/index.d.ts
  115. interface TemplatePromiseProps<Return, Args extends any[] = []> {
  116. /**
  117. * The promise instance.
  118. */
  119. promise: Promise<Return> | undefined;
  120. /**
  121. * Resolve the promise.
  122. */
  123. resolve: (v: Return | Promise<Return>) => void;
  124. /**
  125. * Reject the promise.
  126. */
  127. reject: (v: any) => void;
  128. /**
  129. * Arguments passed to TemplatePromise.start()
  130. */
  131. args: Args;
  132. /**
  133. * Indicates if the promise is resolving.
  134. * When passing another promise to `resolve`, this will be set to `true` until the promise is resolved.
  135. */
  136. isResolving: boolean;
  137. /**
  138. * Options passed to createTemplatePromise()
  139. */
  140. options: TemplatePromiseOptions;
  141. /**
  142. * Unique key for list rendering.
  143. */
  144. key: number;
  145. }
  146. interface TemplatePromiseOptions {
  147. /**
  148. * Determines if the promise can be called only once at a time.
  149. *
  150. * @default false
  151. */
  152. singleton?: boolean;
  153. /**
  154. * Transition props for the promise.
  155. */
  156. transition?: TransitionGroupProps;
  157. }
  158. type TemplatePromise<Return, Args extends any[] = []> = DefineComponent<object> & {
  159. new (): {
  160. $slots: {
  161. default: (_: TemplatePromiseProps<Return, Args>) => any;
  162. };
  163. };
  164. } & {
  165. start: (...args: Args) => Promise<Return>;
  166. };
  167. /**
  168. * Creates a template promise component.
  169. *
  170. * @see https://vueuse.org/createTemplatePromise
  171. *
  172. * @__NO_SIDE_EFFECTS__
  173. */
  174. declare function createTemplatePromise<Return, Args extends any[] = []>(options?: TemplatePromiseOptions): TemplatePromise<Return, Args>;
  175. //#endregion
  176. //#region createUnrefFn/index.d.ts
  177. type UnrefFn<T> = T extends ((...args: infer A) => infer R) ? (...args: { [K in keyof A]: MaybeRef<A[K]> }) => R : never;
  178. /**
  179. * Make a plain function accepting ref and raw values as arguments.
  180. * Returns the same value the unconverted function returns, with proper typing.
  181. *
  182. * @__NO_SIDE_EFFECTS__
  183. */
  184. declare function createUnrefFn<T extends Function>(fn: T): UnrefFn<T>;
  185. //#endregion
  186. //#region _configurable.d.ts
  187. interface ConfigurableWindow {
  188. window?: Window;
  189. }
  190. interface ConfigurableDocument {
  191. document?: Document;
  192. }
  193. interface ConfigurableDocumentOrShadowRoot {
  194. document?: DocumentOrShadowRoot;
  195. }
  196. interface ConfigurableNavigator {
  197. navigator?: Navigator;
  198. }
  199. interface ConfigurableLocation {
  200. location?: Location;
  201. }
  202. declare const defaultWindow: (Window & typeof globalThis) | undefined;
  203. declare const defaultDocument: Document | undefined;
  204. declare const defaultNavigator: Navigator | undefined;
  205. declare const defaultLocation: Location | undefined;
  206. interface ConfigurableDeepRefs<D extends boolean> {
  207. /**
  208. * Return deep refs instead of shallow refs.
  209. *
  210. * @default true - will be changed to `false` by default in the next major
  211. */
  212. deepRefs?: D;
  213. }
  214. interface ConfigurableScheduler {
  215. /**
  216. * Custom scheduler to use for interval execution.
  217. */
  218. scheduler?: (cb: Fn) => Pausable;
  219. }
  220. //#endregion
  221. //#region unrefElement/index.d.ts
  222. type VueInstance = ComponentPublicInstance;
  223. type MaybeElementRef<T extends MaybeElement = MaybeElement> = MaybeRef<T>;
  224. type MaybeComputedElementRef<T extends MaybeElement = MaybeElement> = MaybeRefOrGetter<T>;
  225. type MaybeElement = HTMLElement | SVGElement | VueInstance | undefined | null;
  226. type UnRefElementReturn<T extends MaybeElement = MaybeElement> = T extends VueInstance ? Exclude<MaybeElement, VueInstance> : T | undefined;
  227. /**
  228. * Get the dom element of a ref of element or Vue component instance
  229. *
  230. * @param elRef
  231. */
  232. declare function unrefElement<T extends MaybeElement>(elRef: MaybeComputedElementRef<T>): UnRefElementReturn<T>;
  233. //#endregion
  234. //#region onClickOutside/index.d.ts
  235. interface OnClickOutsideOptions<Controls extends boolean = false> extends ConfigurableWindow {
  236. /**
  237. * List of elements that should not trigger the event,
  238. * provided as Refs or CSS Selectors.
  239. */
  240. ignore?: MaybeRefOrGetter<(MaybeElementRef | string)[]>;
  241. /**
  242. * Use capturing phase for internal event listener.
  243. * @default true
  244. */
  245. capture?: boolean;
  246. /**
  247. * Run handler function if focus moves to an iframe.
  248. * @default false
  249. */
  250. detectIframe?: boolean;
  251. /**
  252. * Use controls to cancel/trigger listener.
  253. * @default false
  254. */
  255. controls?: Controls;
  256. }
  257. type OnClickOutsideHandler<T extends OnClickOutsideOptions<boolean> = OnClickOutsideOptions> = (event: (T['detectIframe'] extends true ? FocusEvent : never) | (T['controls'] extends true ? Event : never) | PointerEvent) => void;
  258. type OnClickOutsideReturn<Controls extends boolean = false> = Controls extends false ? Fn : {
  259. stop: Fn;
  260. cancel: Fn;
  261. trigger: (event: Event) => void;
  262. };
  263. /**
  264. * Listen for clicks outside of an element.
  265. *
  266. * @see https://vueuse.org/onClickOutside
  267. * @param target
  268. * @param handler
  269. * @param options
  270. */
  271. declare function onClickOutside<T extends OnClickOutsideOptions>(target: MaybeComputedElementRef, handler: OnClickOutsideHandler<T>, options?: T): Fn;
  272. declare function onClickOutside<T extends OnClickOutsideOptions<true>>(target: MaybeComputedElementRef, handler: OnClickOutsideHandler<T>, options: T): {
  273. stop: Fn;
  274. cancel: Fn;
  275. trigger: (event: Event) => void;
  276. };
  277. //#endregion
  278. //#region onElementRemoval/index.d.ts
  279. interface OnElementRemovalOptions extends ConfigurableWindow, ConfigurableDocumentOrShadowRoot, WatchOptionsBase {}
  280. /**
  281. * Fires when the element or any element containing it is removed.
  282. *
  283. * @param target
  284. * @param callback
  285. * @param options
  286. */
  287. declare function onElementRemoval(target: MaybeElementRef, callback: (mutationRecords: MutationRecord[]) => void, options?: OnElementRemovalOptions): Fn;
  288. //#endregion
  289. //#region onKeyStroke/index.d.ts
  290. type KeyPredicate = (event: KeyboardEvent) => boolean;
  291. type KeyFilter = true | string | string[] | KeyPredicate;
  292. type KeyStrokeEventName = 'keydown' | 'keypress' | 'keyup';
  293. interface OnKeyStrokeOptions {
  294. eventName?: KeyStrokeEventName;
  295. target?: MaybeRefOrGetter<EventTarget | null | undefined>;
  296. passive?: boolean;
  297. /**
  298. * Set to `true` to ignore repeated events when the key is being held down.
  299. *
  300. * @default false
  301. */
  302. dedupe?: MaybeRefOrGetter<boolean>;
  303. }
  304. /**
  305. * Listen for keyboard keystrokes.
  306. *
  307. * @see https://vueuse.org/onKeyStroke
  308. */
  309. declare function onKeyStroke(key: KeyFilter, handler: (event: KeyboardEvent) => void, options?: OnKeyStrokeOptions): () => void;
  310. declare function onKeyStroke(handler: (event: KeyboardEvent) => void, options?: OnKeyStrokeOptions): () => void;
  311. /**
  312. * Listen to the keydown event of the given key.
  313. *
  314. * @see https://vueuse.org/onKeyStroke
  315. * @param key
  316. * @param handler
  317. * @param options
  318. */
  319. declare function onKeyDown(key: KeyFilter, handler: (event: KeyboardEvent) => void, options?: Omit<OnKeyStrokeOptions, 'eventName'>): () => void;
  320. /**
  321. * Listen to the keypress event of the given key.
  322. *
  323. * @see https://vueuse.org/onKeyStroke
  324. * @param key
  325. * @param handler
  326. * @param options
  327. */
  328. declare function onKeyPressed(key: KeyFilter, handler: (event: KeyboardEvent) => void, options?: Omit<OnKeyStrokeOptions, 'eventName'>): () => void;
  329. /**
  330. * Listen to the keyup event of the given key.
  331. *
  332. * @see https://vueuse.org/onKeyStroke
  333. * @param key
  334. * @param handler
  335. * @param options
  336. */
  337. declare function onKeyUp(key: KeyFilter, handler: (event: KeyboardEvent) => void, options?: Omit<OnKeyStrokeOptions, 'eventName'>): () => void;
  338. //#endregion
  339. //#region onLongPress/index.d.ts
  340. interface OnLongPressOptions {
  341. /**
  342. * Time in ms till `longpress` gets called
  343. *
  344. * @default 500
  345. */
  346. delay?: number | ((ev: PointerEvent) => number);
  347. modifiers?: OnLongPressModifiers;
  348. /**
  349. * Allowance of moving distance in pixels,
  350. * The action will get canceled When moving too far from the pointerdown position.
  351. * @default 10
  352. */
  353. distanceThreshold?: number | false;
  354. /**
  355. * Function called when the ref element is released.
  356. * @param duration how long the element was pressed in ms
  357. * @param distance distance from the pointerdown position
  358. * @param isLongPress whether the action was a long press or not
  359. * @param pointerEvent the native {@link PointerEvent} triggered by the browser
  360. */
  361. onMouseUp?: (duration: number, distance: number, isLongPress: boolean, pointerEvent: PointerEvent) => void;
  362. }
  363. interface OnLongPressModifiers {
  364. stop?: boolean;
  365. once?: boolean;
  366. prevent?: boolean;
  367. capture?: boolean;
  368. self?: boolean;
  369. }
  370. type OnLongPressReturn = () => void;
  371. /** @deprecated use {@link OnLongPressReturn} instead */
  372. type UseOnLongPressReturn = OnLongPressReturn;
  373. declare function onLongPress(target: MaybeElementRef, handler: (evt: PointerEvent) => void, options?: OnLongPressOptions): OnLongPressReturn;
  374. //#endregion
  375. //#region onStartTyping/index.d.ts
  376. /**
  377. * Fires when users start typing on non-editable elements.
  378. *
  379. * @see https://vueuse.org/onStartTyping
  380. * @param callback
  381. * @param options
  382. */
  383. declare function onStartTyping(callback: (event: KeyboardEvent) => void, options?: ConfigurableDocument): void;
  384. //#endregion
  385. //#region templateRef/index.d.ts
  386. /**
  387. * @deprecated Use Vue's built-in `useTemplateRef` instead.
  388. *
  389. * Shorthand for binding ref to template element.
  390. *
  391. * @see https://vueuse.org/templateRef
  392. * @param key
  393. * @param initialValue
  394. *
  395. * @__NO_SIDE_EFFECTS__
  396. */
  397. declare function templateRef<T extends HTMLElement | SVGElement | Component | null, Keys extends string = string>(key: Keys, initialValue?: T | null): Readonly<Ref<T>>;
  398. //#endregion
  399. //#region useActiveElement/index.d.ts
  400. interface UseActiveElementOptions extends ConfigurableWindow, ConfigurableDocumentOrShadowRoot {
  401. /**
  402. * Search active element deeply inside shadow dom
  403. *
  404. * @default true
  405. */
  406. deep?: boolean;
  407. /**
  408. * Track active element when it's removed from the DOM
  409. * Using a MutationObserver under the hood
  410. * @default false
  411. */
  412. triggerOnRemoval?: boolean;
  413. }
  414. type UseActiveElementReturn<T extends HTMLElement = HTMLElement> = ShallowRef<T | null | undefined>;
  415. /**
  416. * Reactive `document.activeElement`
  417. *
  418. * @see https://vueuse.org/useActiveElement
  419. * @param options
  420. *
  421. * @__NO_SIDE_EFFECTS__
  422. */
  423. declare function useActiveElement<T extends HTMLElement>(options?: UseActiveElementOptions): UseActiveElementReturn<T>;
  424. //#endregion
  425. //#region types.d.ts
  426. interface Position {
  427. x: number;
  428. y: number;
  429. }
  430. interface RenderableComponent {
  431. /**
  432. * The element that the component should be rendered as
  433. *
  434. * @default 'div'
  435. */
  436. as?: object | string;
  437. }
  438. type PointerType = 'mouse' | 'touch' | 'pen';
  439. interface Supportable {
  440. isSupported: ComputedRef<boolean>;
  441. }
  442. //#endregion
  443. //#region useAnimate/index.d.ts
  444. interface UseAnimateOptions extends KeyframeAnimationOptions, ConfigurableWindow {
  445. /**
  446. * Will automatically run play when `useAnimate` is used
  447. *
  448. * @default true
  449. */
  450. immediate?: boolean;
  451. /**
  452. * Whether to commits the end styling state of an animation to the element being animated
  453. * In general, you should use `fill` option with this.
  454. *
  455. * @default false
  456. */
  457. commitStyles?: boolean;
  458. /**
  459. * Whether to persists the animation
  460. *
  461. * @default false
  462. */
  463. persist?: boolean;
  464. /**
  465. * Executed after animation initialization
  466. */
  467. onReady?: (animate: Animation) => void;
  468. /**
  469. * Callback when error is caught.
  470. */
  471. onError?: (e: unknown) => void;
  472. }
  473. type UseAnimateKeyframes = MaybeRef<Keyframe[] | PropertyIndexedKeyframes | null>;
  474. interface UseAnimateReturn extends Supportable {
  475. animate: ShallowRef<Animation | undefined>;
  476. play: () => void;
  477. pause: () => void;
  478. reverse: () => void;
  479. finish: () => void;
  480. cancel: () => void;
  481. pending: ComputedRef<boolean>;
  482. playState: ComputedRef<AnimationPlayState>;
  483. replaceState: ComputedRef<AnimationReplaceState>;
  484. startTime: WritableComputedRef<CSSNumberish | number | null>;
  485. currentTime: WritableComputedRef<CSSNumberish | null>;
  486. timeline: WritableComputedRef<AnimationTimeline | null>;
  487. playbackRate: WritableComputedRef<number>;
  488. }
  489. /**
  490. * Reactive Web Animations API
  491. *
  492. * @see https://vueuse.org/useAnimate
  493. * @param target
  494. * @param keyframes
  495. * @param options
  496. */
  497. declare function useAnimate(target: MaybeComputedElementRef, keyframes: UseAnimateKeyframes, options?: number | UseAnimateOptions): UseAnimateReturn;
  498. //#endregion
  499. //#region useAsyncQueue/index.d.ts
  500. type UseAsyncQueueTask<T> = (...args: any[]) => T | Promise<T>;
  501. type MapQueueTask<T extends any[]> = { [K in keyof T]: UseAsyncQueueTask<T[K]> };
  502. interface UseAsyncQueueResult<T> {
  503. state: 'aborted' | 'fulfilled' | 'pending' | 'rejected';
  504. data: T | null;
  505. }
  506. interface UseAsyncQueueReturn<T> {
  507. activeIndex: ShallowRef<number>;
  508. result: T;
  509. }
  510. interface UseAsyncQueueOptions {
  511. /**
  512. * Interrupt tasks when current task fails.
  513. *
  514. * @default true
  515. */
  516. interrupt?: boolean;
  517. /**
  518. * Trigger it when the tasks fails.
  519. *
  520. */
  521. onError?: () => void;
  522. /**
  523. * Trigger it when the tasks ends.
  524. *
  525. */
  526. onFinished?: () => void;
  527. /**
  528. * A AbortSignal that can be used to abort the task.
  529. */
  530. signal?: AbortSignal;
  531. }
  532. /**
  533. * Asynchronous queue task controller.
  534. *
  535. * @see https://vueuse.org/useAsyncQueue
  536. * @param tasks
  537. * @param options
  538. */
  539. declare function useAsyncQueue<T extends any[], S = MapQueueTask<T>>(tasks: S & Array<UseAsyncQueueTask<any>>, options?: UseAsyncQueueOptions): UseAsyncQueueReturn<{ [P in keyof T]: UseAsyncQueueResult<T[P]> }>;
  540. //#endregion
  541. //#region useAsyncState/index.d.ts
  542. interface UseAsyncStateReturnBase<Data, Params extends any[], Shallow extends boolean> {
  543. state: Shallow extends true ? Ref<Data> : Ref<UnwrapRef<Data>>;
  544. isReady: Ref<boolean>;
  545. isLoading: Ref<boolean>;
  546. error: Ref<unknown>;
  547. execute: (delay?: number, ...args: Params) => Promise<Data | undefined>;
  548. executeImmediate: (...args: Params) => Promise<Data | undefined>;
  549. }
  550. type UseAsyncStateReturn<Data, Params extends any[], Shallow extends boolean> = UseAsyncStateReturnBase<Data, Params, Shallow> & PromiseLike<UseAsyncStateReturnBase<Data, Params, Shallow>>;
  551. interface UseAsyncStateOptions<Shallow extends boolean, D = any> {
  552. /**
  553. * Delay for the first execution of the promise when "immediate" is true. In milliseconds.
  554. *
  555. * @default 0
  556. */
  557. delay?: number;
  558. /**
  559. * Execute the promise right after the function is invoked.
  560. * Will apply the delay if any.
  561. *
  562. * When set to false, you will need to execute it manually.
  563. *
  564. * @default true
  565. */
  566. immediate?: boolean;
  567. /**
  568. * Callback when error is caught.
  569. */
  570. onError?: (e: unknown) => void;
  571. /**
  572. * Callback when success is caught.
  573. * @param {D} data
  574. */
  575. onSuccess?: (data: D) => void;
  576. /**
  577. * Sets the state to initialState before executing the promise.
  578. *
  579. * This can be useful when calling the execute function more than once (for
  580. * example, to refresh data). When set to false, the current state remains
  581. * unchanged until the promise resolves.
  582. *
  583. * @default true
  584. */
  585. resetOnExecute?: boolean;
  586. /**
  587. * Use shallowRef.
  588. *
  589. * @default true
  590. */
  591. shallow?: Shallow;
  592. /**
  593. *
  594. * An error is thrown when executing the execute function
  595. *
  596. * @default false
  597. */
  598. throwError?: boolean;
  599. }
  600. /**
  601. * Reactive async state. Will not block your setup function and will trigger changes once
  602. * the promise is ready.
  603. *
  604. * @see https://vueuse.org/useAsyncState
  605. * @param promise The promise / async function to be resolved
  606. * @param initialState The initial state, used until the first evaluation finishes
  607. * @param options
  608. */
  609. declare function useAsyncState<Data, Params extends any[] = any[], Shallow extends boolean = true>(promise: Promise<Data> | ((...args: Params) => Promise<Data>), initialState: MaybeRef<Data>, options?: UseAsyncStateOptions<Shallow, Data>): UseAsyncStateReturn<Data, Params, Shallow>;
  610. //#endregion
  611. //#region useBase64/index.d.ts
  612. interface UseBase64Options {
  613. /**
  614. * Output as Data URL format
  615. *
  616. * @default true
  617. */
  618. dataUrl?: boolean;
  619. }
  620. interface ToDataURLOptions extends UseBase64Options {
  621. /**
  622. * MIME type
  623. */
  624. type?: string | undefined;
  625. /**
  626. * Image quality of jpeg or webp
  627. */
  628. quality?: any;
  629. }
  630. interface UseBase64ObjectOptions<T> extends UseBase64Options {
  631. serializer?: (v: T) => string;
  632. }
  633. interface UseBase64Return {
  634. base64: ShallowRef<string>;
  635. promise: ShallowRef<Promise<string>>;
  636. execute: () => Promise<string>;
  637. }
  638. declare function useBase64(target: MaybeRefOrGetter<string | undefined>, options?: UseBase64Options): UseBase64Return;
  639. declare function useBase64(target: MaybeRefOrGetter<Blob | undefined>, options?: UseBase64Options): UseBase64Return;
  640. declare function useBase64(target: MaybeRefOrGetter<ArrayBuffer | undefined>, options?: UseBase64Options): UseBase64Return;
  641. declare function useBase64(target: MaybeRefOrGetter<HTMLCanvasElement | undefined>, options?: ToDataURLOptions): UseBase64Return;
  642. declare function useBase64(target: MaybeRefOrGetter<HTMLImageElement | undefined>, options?: ToDataURLOptions): UseBase64Return;
  643. declare function useBase64<T extends Record<string, unknown>>(target: MaybeRefOrGetter<T>, options?: UseBase64ObjectOptions<T>): UseBase64Return;
  644. declare function useBase64<T extends Map<string, unknown>>(target: MaybeRefOrGetter<T>, options?: UseBase64ObjectOptions<T>): UseBase64Return;
  645. declare function useBase64<T extends Set<unknown>>(target: MaybeRefOrGetter<T>, options?: UseBase64ObjectOptions<T>): UseBase64Return;
  646. declare function useBase64<T>(target: MaybeRefOrGetter<T[]>, options?: UseBase64ObjectOptions<T[]>): UseBase64Return;
  647. //#endregion
  648. //#region useBattery/index.d.ts
  649. interface UseBatteryOptions extends ConfigurableNavigator {}
  650. interface UseBatteryReturn extends Supportable {
  651. charging: ShallowRef<boolean>;
  652. chargingTime: ShallowRef<number>;
  653. dischargingTime: ShallowRef<number>;
  654. level: ShallowRef<number>;
  655. }
  656. interface BatteryManager extends EventTarget {
  657. charging: boolean;
  658. chargingTime: number;
  659. dischargingTime: number;
  660. level: number;
  661. }
  662. /**
  663. * Reactive Battery Status API.
  664. *
  665. * @see https://vueuse.org/useBattery
  666. *
  667. * @__NO_SIDE_EFFECTS__
  668. */
  669. declare function useBattery(options?: UseBatteryOptions): UseBatteryReturn;
  670. //#endregion
  671. //#region useBluetooth/index.d.ts
  672. interface UseBluetoothRequestDeviceOptions {
  673. /**
  674. *
  675. * An array of BluetoothScanFilters. This filter consists of an array
  676. * of BluetoothServiceUUIDs, a name parameter, and a namePrefix parameter.
  677. *
  678. */
  679. filters?: BluetoothLEScanFilter[] | undefined;
  680. /**
  681. *
  682. * An array of BluetoothServiceUUIDs.
  683. *
  684. * @see https://developer.mozilla.org/en-US/docs/Web/API/BluetoothRemoteGATTService/uuid
  685. *
  686. */
  687. optionalServices?: BluetoothServiceUUID[] | undefined;
  688. }
  689. interface UseBluetoothOptions extends UseBluetoothRequestDeviceOptions, ConfigurableNavigator {
  690. /**
  691. *
  692. * A boolean value indicating that the requesting script can accept all Bluetooth
  693. * devices. The default is false.
  694. *
  695. * !! This may result in a bunch of unrelated devices being shown
  696. * in the chooser and energy being wasted as there are no filters.
  697. *
  698. *
  699. * Use it with caution.
  700. *
  701. * @default false
  702. *
  703. */
  704. acceptAllDevices?: boolean;
  705. }
  706. declare function useBluetooth(options?: UseBluetoothOptions): UseBluetoothReturn;
  707. interface UseBluetoothReturn extends Supportable {
  708. isConnected: Readonly<ShallowRef<boolean>>;
  709. device: ShallowRef<BluetoothDevice | undefined>;
  710. requestDevice: () => Promise<void>;
  711. server: ShallowRef<BluetoothRemoteGATTServer | undefined>;
  712. error: ShallowRef<unknown | null>;
  713. }
  714. //#endregion
  715. //#region useBreakpoints/breakpoints.d.ts
  716. /**
  717. * Breakpoints from Tailwind V2
  718. *
  719. * @see https://tailwindcss.com/docs/breakpoints
  720. */
  721. declare const breakpointsTailwind: {
  722. sm: number;
  723. md: number;
  724. lg: number;
  725. xl: number;
  726. '2xl': number;
  727. };
  728. /**
  729. * Breakpoints from Bootstrap V5
  730. *
  731. * @see https://getbootstrap.com/docs/5.0/layout/breakpoints
  732. */
  733. declare const breakpointsBootstrapV5: {
  734. xs: number;
  735. sm: number;
  736. md: number;
  737. lg: number;
  738. xl: number;
  739. xxl: number;
  740. };
  741. /**
  742. * Breakpoints from Vuetify V2
  743. *
  744. * @see https://v2.vuetifyjs.com/en/features/breakpoints/
  745. */
  746. declare const breakpointsVuetifyV2: {
  747. xs: number;
  748. sm: number;
  749. md: number;
  750. lg: number;
  751. xl: number;
  752. };
  753. /**
  754. * Breakpoints from Vuetify V3
  755. *
  756. * @see https://vuetifyjs.com/en/styles/float/#overview
  757. */
  758. declare const breakpointsVuetifyV3: {
  759. xs: number;
  760. sm: number;
  761. md: number;
  762. lg: number;
  763. xl: number;
  764. xxl: number;
  765. };
  766. /**
  767. * Alias to `breakpointsVuetifyV2`
  768. *
  769. * @deprecated explictly use `breakpointsVuetifyV2` or `breakpointsVuetifyV3` instead
  770. */
  771. declare const breakpointsVuetify: {
  772. xs: number;
  773. sm: number;
  774. md: number;
  775. lg: number;
  776. xl: number;
  777. };
  778. /**
  779. * Breakpoints from Ant Design
  780. *
  781. * @see https://ant.design/components/layout/#breakpoint-width
  782. */
  783. declare const breakpointsAntDesign: {
  784. xs: number;
  785. sm: number;
  786. md: number;
  787. lg: number;
  788. xl: number;
  789. xxl: number;
  790. };
  791. /**
  792. * Breakpoints from Quasar V2
  793. *
  794. * @see https://quasar.dev/style/breakpoints
  795. */
  796. declare const breakpointsQuasar: {
  797. xs: number;
  798. sm: number;
  799. md: number;
  800. lg: number;
  801. xl: number;
  802. };
  803. /**
  804. * Sematic Breakpoints
  805. */
  806. declare const breakpointsSematic: {
  807. mobileS: number;
  808. mobileM: number;
  809. mobileL: number;
  810. tablet: number;
  811. laptop: number;
  812. laptopL: number;
  813. desktop4K: number;
  814. };
  815. /**
  816. * Breakpoints from Master CSS
  817. *
  818. * @see https://docs.master.co/css/breakpoints
  819. */
  820. declare const breakpointsMasterCss: {
  821. '3xs': number;
  822. '2xs': number;
  823. xs: number;
  824. sm: number;
  825. md: number;
  826. lg: number;
  827. xl: number;
  828. '2xl': number;
  829. '3xl': number;
  830. '4xl': number;
  831. };
  832. /**
  833. * Breakpoints from PrimeFlex
  834. *
  835. * @see https://primeflex.org/installation
  836. */
  837. declare const breakpointsPrimeFlex: {
  838. sm: number;
  839. md: number;
  840. lg: number;
  841. xl: number;
  842. };
  843. /**
  844. * Breakpoints from ElementUI/ElementPlus
  845. *
  846. * @see https://element.eleme.io/#/en-US/component/layout
  847. * @see https://element-plus.org/en-US/component/layout.html
  848. */
  849. declare const breakpointsElement: {
  850. xs: number;
  851. sm: number;
  852. md: number;
  853. lg: number;
  854. xl: number;
  855. };
  856. //#endregion
  857. //#region useBreakpoints/index.d.ts
  858. type Breakpoints<K extends string = string> = Record<K, MaybeRefOrGetter<number | string>>;
  859. interface UseBreakpointsOptions extends ConfigurableWindow {
  860. /**
  861. * The query strategy to use for the generated shortcut methods like `.lg`
  862. *
  863. * 'min-width' - .lg will be true when the viewport is greater than or equal to the lg breakpoint (mobile-first)
  864. * 'max-width' - .lg will be true when the viewport is smaller than the xl breakpoint (desktop-first)
  865. *
  866. * @default "min-width"
  867. */
  868. strategy?: 'min-width' | 'max-width';
  869. ssrWidth?: number;
  870. }
  871. type UseBreakpointReturn<K extends string = string> = Record<K, ComputedRef<boolean>> & {
  872. greaterOrEqual: (k: MaybeRefOrGetter<K>) => ComputedRef<boolean>;
  873. smallerOrEqual: (k: MaybeRefOrGetter<K>) => ComputedRef<boolean>;
  874. greater: (k: MaybeRefOrGetter<K>) => ComputedRef<boolean>;
  875. smaller: (k: MaybeRefOrGetter<K>) => ComputedRef<boolean>;
  876. between: (a: MaybeRefOrGetter<K>, b: MaybeRefOrGetter<K>) => ComputedRef<boolean>;
  877. isGreater: (k: MaybeRefOrGetter<K>) => boolean;
  878. isGreaterOrEqual: (k: MaybeRefOrGetter<K>) => boolean;
  879. isSmaller: (k: MaybeRefOrGetter<K>) => boolean;
  880. isSmallerOrEqual: (k: MaybeRefOrGetter<K>) => boolean;
  881. isInBetween: (a: MaybeRefOrGetter<K>, b: MaybeRefOrGetter<K>) => boolean;
  882. current: () => ComputedRef<K[]>;
  883. active: () => ComputedRef<K | ''>;
  884. };
  885. /**
  886. * Reactively viewport breakpoints
  887. *
  888. * @see https://vueuse.org/useBreakpoints
  889. *
  890. * @__NO_SIDE_EFFECTS__
  891. */
  892. declare function useBreakpoints<K extends string>(breakpoints: Breakpoints<K>, options?: UseBreakpointsOptions): UseBreakpointReturn<K>;
  893. //#endregion
  894. //#region useBroadcastChannel/index.d.ts
  895. interface UseBroadcastChannelOptions extends ConfigurableWindow {
  896. /**
  897. * The name of the channel.
  898. */
  899. name: string;
  900. }
  901. /**
  902. * Reactive BroadcastChannel
  903. *
  904. * @see https://vueuse.org/useBroadcastChannel
  905. * @see https://developer.mozilla.org/en-US/docs/Web/API/BroadcastChannel
  906. * @param options
  907. *
  908. */
  909. declare function useBroadcastChannel<D, P>(options: UseBroadcastChannelOptions): UseBroadcastChannelReturn<D, P>;
  910. interface UseBroadcastChannelReturn<D, P> extends Supportable {
  911. channel: ShallowRef<BroadcastChannel | undefined>;
  912. data: ShallowRef<D>;
  913. post: (data: P) => void;
  914. close: () => void;
  915. error: ShallowRef<Event | null>;
  916. isClosed: ShallowRef<boolean>;
  917. }
  918. //#endregion
  919. //#region useBrowserLocation/index.d.ts
  920. interface UseBrowserLocationOptions extends ConfigurableWindow {}
  921. interface BrowserLocationState {
  922. readonly trigger: string;
  923. readonly state?: any;
  924. readonly length?: number;
  925. readonly origin?: string;
  926. hash?: string;
  927. host?: string;
  928. hostname?: string;
  929. href?: string;
  930. pathname?: string;
  931. port?: string;
  932. protocol?: string;
  933. search?: string;
  934. }
  935. type UseBrowserLocationReturn = Ref<BrowserLocationState>;
  936. /**
  937. * Reactive browser location.
  938. *
  939. * @see https://vueuse.org/useBrowserLocation
  940. *
  941. * @__NO_SIDE_EFFECTS__
  942. */
  943. declare function useBrowserLocation(options?: UseBrowserLocationOptions): UseBrowserLocationReturn;
  944. //#endregion
  945. //#region useCached/index.d.ts
  946. interface UseCachedOptions<D extends boolean = true> extends ConfigurableDeepRefs<D>, WatchOptions {}
  947. declare function useCached<T, D extends boolean = true>(refValue: Ref<T>, comparator?: (newSourceValue: T, cachedValue: T) => boolean, options?: UseCachedOptions<D>): UseCachedReturn<T, D>;
  948. type UseCachedReturn<T = any, D extends boolean = true> = ShallowOrDeepRef<T, D>;
  949. //#endregion
  950. //#region useClipboard/index.d.ts
  951. interface UseClipboardOptions<Source> extends ConfigurableNavigator {
  952. /**
  953. * Enabled reading for clipboard
  954. *
  955. * @default false
  956. */
  957. read?: boolean;
  958. /**
  959. * Copy source
  960. */
  961. source?: Source;
  962. /**
  963. * Milliseconds to reset state of `copied` ref
  964. *
  965. * @default 1500
  966. */
  967. copiedDuring?: number;
  968. /**
  969. * Whether fallback to document.execCommand('copy') if clipboard is undefined.
  970. *
  971. * @default false
  972. */
  973. legacy?: boolean;
  974. }
  975. type ClipboardValue = string | (() => Promise<string | undefined>);
  976. interface UseClipboardReturn<Optional> extends Supportable {
  977. text: Readonly<ShallowRef<string>>;
  978. copied: Readonly<ShallowRef<boolean>>;
  979. copyPending: Readonly<ShallowRef<boolean>>;
  980. copy: Optional extends true ? (text?: ClipboardValue) => Promise<void> : (text: ClipboardValue) => Promise<void>;
  981. }
  982. /**
  983. * Reactive Clipboard API.
  984. *
  985. * @see https://vueuse.org/useClipboard
  986. * @param options
  987. *
  988. * @__NO_SIDE_EFFECTS__
  989. */
  990. declare function useClipboard(options?: UseClipboardOptions<undefined>): UseClipboardReturn<false>;
  991. declare function useClipboard(options: UseClipboardOptions<MaybeRefOrGetter<string>>): UseClipboardReturn<true>;
  992. //#endregion
  993. //#region useClipboardItems/index.d.ts
  994. interface UseClipboardItemsOptions<Source> extends ConfigurableNavigator {
  995. /**
  996. * Enabled reading for clipboard
  997. *
  998. * @default false
  999. */
  1000. read?: boolean;
  1001. /**
  1002. * Copy source
  1003. */
  1004. source?: Source;
  1005. /**
  1006. * Milliseconds to reset state of `copied` ref
  1007. *
  1008. * @default 1500
  1009. */
  1010. copiedDuring?: number;
  1011. }
  1012. interface UseClipboardItemsReturn<Optional> extends Supportable {
  1013. content: Readonly<Ref<ClipboardItems>>;
  1014. copied: Readonly<ShallowRef<boolean>>;
  1015. copy: Optional extends true ? (content?: ClipboardItems) => Promise<void> : (text: ClipboardItems) => Promise<void>;
  1016. read: () => void;
  1017. }
  1018. /**
  1019. * Reactive Clipboard API.
  1020. *
  1021. * @see https://vueuse.org/useClipboardItems
  1022. * @param options
  1023. *
  1024. * @__NO_SIDE_EFFECTS__
  1025. */
  1026. declare function useClipboardItems(options?: UseClipboardItemsOptions<undefined>): UseClipboardItemsReturn<false>;
  1027. declare function useClipboardItems(options: UseClipboardItemsOptions<MaybeRefOrGetter<ClipboardItems>>): UseClipboardItemsReturn<true>;
  1028. //#endregion
  1029. //#region useCloned/index.d.ts
  1030. interface UseClonedOptions<T = any> extends WatchOptions {
  1031. /**
  1032. * Custom clone function.
  1033. *
  1034. * By default, it use `JSON.parse(JSON.stringify(value))` to clone.
  1035. */
  1036. clone?: (source: T) => T;
  1037. /**
  1038. * Manually sync the ref
  1039. *
  1040. * @default false
  1041. */
  1042. manual?: boolean;
  1043. }
  1044. interface UseClonedReturn<T> {
  1045. /**
  1046. * Cloned ref
  1047. */
  1048. cloned: Ref<T>;
  1049. /**
  1050. * Ref indicates whether the cloned data is modified
  1051. */
  1052. isModified: Ref<boolean>;
  1053. /**
  1054. * Sync cloned data with source manually
  1055. */
  1056. sync: () => void;
  1057. }
  1058. type CloneFn<F, T = F> = (x: F) => T;
  1059. declare function cloneFnJSON<T>(source: T): T;
  1060. declare function useCloned<T>(source: MaybeRefOrGetter<T>, options?: UseClonedOptions): UseClonedReturn<T>;
  1061. //#endregion
  1062. //#region ssr-handlers.d.ts
  1063. interface StorageLikeAsync {
  1064. getItem: (key: string) => Awaitable<string | null>;
  1065. setItem: (key: string, value: string) => Awaitable<void>;
  1066. removeItem: (key: string) => Awaitable<void>;
  1067. }
  1068. interface StorageLike {
  1069. getItem: (key: string) => string | null;
  1070. setItem: (key: string, value: string) => void;
  1071. removeItem: (key: string) => void;
  1072. }
  1073. /**
  1074. * @experimental The API is not finalized yet. It might not follow semver.
  1075. */
  1076. interface SSRHandlersMap {
  1077. getDefaultStorage: () => StorageLike | undefined;
  1078. getDefaultStorageAsync: () => StorageLikeAsync | undefined;
  1079. updateHTMLAttrs: (selector: string | MaybeElementRef, attribute: string, value: string) => void;
  1080. }
  1081. declare function getSSRHandler<T extends keyof SSRHandlersMap>(key: T, fallback: SSRHandlersMap[T]): SSRHandlersMap[T];
  1082. declare function getSSRHandler<T extends keyof SSRHandlersMap>(key: T, fallback: SSRHandlersMap[T] | undefined): SSRHandlersMap[T] | undefined;
  1083. declare function setSSRHandler<T extends keyof SSRHandlersMap>(key: T, fn: SSRHandlersMap[T]): void;
  1084. //#endregion
  1085. //#region useStorage/index.d.ts
  1086. interface Serializer<T> {
  1087. read: (raw: string) => T;
  1088. write: (value: T) => string;
  1089. }
  1090. interface SerializerAsync<T> {
  1091. read: (raw: string) => Awaitable<T>;
  1092. write: (value: T) => Awaitable<string>;
  1093. }
  1094. declare const StorageSerializers: Record<'boolean' | 'object' | 'number' | 'any' | 'string' | 'map' | 'set' | 'date', Serializer<any>>;
  1095. declare const customStorageEventName = "vueuse-storage";
  1096. interface StorageEventLike {
  1097. storageArea: StorageLike | null;
  1098. key: StorageEvent['key'];
  1099. oldValue: StorageEvent['oldValue'];
  1100. newValue: StorageEvent['newValue'];
  1101. }
  1102. interface UseStorageOptions<T> extends ConfigurableEventFilter, ConfigurableWindow, ConfigurableFlush {
  1103. /**
  1104. * Watch for deep changes
  1105. *
  1106. * @default true
  1107. */
  1108. deep?: boolean;
  1109. /**
  1110. * Listen to storage changes, useful for multiple tabs application
  1111. *
  1112. * @default true
  1113. */
  1114. listenToStorageChanges?: boolean;
  1115. /**
  1116. * Write the default value to the storage when it does not exist
  1117. *
  1118. * @default true
  1119. */
  1120. writeDefaults?: boolean;
  1121. /**
  1122. * Merge the default value with the value read from the storage.
  1123. *
  1124. * When setting it to true, it will perform a **shallow merge** for objects.
  1125. * You can pass a function to perform custom merge (e.g. deep merge), for example:
  1126. *
  1127. * @default false
  1128. */
  1129. mergeDefaults?: boolean | ((storageValue: T, defaults: T) => T);
  1130. /**
  1131. * Custom data serialization
  1132. */
  1133. serializer?: Serializer<T>;
  1134. /**
  1135. * On error callback
  1136. *
  1137. * Default log error to `console.error`
  1138. */
  1139. onError?: (error: unknown) => void;
  1140. /**
  1141. * Use shallow ref as reference
  1142. *
  1143. * @default false
  1144. */
  1145. shallow?: boolean;
  1146. /**
  1147. * Wait for the component to be mounted before reading the storage.
  1148. *
  1149. * @default false
  1150. */
  1151. initOnMounted?: boolean;
  1152. }
  1153. declare function useStorage(key: MaybeRefOrGetter<string>, defaults: MaybeRefOrGetter<string>, storage?: StorageLike, options?: UseStorageOptions<string>): RemovableRef<string>;
  1154. declare function useStorage(key: MaybeRefOrGetter<string>, defaults: MaybeRefOrGetter<boolean>, storage?: StorageLike, options?: UseStorageOptions<boolean>): RemovableRef<boolean>;
  1155. declare function useStorage(key: MaybeRefOrGetter<string>, defaults: MaybeRefOrGetter<number>, storage?: StorageLike, options?: UseStorageOptions<number>): RemovableRef<number>;
  1156. declare function useStorage<T>(key: MaybeRefOrGetter<string>, defaults: MaybeRefOrGetter<T>, storage?: StorageLike, options?: UseStorageOptions<T>): RemovableRef<T>;
  1157. declare function useStorage<T = unknown>(key: MaybeRefOrGetter<string>, defaults: MaybeRefOrGetter<null>, storage?: StorageLike, options?: UseStorageOptions<T>): RemovableRef<T>;
  1158. //#endregion
  1159. //#region useColorMode/index.d.ts
  1160. type BasicColorMode = 'light' | 'dark';
  1161. type BasicColorSchema = BasicColorMode | 'auto';
  1162. interface UseColorModeOptions<T extends string = BasicColorMode> extends UseStorageOptions<T | BasicColorMode> {
  1163. /**
  1164. * CSS Selector for the target element applying to
  1165. *
  1166. * @default 'html'
  1167. */
  1168. selector?: string | MaybeElementRef;
  1169. /**
  1170. * HTML attribute applying the target element
  1171. *
  1172. * @default 'class'
  1173. */
  1174. attribute?: string;
  1175. /**
  1176. * The initial color mode
  1177. *
  1178. * @default 'auto'
  1179. */
  1180. initialValue?: MaybeRefOrGetter<T | BasicColorSchema>;
  1181. /**
  1182. * Prefix when adding value to the attribute
  1183. */
  1184. modes?: Partial<Record<T | BasicColorSchema, string>>;
  1185. /**
  1186. * A custom handler for handle the updates.
  1187. * When specified, the default behavior will be overridden.
  1188. *
  1189. * @default undefined
  1190. */
  1191. onChanged?: (mode: T | BasicColorMode, defaultHandler: ((mode: T | BasicColorMode) => void)) => void;
  1192. /**
  1193. * Custom storage ref
  1194. *
  1195. * When provided, `useStorage` will be skipped
  1196. */
  1197. storageRef?: Ref<T | BasicColorSchema>;
  1198. /**
  1199. * Key to persist the data into localStorage/sessionStorage.
  1200. *
  1201. * Pass `null` to disable persistence
  1202. *
  1203. * @default 'vueuse-color-scheme'
  1204. */
  1205. storageKey?: string | null;
  1206. /**
  1207. * Storage object, can be localStorage or sessionStorage
  1208. *
  1209. * @default localStorage
  1210. */
  1211. storage?: StorageLike;
  1212. /**
  1213. * Emit `auto` mode from state
  1214. *
  1215. * When set to `true`, preferred mode won't be translated into `light` or `dark`.
  1216. * This is useful when the fact that `auto` mode was selected needs to be known.
  1217. *
  1218. * @default undefined
  1219. * @deprecated use `store.value` when `auto` mode needs to be known
  1220. * @see https://vueuse.org/core/useColorMode/#advanced-usage
  1221. */
  1222. emitAuto?: boolean;
  1223. /**
  1224. * Disable transition on switch
  1225. *
  1226. * @see https://paco.me/writing/disable-theme-transitions
  1227. * @default true
  1228. */
  1229. disableTransition?: boolean;
  1230. }
  1231. type UseColorModeReturn<T extends string = BasicColorMode> = Ref<T | BasicColorSchema> & {
  1232. store: Ref<T | BasicColorSchema>;
  1233. system: ComputedRef<BasicColorMode>;
  1234. state: ComputedRef<T | BasicColorMode>;
  1235. };
  1236. /**
  1237. * Reactive color mode with auto data persistence.
  1238. *
  1239. * @see https://vueuse.org/useColorMode
  1240. * @param options
  1241. */
  1242. declare function useColorMode<T extends string = BasicColorMode>(options?: UseColorModeOptions<T>): UseColorModeReturn<T>;
  1243. //#endregion
  1244. //#region useConfirmDialog/index.d.ts
  1245. type UseConfirmDialogRevealResult<C, D> = {
  1246. data?: C;
  1247. isCanceled: false;
  1248. } | {
  1249. data?: D;
  1250. isCanceled: true;
  1251. };
  1252. interface UseConfirmDialogReturn<RevealData, ConfirmData, CancelData> {
  1253. /**
  1254. * Revealing state
  1255. */
  1256. isRevealed: ComputedRef<boolean>;
  1257. /**
  1258. * Opens the dialog.
  1259. * Create promise and return it. Triggers `onReveal` hook.
  1260. */
  1261. reveal: (data?: RevealData) => Promise<UseConfirmDialogRevealResult<ConfirmData, CancelData>>;
  1262. /**
  1263. * Confirms and closes the dialog. Triggers a callback inside `onConfirm` hook.
  1264. * Resolves promise from `reveal()` with `data` and `isCanceled` ref with `false` value.
  1265. * Can accept any data and to pass it to `onConfirm` hook.
  1266. */
  1267. confirm: (data?: ConfirmData) => void;
  1268. /**
  1269. * Cancels and closes the dialog. Triggers a callback inside `onCancel` hook.
  1270. * Resolves promise from `reveal()` with `data` and `isCanceled` ref with `true` value.
  1271. * Can accept any data and to pass it to `onCancel` hook.
  1272. */
  1273. cancel: (data?: CancelData) => void;
  1274. /**
  1275. * Event Hook to be triggered right before dialog creating.
  1276. */
  1277. onReveal: EventHookOn<RevealData>;
  1278. /**
  1279. * Event Hook to be called on `confirm()`.
  1280. * Gets data object from `confirm` function.
  1281. */
  1282. onConfirm: EventHookOn<ConfirmData>;
  1283. /**
  1284. * Event Hook to be called on `cancel()`.
  1285. * Gets data object from `cancel` function.
  1286. */
  1287. onCancel: EventHookOn<CancelData>;
  1288. }
  1289. /**
  1290. * Hooks for creating confirm dialogs. Useful for modal windows, popups and logins.
  1291. *
  1292. * @see https://vueuse.org/useConfirmDialog/
  1293. * @param revealed `boolean` `ref` that handles a modal window
  1294. *
  1295. * @__NO_SIDE_EFFECTS__
  1296. */
  1297. declare function useConfirmDialog<RevealData = any, ConfirmData = any, CancelData = any>(revealed?: ShallowRef<boolean>): UseConfirmDialogReturn<RevealData, ConfirmData, CancelData>;
  1298. //#endregion
  1299. //#region useCountdown/index.d.ts
  1300. interface UseCountdownOptions extends ConfigurableScheduler {
  1301. /**
  1302. * Interval for the countdown in milliseconds. Default is 1000ms.
  1303. *
  1304. * @deprecated Please use `scheduler` option instead
  1305. */
  1306. interval?: MaybeRefOrGetter<number>;
  1307. /**
  1308. * Callback function called when the countdown reaches 0.
  1309. */
  1310. onComplete?: () => void;
  1311. /**
  1312. * Callback function called on each tick of the countdown.
  1313. */
  1314. onTick?: () => void;
  1315. /**
  1316. * Start the countdown immediately
  1317. *
  1318. * @deprecated Please use `scheduler` option instead
  1319. * @default false
  1320. */
  1321. immediate?: boolean;
  1322. }
  1323. interface UseCountdownReturn extends Pausable {
  1324. /**
  1325. * Current countdown value.
  1326. */
  1327. remaining: ShallowRef<number>;
  1328. /**
  1329. * Resets the countdown and repeatsLeft to their initial values.
  1330. */
  1331. reset: (countdown?: MaybeRefOrGetter<number>) => void;
  1332. /**
  1333. * Stops the countdown and resets its state.
  1334. */
  1335. stop: () => void;
  1336. /**
  1337. * Reset the countdown and start it again.
  1338. */
  1339. start: (countdown?: MaybeRefOrGetter<number>) => void;
  1340. }
  1341. /**
  1342. * Reactive countdown timer in seconds.
  1343. *
  1344. * @param initialCountdown
  1345. * @param options
  1346. *
  1347. * @see https://vueuse.org/useCountdown
  1348. */
  1349. declare function useCountdown(initialCountdown: MaybeRefOrGetter<number>, options?: UseCountdownOptions): UseCountdownReturn;
  1350. //#endregion
  1351. //#region useCssSupports/index.d.ts
  1352. interface UseCssSupportsOptions extends ConfigurableWindow {
  1353. ssrValue?: boolean;
  1354. }
  1355. interface UseCssSupportsReturn extends Supportable {}
  1356. declare function useCssSupports(property: MaybeRefOrGetter<string>, value: MaybeRefOrGetter<string>, options?: UseCssSupportsOptions): UseCssSupportsReturn;
  1357. declare function useCssSupports(conditionText: MaybeRefOrGetter<string>, options?: UseCssSupportsOptions): UseCssSupportsReturn;
  1358. //#endregion
  1359. //#region useCssVar/index.d.ts
  1360. interface UseCssVarOptions extends ConfigurableWindow {
  1361. initialValue?: string;
  1362. /**
  1363. * Use MutationObserver to monitor variable changes
  1364. * @default false
  1365. */
  1366. observe?: boolean;
  1367. }
  1368. /**
  1369. * Manipulate CSS variables.
  1370. *
  1371. * @see https://vueuse.org/useCssVar
  1372. * @param prop
  1373. * @param target
  1374. * @param options
  1375. */
  1376. declare function useCssVar(prop: MaybeRefOrGetter<string | null | undefined>, target?: MaybeElementRef, options?: UseCssVarOptions): _$vue.ShallowRef<string | undefined, string | undefined>;
  1377. //#endregion
  1378. //#region useCurrentElement/index.d.ts
  1379. declare function useCurrentElement<T extends MaybeElement = MaybeElement, R extends VueInstance = VueInstance, E extends MaybeElement = (MaybeElement extends T ? IsAny<R['$el']> extends false ? R['$el'] : T : T)>(rootComponent?: MaybeElementRef<R>): _$_vueuse_shared0.ComputedRefWithControl<E>;
  1380. //#endregion
  1381. //#region useCycleList/index.d.ts
  1382. interface UseCycleListOptions<T> {
  1383. /**
  1384. * The initial value of the state.
  1385. * A ref can be provided to reuse.
  1386. */
  1387. initialValue?: MaybeRef<T>;
  1388. /**
  1389. * The default index when
  1390. */
  1391. fallbackIndex?: number;
  1392. /**
  1393. * Custom function to get the index of the current value.
  1394. */
  1395. getIndexOf?: (value: T, list: T[]) => number;
  1396. }
  1397. /**
  1398. * Cycle through a list of items
  1399. *
  1400. * @see https://vueuse.org/useCycleList
  1401. */
  1402. declare function useCycleList<T>(list: MaybeRefOrGetter<T[]>, options?: UseCycleListOptions<T>): UseCycleListReturn<T>;
  1403. interface UseCycleListReturn<T> {
  1404. state: ShallowRef<T>;
  1405. index: WritableComputedRef<number>;
  1406. next: (n?: number) => T;
  1407. prev: (n?: number) => T;
  1408. /**
  1409. * Go to a specific index
  1410. */
  1411. go: (i: number) => T;
  1412. }
  1413. //#endregion
  1414. //#region useDark/index.d.ts
  1415. interface UseDarkOptions extends Omit<UseColorModeOptions<BasicColorSchema>, 'modes' | 'onChanged'> {
  1416. /**
  1417. * Value applying to the target element when isDark=true
  1418. *
  1419. * @default 'dark'
  1420. */
  1421. valueDark?: string;
  1422. /**
  1423. * Value applying to the target element when isDark=false
  1424. *
  1425. * @default ''
  1426. */
  1427. valueLight?: string;
  1428. /**
  1429. * A custom handler for handle the updates.
  1430. * When specified, the default behavior will be overridden.
  1431. *
  1432. * @default undefined
  1433. */
  1434. onChanged?: (isDark: boolean, defaultHandler: ((mode: BasicColorSchema) => void), mode: BasicColorSchema) => void;
  1435. }
  1436. type UseDarkReturn = WritableComputedRef<boolean>;
  1437. /**
  1438. * Reactive dark mode with auto data persistence.
  1439. *
  1440. * @see https://vueuse.org/useDark
  1441. * @param options
  1442. */
  1443. declare function useDark(options?: UseDarkOptions): UseDarkReturn;
  1444. //#endregion
  1445. //#region useManualRefHistory/index.d.ts
  1446. interface UseRefHistoryRecord<T> {
  1447. snapshot: T;
  1448. timestamp: number;
  1449. }
  1450. interface UseManualRefHistoryOptions<Raw, Serialized = Raw> {
  1451. /**
  1452. * Maximum number of history to be kept. Default to unlimited.
  1453. */
  1454. capacity?: number;
  1455. /**
  1456. * Clone when taking a snapshot, shortcut for dump: JSON.parse(JSON.stringify(value)).
  1457. * Default to false
  1458. *
  1459. * @default false
  1460. */
  1461. clone?: boolean | CloneFn<Raw>;
  1462. /**
  1463. * Serialize data into the history
  1464. */
  1465. dump?: (v: Raw) => Serialized;
  1466. /**
  1467. * Deserialize data from the history
  1468. */
  1469. parse?: (v: Serialized) => Raw;
  1470. /**
  1471. * set data source
  1472. */
  1473. setSource?: (source: Ref<Raw>, v: Raw) => void;
  1474. }
  1475. interface UseManualRefHistoryReturn<Raw, Serialized> {
  1476. /**
  1477. * Bypassed tracking ref from the argument
  1478. */
  1479. source: Ref<Raw>;
  1480. /**
  1481. * An array of history records for undo, newest comes to first
  1482. */
  1483. history: ComputedRef<UseRefHistoryRecord<Serialized>[]>;
  1484. /**
  1485. * Last history point, source can be different if paused
  1486. */
  1487. last: Ref<UseRefHistoryRecord<Serialized>>;
  1488. /**
  1489. * Same as {@link UseManualRefHistoryReturn.history | history}
  1490. */
  1491. undoStack: Ref<UseRefHistoryRecord<Serialized>[]>;
  1492. /**
  1493. * Records array for redo
  1494. */
  1495. redoStack: Ref<UseRefHistoryRecord<Serialized>[]>;
  1496. /**
  1497. * A ref representing if undo is possible (non empty undoStack)
  1498. */
  1499. canUndo: ComputedRef<boolean>;
  1500. /**
  1501. * A ref representing if redo is possible (non empty redoStack)
  1502. */
  1503. canRedo: ComputedRef<boolean>;
  1504. /**
  1505. * Undo changes
  1506. */
  1507. undo: () => void;
  1508. /**
  1509. * Redo changes
  1510. */
  1511. redo: () => void;
  1512. /**
  1513. * Clear all the history
  1514. */
  1515. clear: () => void;
  1516. /**
  1517. * Create a new history record
  1518. */
  1519. commit: () => void;
  1520. /**
  1521. * Reset ref's value with latest history
  1522. */
  1523. reset: () => void;
  1524. }
  1525. /**
  1526. * Track the change history of a ref, also provides undo and redo functionality.
  1527. *
  1528. * @see https://vueuse.org/useManualRefHistory
  1529. * @param source
  1530. * @param options
  1531. */
  1532. declare function useManualRefHistory<Raw, Serialized = Raw>(source: Ref<Raw>, options?: UseManualRefHistoryOptions<Raw, Serialized>): UseManualRefHistoryReturn<Raw, Serialized>;
  1533. //#endregion
  1534. //#region useRefHistory/index.d.ts
  1535. interface UseRefHistoryOptions<Raw, Serialized = Raw> extends ConfigurableEventFilter, ConfigurableFlush {
  1536. /**
  1537. * Watch for deep changes, default to false
  1538. *
  1539. * When set to true, it will also create clones for values store in the history
  1540. *
  1541. * @default false
  1542. */
  1543. deep?: boolean;
  1544. /**
  1545. * Maximum number of history to be kept. Default to unlimited.
  1546. */
  1547. capacity?: number;
  1548. /**
  1549. * Clone when taking a snapshot, shortcut for dump: JSON.parse(JSON.stringify(value)).
  1550. * Default to false
  1551. *
  1552. * @default false
  1553. */
  1554. clone?: boolean | CloneFn<Raw>;
  1555. /**
  1556. * Serialize data into the history
  1557. */
  1558. dump?: (v: Raw) => Serialized;
  1559. /**
  1560. * Deserialize data from the history
  1561. */
  1562. parse?: (v: Serialized) => Raw;
  1563. /**
  1564. * Function to determine if the commit should proceed
  1565. * @param oldValue Previous value
  1566. * @param newValue New value
  1567. * @returns boolean indicating if commit should proceed
  1568. */
  1569. shouldCommit?: (oldValue: Raw | undefined, newValue: Raw) => boolean;
  1570. }
  1571. interface UseRefHistoryReturn<Raw, Serialized> extends UseManualRefHistoryReturn<Raw, Serialized> {
  1572. /**
  1573. * A ref representing if the tracking is enabled
  1574. */
  1575. isTracking: Ref<boolean>;
  1576. /**
  1577. * Pause change tracking
  1578. */
  1579. pause: () => void;
  1580. /**
  1581. * Resume change tracking
  1582. *
  1583. * @param [commit] if true, a history record will be create after resuming
  1584. */
  1585. resume: (commit?: boolean) => void;
  1586. /**
  1587. * A sugar for auto pause and auto resuming within a function scope
  1588. *
  1589. * @param fn
  1590. */
  1591. batch: (fn: (cancel: Fn) => void) => void;
  1592. /**
  1593. * Clear the data and stop the watch
  1594. */
  1595. dispose: () => void;
  1596. }
  1597. /**
  1598. * Track the change history of a ref, also provides undo and redo functionality.
  1599. *
  1600. * @see https://vueuse.org/useRefHistory
  1601. * @param source
  1602. * @param options
  1603. */
  1604. declare function useRefHistory<Raw, Serialized = Raw>(source: Ref<Raw>, options?: UseRefHistoryOptions<Raw, Serialized>): UseRefHistoryReturn<Raw, Serialized>;
  1605. //#endregion
  1606. //#region useDebouncedRefHistory/index.d.ts
  1607. /**
  1608. * Shorthand for [useRefHistory](https://vueuse.org/useRefHistory) with debounce filter.
  1609. *
  1610. * @see https://vueuse.org/useDebouncedRefHistory
  1611. * @param source
  1612. * @param options
  1613. */
  1614. declare function useDebouncedRefHistory<Raw, Serialized = Raw>(source: Ref<Raw>, options?: Omit<UseRefHistoryOptions<Raw, Serialized>, 'eventFilter'> & {
  1615. debounce?: MaybeRefOrGetter<number>;
  1616. }): UseRefHistoryReturn<Raw, Serialized>;
  1617. //#endregion
  1618. //#region useDeviceMotion/index.d.ts
  1619. interface UseDeviceMotionOptions extends ConfigurableWindow, ConfigurableEventFilter {
  1620. /**
  1621. * Request for permissions immediately if it's not granted,
  1622. * otherwise label and deviceIds could be empty
  1623. *
  1624. * @default false
  1625. */
  1626. requestPermissions?: boolean;
  1627. }
  1628. /** @deprecated use {@link UseDeviceMotionOptions} instead */
  1629. type DeviceMotionOptions = UseDeviceMotionOptions;
  1630. interface UseDeviceMotionReturn extends Supportable {
  1631. acceleration: Ref<DeviceMotionEventAcceleration | null>;
  1632. accelerationIncludingGravity: Ref<DeviceMotionEventAcceleration | null>;
  1633. rotationRate: Ref<DeviceMotionEventRotationRate | null>;
  1634. interval: ShallowRef<number>;
  1635. requirePermissions: ComputedRef<boolean>;
  1636. ensurePermissions: () => Promise<void>;
  1637. permissionGranted: ShallowRef<boolean>;
  1638. }
  1639. /**
  1640. * Reactive DeviceMotionEvent.
  1641. *
  1642. * @see https://vueuse.org/useDeviceMotion
  1643. * @param options
  1644. */
  1645. declare function useDeviceMotion(options?: UseDeviceMotionOptions): UseDeviceMotionReturn;
  1646. //#endregion
  1647. //#region useDeviceOrientation/index.d.ts
  1648. interface UseDeviceOrientationOptions extends ConfigurableWindow {}
  1649. interface UseDeviceOrientationReturn extends Supportable {
  1650. isAbsolute: ShallowRef<boolean, boolean>;
  1651. alpha: Ref<number | null, number | null>;
  1652. beta: Ref<number | null, number | null>;
  1653. gamma: Ref<number | null, number | null>;
  1654. }
  1655. /**
  1656. * Reactive DeviceOrientationEvent.
  1657. *
  1658. * @see https://vueuse.org/useDeviceOrientation
  1659. * @param options
  1660. *
  1661. * @__NO_SIDE_EFFECTS__
  1662. */
  1663. declare function useDeviceOrientation(options?: UseDeviceOrientationOptions): UseDeviceOrientationReturn;
  1664. //#endregion
  1665. //#region useDevicePixelRatio/index.d.ts
  1666. interface UseDevicePixelRatioOptions extends ConfigurableWindow {}
  1667. interface UseDevicePixelRatioReturn {
  1668. pixelRatio: Readonly<ShallowRef<number>>;
  1669. stop: WatchStopHandle;
  1670. }
  1671. /**
  1672. * Reactively track `window.devicePixelRatio`.
  1673. *
  1674. * @see https://vueuse.org/useDevicePixelRatio
  1675. *
  1676. * @__NO_SIDE_EFFECTS__
  1677. */
  1678. declare function useDevicePixelRatio(options?: UseDevicePixelRatioOptions): UseDevicePixelRatioReturn;
  1679. //#endregion
  1680. //#region useDevicesList/index.d.ts
  1681. interface UseDevicesListOptions extends ConfigurableNavigator {
  1682. onUpdated?: (devices: MediaDeviceInfo[]) => void;
  1683. /**
  1684. * Request for permissions immediately if it's not granted,
  1685. * otherwise label and deviceIds could be empty
  1686. *
  1687. * @default false
  1688. */
  1689. requestPermissions?: boolean;
  1690. /**
  1691. * Request for types of media permissions
  1692. *
  1693. * @default { audio: true, video: true }
  1694. */
  1695. constraints?: MediaStreamConstraints;
  1696. }
  1697. interface UseDevicesListReturn extends Supportable {
  1698. /**
  1699. * All devices
  1700. */
  1701. devices: ShallowRef<MediaDeviceInfo[]>;
  1702. videoInputs: ComputedRef<MediaDeviceInfo[]>;
  1703. audioInputs: ComputedRef<MediaDeviceInfo[]>;
  1704. audioOutputs: ComputedRef<MediaDeviceInfo[]>;
  1705. permissionGranted: ShallowRef<boolean>;
  1706. ensurePermissions: () => Promise<boolean>;
  1707. }
  1708. /**
  1709. * Reactive `enumerateDevices` listing available input/output devices
  1710. *
  1711. * @see https://vueuse.org/useDevicesList
  1712. * @param options
  1713. */
  1714. declare function useDevicesList(options?: UseDevicesListOptions): UseDevicesListReturn;
  1715. //#endregion
  1716. //#region useDisplayMedia/index.d.ts
  1717. interface UseDisplayMediaOptions extends ConfigurableNavigator {
  1718. /**
  1719. * If the stream is enabled
  1720. * @default false
  1721. */
  1722. enabled?: MaybeRef<boolean>;
  1723. /**
  1724. * If the stream video media constraints
  1725. */
  1726. video?: boolean | MediaTrackConstraints | undefined;
  1727. /**
  1728. * If the stream audio media constraints
  1729. */
  1730. audio?: boolean | MediaTrackConstraints | undefined;
  1731. }
  1732. interface UseDisplayMediaReturn extends Supportable {
  1733. stream: ShallowRef<MediaStream | undefined>;
  1734. start: () => Promise<MediaStream | undefined>;
  1735. stop: () => void;
  1736. enabled: ShallowRef<boolean>;
  1737. }
  1738. /**
  1739. * Reactive `mediaDevices.getDisplayMedia` streaming
  1740. *
  1741. * @see https://vueuse.org/useDisplayMedia
  1742. * @param options
  1743. */
  1744. declare function useDisplayMedia(options?: UseDisplayMediaOptions): UseDisplayMediaReturn;
  1745. //#endregion
  1746. //#region useDocumentVisibility/index.d.ts
  1747. interface UseDocumentVisibilityOptions extends ConfigurableDocument {}
  1748. type UseDocumentVisibilityReturn = ShallowRef<DocumentVisibilityState>;
  1749. /**
  1750. * Reactively track `document.visibilityState`.
  1751. *
  1752. * @see https://vueuse.org/useDocumentVisibility
  1753. *
  1754. * @__NO_SIDE_EFFECTS__
  1755. */
  1756. declare function useDocumentVisibility(options?: UseDocumentVisibilityOptions): UseDocumentVisibilityReturn;
  1757. //#endregion
  1758. //#region useDraggable/index.d.ts
  1759. interface UseDraggableOptions {
  1760. /**
  1761. * Only start the dragging when click on the element directly
  1762. *
  1763. * @default false
  1764. */
  1765. exact?: MaybeRefOrGetter<boolean>;
  1766. /**
  1767. * Prevent events defaults
  1768. *
  1769. * @default false
  1770. */
  1771. preventDefault?: MaybeRefOrGetter<boolean>;
  1772. /**
  1773. * Prevent events propagation
  1774. *
  1775. * @default false
  1776. */
  1777. stopPropagation?: MaybeRefOrGetter<boolean>;
  1778. /**
  1779. * Whether dispatch events in capturing phase
  1780. *
  1781. * @default true
  1782. */
  1783. capture?: boolean;
  1784. /**
  1785. * Element to attach `pointermove` and `pointerup` events to.
  1786. *
  1787. * @default window
  1788. */
  1789. draggingElement?: MaybeRefOrGetter<HTMLElement | SVGElement | Window | Document | null | undefined>;
  1790. /**
  1791. * Element for calculating bounds (If not set, it will use the event's target).
  1792. *
  1793. * @default undefined
  1794. */
  1795. containerElement?: MaybeRefOrGetter<HTMLElement | SVGElement | null | undefined>;
  1796. /**
  1797. * Handle that triggers the drag event
  1798. *
  1799. * @default target
  1800. */
  1801. handle?: MaybeRefOrGetter<HTMLElement | SVGElement | null | undefined>;
  1802. /**
  1803. * Pointer types that listen to.
  1804. *
  1805. * @default ['mouse', 'touch', 'pen']
  1806. */
  1807. pointerTypes?: PointerType[];
  1808. /**
  1809. * Initial position of the element.
  1810. *
  1811. * @default { x: 0, y: 0 }
  1812. */
  1813. initialValue?: MaybeRefOrGetter<Position>;
  1814. /**
  1815. * Callback when the dragging starts. Return `false` to prevent dragging.
  1816. */
  1817. onStart?: (position: Position, event: PointerEvent) => void | false;
  1818. /**
  1819. * Callback during dragging.
  1820. */
  1821. onMove?: (position: Position, event: PointerEvent) => void;
  1822. /**
  1823. * Callback when dragging end.
  1824. */
  1825. onEnd?: (position: Position, event: PointerEvent) => void;
  1826. /**
  1827. * Axis to drag on.
  1828. *
  1829. * @default 'both'
  1830. */
  1831. axis?: 'x' | 'y' | 'both';
  1832. /**
  1833. * Disabled drag and drop.
  1834. *
  1835. * @default false
  1836. */
  1837. disabled?: MaybeRefOrGetter<boolean>;
  1838. /**
  1839. * Mouse buttons that are allowed to trigger drag events.
  1840. *
  1841. * - `0`: Main button, usually the left button or the un-initialized state
  1842. * - `1`: Auxiliary button, usually the wheel button or the middle button (if present)
  1843. * - `2`: Secondary button, usually the right button
  1844. * - `3`: Fourth button, typically the Browser Back button
  1845. * - `4`: Fifth button, typically the Browser Forward button
  1846. *
  1847. * @see https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/button#value
  1848. * @default [0]
  1849. */
  1850. buttons?: MaybeRefOrGetter<number[]>;
  1851. /**
  1852. * Whether to restrict dragging within the visible area of the container.
  1853. *
  1854. * If enabled, the draggable element will not leave the visible area of its container,
  1855. * ensuring it remains within the viewport of the container during the drag.
  1856. *
  1857. * @default false
  1858. */
  1859. restrictInView?: MaybeRefOrGetter<boolean>;
  1860. /**
  1861. * Whether to enable auto-scroll when dragging near the edges.
  1862. *
  1863. * @default false
  1864. */
  1865. autoScroll?: MaybeRefOrGetter<boolean | {
  1866. /**
  1867. * Speed of auto-scroll.
  1868. *
  1869. * @default 2
  1870. */
  1871. speed?: MaybeRefOrGetter<number | Position>;
  1872. /**
  1873. * Margin from the edge to trigger auto-scroll.
  1874. *
  1875. * @default 30
  1876. */
  1877. margin?: MaybeRefOrGetter<number | Position>;
  1878. /**
  1879. * Direction of auto-scroll.
  1880. *
  1881. * @default 'both'
  1882. */
  1883. direction?: 'x' | 'y' | 'both';
  1884. }>;
  1885. }
  1886. interface UseDraggableReturn {
  1887. x: Ref<number>;
  1888. y: Ref<number>;
  1889. position: Ref<Position>;
  1890. isDragging: ComputedRef<boolean>;
  1891. style: ComputedRef<string>;
  1892. }
  1893. /**
  1894. * Make elements draggable.
  1895. *
  1896. * @see https://vueuse.org/useDraggable
  1897. * @param target
  1898. * @param options
  1899. */
  1900. declare function useDraggable(target: MaybeRefOrGetter<HTMLElement | SVGElement | null | undefined>, options?: UseDraggableOptions): UseDraggableReturn;
  1901. //#endregion
  1902. //#region useDropZone/index.d.ts
  1903. interface UseDropZoneReturn {
  1904. files: ShallowRef<File[] | null>;
  1905. isOverDropZone: ShallowRef<boolean>;
  1906. }
  1907. interface UseDropZoneOptions {
  1908. /**
  1909. * Allowed data types, if not set, all data types are allowed.
  1910. * Also can be a function to check the data types.
  1911. */
  1912. dataTypes?: MaybeRef<readonly string[]> | ((types: readonly string[]) => boolean);
  1913. /**
  1914. * Similar to dataTypes, but exposes the DataTransferItemList for custom validation.
  1915. * If provided, this function takes precedence over dataTypes.
  1916. */
  1917. checkValidity?: (items: DataTransferItemList) => boolean;
  1918. onDrop?: (files: File[] | null, event: DragEvent) => void;
  1919. onEnter?: (files: File[] | null, event: DragEvent) => void;
  1920. onLeave?: (files: File[] | null, event: DragEvent) => void;
  1921. onOver?: (files: File[] | null, event: DragEvent) => void;
  1922. /**
  1923. * Allow multiple files to be dropped. Defaults to true.
  1924. */
  1925. multiple?: boolean;
  1926. /**
  1927. * Prevent default behavior for unhandled events. Defaults to false.
  1928. */
  1929. preventDefaultForUnhandled?: boolean;
  1930. }
  1931. declare function useDropZone(target: MaybeRefOrGetter<HTMLElement | Document | null | undefined>, options?: UseDropZoneOptions | UseDropZoneOptions['onDrop']): UseDropZoneReturn;
  1932. //#endregion
  1933. //#region useElementBounding/index.d.ts
  1934. interface UseElementBoundingOptions {
  1935. /**
  1936. * Reset values to 0 on component unmounted
  1937. *
  1938. * @default true
  1939. */
  1940. reset?: boolean;
  1941. /**
  1942. * Listen to window resize event
  1943. *
  1944. * @default true
  1945. */
  1946. windowResize?: boolean;
  1947. /**
  1948. * Listen to window scroll event
  1949. *
  1950. * @default true
  1951. */
  1952. windowScroll?: boolean;
  1953. /**
  1954. * Immediately call update on component mounted
  1955. *
  1956. * @default true
  1957. */
  1958. immediate?: boolean;
  1959. /**
  1960. * Timing to recalculate the bounding box
  1961. *
  1962. * Setting to `next-frame` can be useful when using this together with something like {@link useBreakpoints}
  1963. * and therefore the layout (which influences the bounding box of the observed element) is not updated on the current tick.
  1964. *
  1965. * @default 'sync'
  1966. */
  1967. updateTiming?: 'sync' | 'next-frame';
  1968. }
  1969. interface UseElementBoundingReturn {
  1970. height: ShallowRef<number>;
  1971. bottom: ShallowRef<number>;
  1972. left: ShallowRef<number>;
  1973. right: ShallowRef<number>;
  1974. top: ShallowRef<number>;
  1975. width: ShallowRef<number>;
  1976. x: ShallowRef<number>;
  1977. y: ShallowRef<number>;
  1978. update: () => void;
  1979. }
  1980. /**
  1981. * Reactive bounding box of an HTML element.
  1982. *
  1983. * @see https://vueuse.org/useElementBounding
  1984. * @param target
  1985. */
  1986. declare function useElementBounding(target: MaybeComputedElementRef, options?: UseElementBoundingOptions): UseElementBoundingReturn;
  1987. //#endregion
  1988. //#region useElementByPoint/index.d.ts
  1989. interface UseElementByPointOptions<Multiple extends boolean = false> extends ConfigurableDocument, ConfigurableScheduler {
  1990. x: MaybeRefOrGetter<number>;
  1991. y: MaybeRefOrGetter<number>;
  1992. multiple?: MaybeRefOrGetter<Multiple>;
  1993. /** @deprecated Please use `scheduler` option instead */
  1994. immediate?: boolean;
  1995. /** @deprecated Please use `scheduler` option instead */
  1996. interval?: 'requestAnimationFrame' | number;
  1997. }
  1998. interface UseElementByPointReturn<Multiple extends boolean = false> extends Supportable, Pausable {
  1999. element: ShallowRef<Multiple extends true ? HTMLElement[] : HTMLElement | null>;
  2000. }
  2001. /**
  2002. * Reactive element by point.
  2003. *
  2004. * @see https://vueuse.org/useElementByPoint
  2005. * @param options - UseElementByPointOptions
  2006. */
  2007. declare function useElementByPoint<M extends boolean = false>(options: UseElementByPointOptions<M>): UseElementByPointReturn<M>;
  2008. //#endregion
  2009. //#region useElementHover/index.d.ts
  2010. interface UseElementHoverOptions extends ConfigurableWindow {
  2011. delayEnter?: number;
  2012. delayLeave?: number;
  2013. triggerOnRemoval?: boolean;
  2014. }
  2015. declare function useElementHover(el: MaybeRefOrGetter<EventTarget | null | undefined>, options?: UseElementHoverOptions): ShallowRef<boolean>;
  2016. //#endregion
  2017. //#region useResizeObserver/index.d.ts
  2018. /**
  2019. * @deprecated This interface is now available in the DOM lib.
  2020. * Use the global {@link globalThis.ResizeObserverSize} instead.
  2021. */
  2022. interface ResizeObserverSize {
  2023. readonly inlineSize: number;
  2024. readonly blockSize: number;
  2025. }
  2026. /**
  2027. * @deprecated This interface is now available in the DOM lib.
  2028. * Use the global {@link globalThis.ResizeObserverEntry} instead.
  2029. */
  2030. interface ResizeObserverEntry {
  2031. readonly target: Element;
  2032. readonly contentRect: DOMRectReadOnly;
  2033. readonly borderBoxSize: ReadonlyArray<ResizeObserverSize>;
  2034. readonly contentBoxSize: ReadonlyArray<ResizeObserverSize>;
  2035. readonly devicePixelContentBoxSize: ReadonlyArray<ResizeObserverSize>;
  2036. }
  2037. /**
  2038. * @deprecated This interface is now available in the DOM lib.
  2039. * Use the global {@link globalThis.ResizeObserverCallback} instead.
  2040. */
  2041. type ResizeObserverCallback = (entries: ReadonlyArray<ResizeObserverEntry>, observer: ResizeObserver) => void;
  2042. interface UseResizeObserverOptions extends ResizeObserverOptions, ConfigurableWindow {}
  2043. interface UseResizeObserverReturn extends Supportable {
  2044. stop: () => void;
  2045. }
  2046. /**
  2047. * Reports changes to the dimensions of an Element's content or the border-box
  2048. *
  2049. * @see https://vueuse.org/useResizeObserver
  2050. * @param target
  2051. * @param callback
  2052. * @param options
  2053. */
  2054. declare function useResizeObserver(target: MaybeComputedElementRef | MaybeComputedElementRef[] | MaybeRefOrGetter<MaybeElement[]>, callback: globalThis.ResizeObserverCallback, options?: UseResizeObserverOptions): UseResizeObserverReturn;
  2055. //#endregion
  2056. //#region useElementSize/index.d.ts
  2057. interface ElementSize {
  2058. width: number;
  2059. height: number;
  2060. }
  2061. interface UseElementSizeOptions extends UseResizeObserverOptions {}
  2062. interface UseElementSizeReturn {
  2063. width: ShallowRef<number>;
  2064. height: ShallowRef<number>;
  2065. stop: () => void;
  2066. }
  2067. /**
  2068. * Reactive size of an HTML element.
  2069. *
  2070. * @see https://vueuse.org/useElementSize
  2071. */
  2072. declare function useElementSize(target: MaybeComputedElementRef, initialSize?: ElementSize, options?: UseElementSizeOptions): UseElementSizeReturn;
  2073. //#endregion
  2074. //#region useIntersectionObserver/index.d.ts
  2075. interface UseIntersectionObserverOptions extends ConfigurableWindow {
  2076. /**
  2077. * Start the IntersectionObserver immediately on creation
  2078. *
  2079. * @default true
  2080. */
  2081. immediate?: boolean;
  2082. /**
  2083. * The Element or Document whose bounds are used as the bounding box when testing for intersection.
  2084. */
  2085. root?: MaybeComputedElementRef | Document;
  2086. /**
  2087. * A string which specifies a set of offsets to add to the root's bounding_box when calculating intersections.
  2088. */
  2089. rootMargin?: MaybeRefOrGetter<string>;
  2090. /**
  2091. * Either a single number or an array of numbers between 0.0 and 1.
  2092. * @default 0
  2093. */
  2094. threshold?: number | number[];
  2095. }
  2096. interface UseIntersectionObserverReturn extends Supportable, Pausable {
  2097. stop: () => void;
  2098. }
  2099. /**
  2100. * Detects changes to a target element's visibility.
  2101. *
  2102. * @see https://vueuse.org/useIntersectionObserver
  2103. * @param target
  2104. * @param callback
  2105. * @param options
  2106. */
  2107. declare function useIntersectionObserver(target: MaybeComputedElementRef | MaybeRefOrGetter<MaybeElement[]> | MaybeComputedElementRef[], callback: IntersectionObserverCallback, options?: UseIntersectionObserverOptions): UseIntersectionObserverReturn;
  2108. //#endregion
  2109. //#region useElementVisibility/index.d.ts
  2110. interface UseElementVisibilityOptions<Controls extends boolean = false> extends ConfigurableWindow, Pick<UseIntersectionObserverOptions, 'rootMargin' | 'threshold'> {
  2111. /**
  2112. * Initial value.
  2113. *
  2114. * @default false
  2115. */
  2116. initialValue?: boolean;
  2117. /**
  2118. * The element that is used as the viewport for checking visibility of the target.
  2119. */
  2120. scrollTarget?: UseIntersectionObserverOptions['root'];
  2121. /**
  2122. * Stop tracking when element visibility changes for the first time
  2123. *
  2124. * @default false
  2125. */
  2126. once?: boolean;
  2127. /**
  2128. * Expose more controls
  2129. *
  2130. * @default false
  2131. */
  2132. controls?: Controls;
  2133. }
  2134. type UseElementVisibilityReturn<Controls extends boolean = false> = Controls extends true ? UseElementVisibilityReturnWithControls : ShallowRef<boolean>;
  2135. interface UseElementVisibilityReturnWithControls extends UseIntersectionObserverReturn {
  2136. isVisible: ShallowRef<boolean>;
  2137. }
  2138. /**
  2139. * Tracks the visibility of an element within the viewport.
  2140. *
  2141. * @see https://vueuse.org/useElementVisibility
  2142. */
  2143. declare function useElementVisibility(element: MaybeComputedElementRef, options?: UseElementVisibilityOptions<false>): UseElementVisibilityReturn<false>;
  2144. declare function useElementVisibility(element: MaybeComputedElementRef, options?: UseElementVisibilityOptions<true>): UseElementVisibilityReturn<true>;
  2145. //#endregion
  2146. //#region useEventBus/index.d.ts
  2147. type EventBusListener<T = unknown, P = any> = (event: T, payload?: P) => void;
  2148. type EventBusEvents<T, P = any> = Set<EventBusListener<T, P>>;
  2149. interface EventBusKey<T> extends Symbol {}
  2150. type EventBusIdentifier<T = unknown> = EventBusKey<T> | string | number;
  2151. interface UseEventBusReturn<T, P> {
  2152. /**
  2153. * Subscribe to an event. When calling emit, the listeners will execute.
  2154. * @param listener watch listener.
  2155. * @returns a stop function to remove the current callback.
  2156. */
  2157. on: (listener: EventBusListener<T, P>) => Fn;
  2158. /**
  2159. * Similar to `on`, but only fires once
  2160. * @param listener watch listener.
  2161. * @returns a stop function to remove the current callback.
  2162. */
  2163. once: (listener: EventBusListener<T, P>) => Fn;
  2164. /**
  2165. * Emit an event, the corresponding event listeners will execute.
  2166. * @param event data sent.
  2167. */
  2168. emit: (event?: T, payload?: P) => void;
  2169. /**
  2170. * Remove the corresponding listener.
  2171. * @param listener watch listener.
  2172. */
  2173. off: (listener: EventBusListener<T>) => void;
  2174. /**
  2175. * Clear all events
  2176. */
  2177. reset: () => void;
  2178. }
  2179. declare function useEventBus<T = unknown, P = any>(key: EventBusIdentifier<T>): UseEventBusReturn<T, P>;
  2180. //#endregion
  2181. //#region useEventListener/index.d.ts
  2182. interface InferEventTarget<Events> {
  2183. addEventListener: (event: Events, fn?: any, options?: any) => any;
  2184. removeEventListener: (event: Events, fn?: any, options?: any) => any;
  2185. }
  2186. type WindowEventName = keyof WindowEventMap;
  2187. type DocumentEventName = keyof DocumentEventMap;
  2188. type ShadowRootEventName = keyof ShadowRootEventMap;
  2189. interface GeneralEventListener<E = Event> {
  2190. (evt: E): void;
  2191. }
  2192. /**
  2193. * Register using addEventListener on mounted, and removeEventListener automatically on unmounted.
  2194. *
  2195. * Overload 1: Omitted Window target
  2196. *
  2197. * @see https://vueuse.org/useEventListener
  2198. */
  2199. declare function useEventListener<E extends keyof WindowEventMap>(event: MaybeRefOrGetter<Arrayable<E>>, listener: MaybeRef<Arrayable<(this: Window, ev: WindowEventMap[E]) => any>>, options?: MaybeRefOrGetter<boolean | AddEventListenerOptions>): Fn;
  2200. /**
  2201. * Register using addEventListener on mounted, and removeEventListener automatically on unmounted.
  2202. *
  2203. * Overload 2: Explicitly Window target
  2204. *
  2205. * @see https://vueuse.org/useEventListener
  2206. * @param target
  2207. * @param event
  2208. * @param listener
  2209. * @param options
  2210. */
  2211. declare function useEventListener<E extends keyof WindowEventMap>(target: Window, event: MaybeRefOrGetter<Arrayable<E>>, listener: MaybeRef<Arrayable<(this: Window, ev: WindowEventMap[E]) => any>>, options?: MaybeRefOrGetter<boolean | AddEventListenerOptions>): Fn;
  2212. /**
  2213. * Register using addEventListener on mounted, and removeEventListener automatically on unmounted.
  2214. *
  2215. * Overload 3: Explicitly Document target
  2216. *
  2217. * @see https://vueuse.org/useEventListener
  2218. */
  2219. declare function useEventListener<E extends keyof DocumentEventMap>(target: Document, event: MaybeRefOrGetter<Arrayable<E>>, listener: MaybeRef<Arrayable<(this: Document, ev: DocumentEventMap[E]) => any>>, options?: MaybeRefOrGetter<boolean | AddEventListenerOptions>): Fn;
  2220. /**
  2221. * Register using addEventListener on mounted, and removeEventListener automatically on unmounted.
  2222. *
  2223. * Overload 4: Explicitly ShadowRoot target
  2224. *
  2225. * @see https://vueuse.org/useEventListener
  2226. */
  2227. declare function useEventListener<E extends keyof ShadowRootEventMap>(target: MaybeRefOrGetter<Arrayable<ShadowRoot> | null | undefined>, event: MaybeRefOrGetter<Arrayable<E>>, listener: MaybeRef<Arrayable<(this: ShadowRoot, ev: ShadowRootEventMap[E]) => any>>, options?: MaybeRefOrGetter<boolean | AddEventListenerOptions>): Fn;
  2228. /**
  2229. * Register using addEventListener on mounted, and removeEventListener automatically on unmounted.
  2230. *
  2231. * Overload 5: Explicitly HTMLElement target
  2232. *
  2233. * @see https://vueuse.org/useEventListener
  2234. */
  2235. declare function useEventListener<E extends keyof HTMLElementEventMap>(target: MaybeRefOrGetter<Arrayable<HTMLElement> | null | undefined>, event: MaybeRefOrGetter<Arrayable<E>>, listener: MaybeRef<(this: HTMLElement, ev: HTMLElementEventMap[E]) => any>, options?: MaybeRefOrGetter<boolean | AddEventListenerOptions>): Fn;
  2236. /**
  2237. * Register using addEventListener on mounted, and removeEventListener automatically on unmounted.
  2238. *
  2239. * Overload 6: Custom event target with event type infer
  2240. *
  2241. * @see https://vueuse.org/useEventListener
  2242. */
  2243. declare function useEventListener<Names extends string, EventType = Event>(target: MaybeRefOrGetter<Arrayable<InferEventTarget<Names>> | null | undefined>, event: MaybeRefOrGetter<Arrayable<Names>>, listener: MaybeRef<Arrayable<GeneralEventListener<EventType>>>, options?: MaybeRefOrGetter<boolean | AddEventListenerOptions>): Fn;
  2244. /**
  2245. * Register using addEventListener on mounted, and removeEventListener automatically on unmounted.
  2246. *
  2247. * Overload 7: Custom event target fallback
  2248. *
  2249. * @see https://vueuse.org/useEventListener
  2250. */
  2251. declare function useEventListener<EventType = Event>(target: MaybeRefOrGetter<Arrayable<EventTarget> | null | undefined>, event: MaybeRefOrGetter<Arrayable<string>>, listener: MaybeRef<Arrayable<GeneralEventListener<EventType>>>, options?: MaybeRefOrGetter<boolean | AddEventListenerOptions>): Fn;
  2252. //#endregion
  2253. //#region useEventSource/index.d.ts
  2254. type EventSourceStatus = 'CONNECTING' | 'OPEN' | 'CLOSED';
  2255. interface UseEventSourceOptions<Data> extends EventSourceInit {
  2256. /**
  2257. * Enabled auto reconnect
  2258. *
  2259. * @default false
  2260. */
  2261. autoReconnect?: boolean | {
  2262. /**
  2263. * Maximum retry times.
  2264. *
  2265. * Or you can pass a predicate function (which returns true if you want to retry).
  2266. *
  2267. * @default -1
  2268. */
  2269. retries?: number | (() => boolean);
  2270. /**
  2271. * Delay for reconnect, in milliseconds
  2272. *
  2273. * @default 1000
  2274. */
  2275. delay?: number;
  2276. /**
  2277. * On maximum retry times reached.
  2278. */
  2279. onFailed?: Fn;
  2280. };
  2281. /**
  2282. * Immediately open the connection when calling this composable
  2283. *
  2284. * @default true
  2285. */
  2286. immediate?: boolean;
  2287. /**
  2288. * Automatically connect to the websocket when URL changes
  2289. *
  2290. * @default true
  2291. */
  2292. autoConnect?: boolean;
  2293. /**
  2294. * Custom data serialization
  2295. */
  2296. serializer?: {
  2297. read: (v?: string) => Data;
  2298. };
  2299. }
  2300. interface UseEventSourceReturn<Events extends string[], Data = any> {
  2301. /**
  2302. * Reference to the latest data received via the EventSource,
  2303. * can be watched to respond to incoming messages
  2304. */
  2305. data: ShallowRef<Data | null>;
  2306. /**
  2307. * The current state of the connection, can be only one of:
  2308. * 'CONNECTING', 'OPEN' 'CLOSED'
  2309. */
  2310. status: ShallowRef<EventSourceStatus>;
  2311. /**
  2312. * The latest named event
  2313. */
  2314. event: ShallowRef<Events[number] | null>;
  2315. /**
  2316. * The current error
  2317. */
  2318. error: ShallowRef<Event | null>;
  2319. /**
  2320. * Closes the EventSource connection gracefully.
  2321. */
  2322. close: EventSource['close'];
  2323. /**
  2324. * Reopen the EventSource connection.
  2325. * If there the current one is active, will close it before opening a new one.
  2326. */
  2327. open: Fn;
  2328. /**
  2329. * Reference to the current EventSource instance.
  2330. */
  2331. eventSource: ShallowRef<EventSource | null>;
  2332. /**
  2333. * The last event ID string, for server-sent events.
  2334. * @see https://developer.mozilla.org/en-US/docs/Web/API/MessageEvent/lastEventId
  2335. */
  2336. lastEventId: ShallowRef<string | null>;
  2337. }
  2338. /**
  2339. * Reactive wrapper for EventSource.
  2340. *
  2341. * @see https://vueuse.org/useEventSource
  2342. * @see https://developer.mozilla.org/en-US/docs/Web/API/EventSource/EventSource EventSource
  2343. * @param url
  2344. * @param events
  2345. * @param options
  2346. */
  2347. declare function useEventSource<Events extends string[], Data = any>(url: MaybeRefOrGetter<string | URL | undefined>, events?: Events, options?: UseEventSourceOptions<Data>): UseEventSourceReturn<Events, Data>;
  2348. //#endregion
  2349. //#region useEyeDropper/index.d.ts
  2350. interface EyeDropperOpenOptions {
  2351. /**
  2352. * @see https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal
  2353. */
  2354. signal?: AbortSignal;
  2355. }
  2356. interface EyeDropper {
  2357. new (): EyeDropper;
  2358. open: (options?: EyeDropperOpenOptions) => Promise<{
  2359. sRGBHex: string;
  2360. }>;
  2361. [Symbol.toStringTag]: 'EyeDropper';
  2362. }
  2363. interface UseEyeDropperOptions {
  2364. /**
  2365. * Initial sRGBHex.
  2366. *
  2367. * @default ''
  2368. */
  2369. initialValue?: string;
  2370. }
  2371. interface UseEyeDropperReturn extends Supportable {
  2372. sRGBHex: ShallowRef<string>;
  2373. open: (openOptions?: EyeDropperOpenOptions) => Promise<{
  2374. sRGBHex: string;
  2375. } | undefined>;
  2376. }
  2377. /**
  2378. * Reactive [EyeDropper API](https://developer.mozilla.org/en-US/docs/Web/API/EyeDropper_API)
  2379. *
  2380. * @see https://vueuse.org/useEyeDropper
  2381. *
  2382. * @__NO_SIDE_EFFECTS__
  2383. */
  2384. declare function useEyeDropper(options?: UseEyeDropperOptions): UseEyeDropperReturn;
  2385. //#endregion
  2386. //#region useFavicon/index.d.ts
  2387. interface UseFaviconOptions extends ConfigurableDocument {
  2388. baseUrl?: string;
  2389. rel?: string;
  2390. }
  2391. type UseFaviconReturn = ComputedRef<string | null | undefined> | Ref<string | null | undefined>;
  2392. /**
  2393. * Reactive favicon.
  2394. *
  2395. * @see https://vueuse.org/useFavicon
  2396. * @param newIcon
  2397. * @param options
  2398. */
  2399. declare function useFavicon(newIcon: ReadonlyRefOrGetter<string | null | undefined>, options?: UseFaviconOptions): ComputedRef<string | null | undefined>;
  2400. declare function useFavicon(newIcon?: MaybeRef<string | null | undefined>, options?: UseFaviconOptions): Ref<string | null | undefined>;
  2401. //#endregion
  2402. //#region useFetch/index.d.ts
  2403. interface UseFetchReturn<T> {
  2404. /**
  2405. * Indicates if the fetch request has finished
  2406. */
  2407. isFinished: Readonly<ShallowRef<boolean>>;
  2408. /**
  2409. * The statusCode of the HTTP fetch response
  2410. */
  2411. statusCode: ShallowRef<number | null>;
  2412. /**
  2413. * The raw response of the fetch response
  2414. */
  2415. response: ShallowRef<Response | null>;
  2416. /**
  2417. * Any fetch errors that may have occurred
  2418. */
  2419. error: ShallowRef<any>;
  2420. /**
  2421. * The fetch response body on success, may either be JSON or text
  2422. */
  2423. data: ShallowRef<T | null>;
  2424. /**
  2425. * Indicates if the request is currently being fetched.
  2426. */
  2427. isFetching: Readonly<ShallowRef<boolean>>;
  2428. /**
  2429. * Indicates if the fetch request is able to be aborted
  2430. */
  2431. canAbort: ComputedRef<boolean>;
  2432. /**
  2433. * Indicates if the fetch request was aborted
  2434. */
  2435. aborted: ShallowRef<boolean>;
  2436. /**
  2437. * Abort the fetch request
  2438. */
  2439. abort: (reason?: any) => void;
  2440. /**
  2441. * Manually call the fetch
  2442. * (default not throwing error)
  2443. */
  2444. execute: (throwOnFailed?: boolean) => Promise<any>;
  2445. /**
  2446. * Fires after the fetch request has finished
  2447. */
  2448. onFetchResponse: EventHookOn<Response>;
  2449. /**
  2450. * Fires after a fetch request error
  2451. */
  2452. onFetchError: EventHookOn;
  2453. /**
  2454. * Fires after a fetch has completed
  2455. */
  2456. onFetchFinally: EventHookOn;
  2457. get: () => UseFetchReturn<T> & PromiseLike<UseFetchReturn<T>>;
  2458. post: (payload?: MaybeRefOrGetter<unknown>, type?: string) => UseFetchReturn<T> & PromiseLike<UseFetchReturn<T>>;
  2459. put: (payload?: MaybeRefOrGetter<unknown>, type?: string) => UseFetchReturn<T> & PromiseLike<UseFetchReturn<T>>;
  2460. delete: (payload?: MaybeRefOrGetter<unknown>, type?: string) => UseFetchReturn<T> & PromiseLike<UseFetchReturn<T>>;
  2461. patch: (payload?: MaybeRefOrGetter<unknown>, type?: string) => UseFetchReturn<T> & PromiseLike<UseFetchReturn<T>>;
  2462. head: (payload?: MaybeRefOrGetter<unknown>, type?: string) => UseFetchReturn<T> & PromiseLike<UseFetchReturn<T>>;
  2463. options: (payload?: MaybeRefOrGetter<unknown>, type?: string) => UseFetchReturn<T> & PromiseLike<UseFetchReturn<T>>;
  2464. json: <JSON = any>() => UseFetchReturn<JSON> & PromiseLike<UseFetchReturn<JSON>>;
  2465. text: () => UseFetchReturn<string> & PromiseLike<UseFetchReturn<string>>;
  2466. blob: () => UseFetchReturn<Blob> & PromiseLike<UseFetchReturn<Blob>>;
  2467. arrayBuffer: () => UseFetchReturn<ArrayBuffer> & PromiseLike<UseFetchReturn<ArrayBuffer>>;
  2468. formData: () => UseFetchReturn<FormData> & PromiseLike<UseFetchReturn<FormData>>;
  2469. }
  2470. type Combination = 'overwrite' | 'chain';
  2471. interface BeforeFetchContext {
  2472. /**
  2473. * The computed url of the current request
  2474. */
  2475. url: string;
  2476. /**
  2477. * The request options of the current request
  2478. */
  2479. options: RequestInit;
  2480. /**
  2481. * Cancels the current request
  2482. */
  2483. cancel: Fn;
  2484. }
  2485. interface AfterFetchContext<T = any> {
  2486. response: Response;
  2487. data: T | null;
  2488. context: BeforeFetchContext;
  2489. execute: (throwOnFailed?: boolean) => Promise<any>;
  2490. }
  2491. interface OnFetchErrorContext<T = any, E = any> {
  2492. error: E;
  2493. data: T | null;
  2494. response: Response | null;
  2495. context: BeforeFetchContext;
  2496. execute: (throwOnFailed?: boolean) => Promise<any>;
  2497. }
  2498. interface UseFetchOptions {
  2499. /**
  2500. * Fetch function
  2501. */
  2502. fetch?: typeof window.fetch;
  2503. /**
  2504. * Will automatically run fetch when `useFetch` is used
  2505. *
  2506. * @default true
  2507. */
  2508. immediate?: boolean;
  2509. /**
  2510. * Will automatically refetch when:
  2511. * - the URL is changed if the URL is a ref
  2512. * - the payload is changed if the payload is a ref
  2513. *
  2514. * @default false
  2515. */
  2516. refetch?: MaybeRefOrGetter<boolean>;
  2517. /**
  2518. * Initial data before the request finished
  2519. *
  2520. * @default null
  2521. */
  2522. initialData?: any;
  2523. /**
  2524. * Timeout for abort request after number of millisecond
  2525. * `0` means use browser default
  2526. *
  2527. * @default 0
  2528. */
  2529. timeout?: number;
  2530. /**
  2531. * Allow update the `data` ref when fetch error whenever provided, or mutated in the `onFetchError` callback
  2532. *
  2533. * @default false
  2534. */
  2535. updateDataOnError?: boolean;
  2536. /**
  2537. * Will run immediately before the fetch request is dispatched
  2538. */
  2539. beforeFetch?: (ctx: BeforeFetchContext) => Promise<Partial<BeforeFetchContext> | void> | Partial<BeforeFetchContext> | void;
  2540. /**
  2541. * Will run immediately after the fetch request is returned.
  2542. * Runs after any 2xx response
  2543. */
  2544. afterFetch?: (ctx: AfterFetchContext) => Promise<Partial<AfterFetchContext>> | Partial<AfterFetchContext>;
  2545. /**
  2546. * Will run immediately after the fetch request is returned.
  2547. * Runs after any 4xx and 5xx response
  2548. */
  2549. onFetchError?: (ctx: OnFetchErrorContext) => Promise<Partial<OnFetchErrorContext>> | Partial<OnFetchErrorContext>;
  2550. }
  2551. interface CreateFetchOptions {
  2552. /**
  2553. * The base URL that will be prefixed to all urls unless urls are absolute
  2554. */
  2555. baseUrl?: MaybeRefOrGetter<string>;
  2556. /**
  2557. * Determine the inherit behavior for beforeFetch, afterFetch, onFetchError
  2558. * @default 'chain'
  2559. */
  2560. combination?: Combination;
  2561. /**
  2562. * Default Options for the useFetch function
  2563. */
  2564. options?: UseFetchOptions;
  2565. /**
  2566. * Options for the fetch request
  2567. */
  2568. fetchOptions?: RequestInit;
  2569. }
  2570. declare function createFetch(config?: CreateFetchOptions): typeof useFetch;
  2571. declare function useFetch<T>(url: MaybeRefOrGetter<string>): UseFetchReturn<T> & PromiseLike<UseFetchReturn<T>>;
  2572. declare function useFetch<T>(url: MaybeRefOrGetter<string>, useFetchOptions: UseFetchOptions): UseFetchReturn<T> & PromiseLike<UseFetchReturn<T>>;
  2573. declare function useFetch<T>(url: MaybeRefOrGetter<string>, options: RequestInit, useFetchOptions?: UseFetchOptions): UseFetchReturn<T> & PromiseLike<UseFetchReturn<T>>;
  2574. //#endregion
  2575. //#region useFileDialog/index.d.ts
  2576. interface UseFileDialogOptions extends ConfigurableDocument {
  2577. /**
  2578. * @default true
  2579. */
  2580. multiple?: MaybeRef<boolean>;
  2581. /**
  2582. * @default '*'
  2583. */
  2584. accept?: MaybeRef<string>;
  2585. /**
  2586. * Select the input source for the capture file.
  2587. * @see [HTMLInputElement Capture](https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/capture)
  2588. */
  2589. capture?: MaybeRef<string>;
  2590. /**
  2591. * Reset when open file dialog.
  2592. * @default false
  2593. */
  2594. reset?: MaybeRef<boolean>;
  2595. /**
  2596. * Select directories instead of files.
  2597. * @see [HTMLInputElement webkitdirectory](https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement/webkitdirectory)
  2598. * @default false
  2599. */
  2600. directory?: MaybeRef<boolean>;
  2601. /**
  2602. * Initial files to set.
  2603. * @default null
  2604. */
  2605. initialFiles?: Array<File> | FileList;
  2606. /**
  2607. * The input element to use for file dialog.
  2608. * @default document.createElement('input')
  2609. */
  2610. input?: MaybeElementRef<HTMLInputElement>;
  2611. }
  2612. interface UseFileDialogReturn {
  2613. files: Ref<FileList | null>;
  2614. open: (localOptions?: Partial<UseFileDialogOptions>) => void;
  2615. reset: () => void;
  2616. onChange: EventHookOn<FileList | null>;
  2617. onCancel: EventHookOn;
  2618. }
  2619. /**
  2620. * Open file dialog with ease.
  2621. *
  2622. * @see https://vueuse.org/useFileDialog
  2623. * @param options
  2624. */
  2625. declare function useFileDialog(options?: UseFileDialogOptions): UseFileDialogReturn;
  2626. //#endregion
  2627. //#region useFileSystemAccess/index.d.ts
  2628. /**
  2629. * window.showOpenFilePicker parameters
  2630. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/showOpenFilePicker#parameters
  2631. */
  2632. interface FileSystemAccessShowOpenFileOptions {
  2633. multiple?: boolean;
  2634. types?: Array<{
  2635. description?: string;
  2636. accept: Record<string, string[]>;
  2637. }>;
  2638. excludeAcceptAllOption?: boolean;
  2639. }
  2640. /**
  2641. * window.showSaveFilePicker parameters
  2642. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/showSaveFilePicker#parameters
  2643. */
  2644. interface FileSystemAccessShowSaveFileOptions {
  2645. suggestedName?: string;
  2646. types?: Array<{
  2647. description?: string;
  2648. accept: Record<string, string[]>;
  2649. }>;
  2650. excludeAcceptAllOption?: boolean;
  2651. }
  2652. /**
  2653. * FileHandle
  2654. * @see https://developer.mozilla.org/en-US/docs/Web/API/FileSystemFileHandle
  2655. */
  2656. interface FileSystemFileHandle {
  2657. getFile: () => Promise<File>;
  2658. createWritable: () => FileSystemWritableFileStream;
  2659. }
  2660. /**
  2661. * @see https://developer.mozilla.org/en-US/docs/Web/API/FileSystemWritableFileStream
  2662. */
  2663. interface FileSystemWritableFileStream extends WritableStream {
  2664. /**
  2665. * @see https://developer.mozilla.org/en-US/docs/Web/API/FileSystemWritableFileStream/write
  2666. */
  2667. write: FileSystemWritableFileStreamWrite;
  2668. /**
  2669. * @see https://developer.mozilla.org/en-US/docs/Web/API/FileSystemWritableFileStream/seek
  2670. */
  2671. seek: (position: number) => Promise<void>;
  2672. /**
  2673. * @see https://developer.mozilla.org/en-US/docs/Web/API/FileSystemWritableFileStream/truncate
  2674. */
  2675. truncate: (size: number) => Promise<void>;
  2676. }
  2677. /**
  2678. * FileStream.write
  2679. * @see https://developer.mozilla.org/en-US/docs/Web/API/FileSystemWritableFileStream/write
  2680. */
  2681. interface FileSystemWritableFileStreamWrite {
  2682. (data: string | BufferSource | Blob): Promise<void>;
  2683. (options: {
  2684. type: 'write';
  2685. position: number;
  2686. data: string | BufferSource | Blob;
  2687. }): Promise<void>;
  2688. (options: {
  2689. type: 'seek';
  2690. position: number;
  2691. }): Promise<void>;
  2692. (options: {
  2693. type: 'truncate';
  2694. size: number;
  2695. }): Promise<void>;
  2696. }
  2697. /**
  2698. * FileStream.write
  2699. * @see https://developer.mozilla.org/en-US/docs/Web/API/FileSystemWritableFileStream/write
  2700. */
  2701. type FileSystemAccessWindow = Window & {
  2702. showSaveFilePicker: (options: FileSystemAccessShowSaveFileOptions) => Promise<FileSystemFileHandle>;
  2703. showOpenFilePicker: (options: FileSystemAccessShowOpenFileOptions) => Promise<FileSystemFileHandle[]>;
  2704. };
  2705. type UseFileSystemAccessCommonOptions = Pick<FileSystemAccessShowOpenFileOptions, 'types' | 'excludeAcceptAllOption'>;
  2706. type UseFileSystemAccessShowSaveFileOptions = Pick<FileSystemAccessShowSaveFileOptions, 'suggestedName'>;
  2707. type UseFileSystemAccessOptions = ConfigurableWindow & UseFileSystemAccessCommonOptions & {
  2708. /**
  2709. * file data type
  2710. */
  2711. dataType?: MaybeRefOrGetter<'Text' | 'ArrayBuffer' | 'Blob'>;
  2712. };
  2713. /**
  2714. * Create and read and write local files.
  2715. * @see https://vueuse.org/useFileSystemAccess
  2716. */
  2717. declare function useFileSystemAccess(): UseFileSystemAccessReturn<string | ArrayBuffer | Blob>;
  2718. declare function useFileSystemAccess(options: UseFileSystemAccessOptions & {
  2719. dataType: 'Text';
  2720. }): UseFileSystemAccessReturn<string>;
  2721. declare function useFileSystemAccess(options: UseFileSystemAccessOptions & {
  2722. dataType: 'ArrayBuffer';
  2723. }): UseFileSystemAccessReturn<ArrayBuffer>;
  2724. declare function useFileSystemAccess(options: UseFileSystemAccessOptions & {
  2725. dataType: 'Blob';
  2726. }): UseFileSystemAccessReturn<Blob>;
  2727. declare function useFileSystemAccess(options: UseFileSystemAccessOptions): UseFileSystemAccessReturn<string | ArrayBuffer | Blob>;
  2728. interface UseFileSystemAccessReturn<T = string> extends Supportable {
  2729. data: ShallowRef<T | undefined>;
  2730. file: ShallowRef<File | undefined>;
  2731. fileName: ComputedRef<string>;
  2732. fileMIME: ComputedRef<string>;
  2733. fileSize: ComputedRef<number>;
  2734. fileLastModified: ComputedRef<number>;
  2735. open: (_options?: UseFileSystemAccessCommonOptions) => Awaitable<void>;
  2736. create: (_options?: UseFileSystemAccessShowSaveFileOptions) => Awaitable<void>;
  2737. save: (_options?: UseFileSystemAccessShowSaveFileOptions) => Awaitable<void>;
  2738. saveAs: (_options?: UseFileSystemAccessShowSaveFileOptions) => Awaitable<void>;
  2739. updateData: () => Awaitable<void>;
  2740. }
  2741. //#endregion
  2742. //#region useFocus/index.d.ts
  2743. interface UseFocusOptions extends ConfigurableWindow {
  2744. /**
  2745. * Initial value. If set true, then focus will be set on the target
  2746. *
  2747. * @default false
  2748. */
  2749. initialValue?: boolean;
  2750. /**
  2751. * Replicate the :focus-visible behavior of CSS
  2752. *
  2753. * @default false
  2754. */
  2755. focusVisible?: boolean;
  2756. /**
  2757. * Prevent scrolling to the element when it is focused.
  2758. *
  2759. * @default false
  2760. */
  2761. preventScroll?: boolean;
  2762. }
  2763. interface UseFocusReturn {
  2764. /**
  2765. * If read as true, then the element has focus. If read as false, then the element does not have focus
  2766. * If set to true, then the element will be focused. If set to false, the element will be blurred.
  2767. */
  2768. focused: WritableComputedRef<boolean>;
  2769. }
  2770. /**
  2771. * Track or set the focus state of a DOM element.
  2772. *
  2773. * @see https://vueuse.org/useFocus
  2774. * @param target The target element for the focus and blur events.
  2775. * @param options
  2776. */
  2777. declare function useFocus(target: MaybeElementRef, options?: UseFocusOptions): UseFocusReturn;
  2778. //#endregion
  2779. //#region useFocusWithin/index.d.ts
  2780. interface UseFocusWithinReturn {
  2781. /**
  2782. * True if the element or any of its descendants are focused
  2783. */
  2784. focused: ComputedRef<boolean>;
  2785. }
  2786. /**
  2787. * Track if focus is contained within the target element
  2788. *
  2789. * @see https://vueuse.org/useFocusWithin
  2790. * @param target The target element to track
  2791. * @param options Focus within options
  2792. */
  2793. declare function useFocusWithin(target: MaybeElementRef, options?: ConfigurableWindow): UseFocusWithinReturn;
  2794. //#endregion
  2795. //#region useFps/index.d.ts
  2796. interface UseFpsOptions {
  2797. /**
  2798. * Calculate the FPS on every x frames.
  2799. * @default 10
  2800. */
  2801. every?: number;
  2802. }
  2803. declare function useFps(options?: UseFpsOptions): ShallowRef<number>;
  2804. //#endregion
  2805. //#region useFullscreen/index.d.ts
  2806. interface UseFullscreenOptions extends ConfigurableDocument {
  2807. /**
  2808. * Automatically exit fullscreen when component is unmounted
  2809. *
  2810. * @default false
  2811. */
  2812. autoExit?: boolean;
  2813. }
  2814. interface UseFullscreenReturn extends Supportable {
  2815. isFullscreen: ShallowRef<boolean>;
  2816. enter: () => Promise<void>;
  2817. exit: () => Promise<void>;
  2818. toggle: () => Promise<void>;
  2819. }
  2820. /**
  2821. * Reactive Fullscreen API.
  2822. *
  2823. * @see https://vueuse.org/useFullscreen
  2824. * @param target
  2825. * @param options
  2826. */
  2827. declare function useFullscreen(target?: MaybeElementRef, options?: UseFullscreenOptions): UseFullscreenReturn;
  2828. //#endregion
  2829. //#region useGamepad/index.d.ts
  2830. interface UseGamepadOptions extends ConfigurableWindow, ConfigurableNavigator {}
  2831. interface UseGamepadReturn extends Supportable, Pausable {
  2832. onConnected: EventHookOn<number>;
  2833. onDisconnected: EventHookOn<number>;
  2834. gamepads: Ref<Gamepad[]>;
  2835. }
  2836. /**
  2837. * Maps a standard standard gamepad to an Xbox 360 Controller.
  2838. */
  2839. declare function mapGamepadToXbox360Controller(gamepad: Ref<Gamepad | undefined>): _$vue.ComputedRef<{
  2840. buttons: {
  2841. a: GamepadButton;
  2842. b: GamepadButton;
  2843. x: GamepadButton;
  2844. y: GamepadButton;
  2845. };
  2846. bumper: {
  2847. left: GamepadButton;
  2848. right: GamepadButton;
  2849. };
  2850. triggers: {
  2851. left: GamepadButton;
  2852. right: GamepadButton;
  2853. };
  2854. stick: {
  2855. left: {
  2856. horizontal: number;
  2857. vertical: number;
  2858. button: GamepadButton;
  2859. };
  2860. right: {
  2861. horizontal: number;
  2862. vertical: number;
  2863. button: GamepadButton;
  2864. };
  2865. };
  2866. dpad: {
  2867. up: GamepadButton;
  2868. down: GamepadButton;
  2869. left: GamepadButton;
  2870. right: GamepadButton;
  2871. };
  2872. back: GamepadButton;
  2873. start: GamepadButton;
  2874. } | null>;
  2875. declare function useGamepad(options?: UseGamepadOptions): UseGamepadReturn;
  2876. //#endregion
  2877. //#region useGeolocation/index.d.ts
  2878. interface UseGeolocationOptions extends Partial<PositionOptions>, ConfigurableNavigator {
  2879. immediate?: boolean;
  2880. }
  2881. interface UseGeolocationReturn extends Supportable {
  2882. coords: ShallowRef<Omit<GeolocationPosition['coords'], 'toJSON'>>;
  2883. locatedAt: ShallowRef<number | null>;
  2884. error: ShallowRef<GeolocationPositionError | null>;
  2885. resume: () => void;
  2886. pause: () => void;
  2887. }
  2888. /**
  2889. * Reactive Geolocation API.
  2890. *
  2891. * @see https://vueuse.org/useGeolocation
  2892. * @param options
  2893. */
  2894. declare function useGeolocation(options?: UseGeolocationOptions): UseGeolocationReturn;
  2895. //#endregion
  2896. //#region useIdle/index.d.ts
  2897. interface UseIdleOptions extends ConfigurableWindow, ConfigurableEventFilter {
  2898. /**
  2899. * Event names that listen to for detected user activity
  2900. *
  2901. * @default ['mousemove', 'mousedown', 'resize', 'keydown', 'touchstart', 'wheel']
  2902. */
  2903. events?: WindowEventName[];
  2904. /**
  2905. * Listen for document visibility change
  2906. *
  2907. * @default true
  2908. */
  2909. listenForVisibilityChange?: boolean;
  2910. /**
  2911. * Initial state of the ref idle
  2912. *
  2913. * @default false
  2914. */
  2915. initialState?: boolean;
  2916. }
  2917. interface UseIdleReturn extends Stoppable {
  2918. idle: ShallowRef<boolean>;
  2919. lastActive: ShallowRef<number>;
  2920. reset: () => void;
  2921. }
  2922. /**
  2923. * Tracks whether the user is being inactive.
  2924. *
  2925. * @see https://vueuse.org/useIdle
  2926. * @param timeout default to 1 minute
  2927. * @param options IdleOptions
  2928. */
  2929. declare function useIdle(timeout?: number, options?: UseIdleOptions): UseIdleReturn;
  2930. //#endregion
  2931. //#region useImage/index.d.ts
  2932. interface UseImageOptions {
  2933. /** Address of the resource */
  2934. src: string;
  2935. /** Images to use in different situations, e.g., high-resolution displays, small monitors, etc. */
  2936. srcset?: string;
  2937. /** Image sizes for different page layouts */
  2938. sizes?: string;
  2939. /** Image alternative information */
  2940. alt?: string;
  2941. /** Image classes */
  2942. class?: string;
  2943. /** Image loading */
  2944. loading?: HTMLImageElement['loading'];
  2945. /** Image CORS settings */
  2946. crossorigin?: string;
  2947. /** Referrer policy for fetch https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Referrer-Policy */
  2948. referrerPolicy?: HTMLImageElement['referrerPolicy'];
  2949. /** Image width */
  2950. width?: HTMLImageElement['width'];
  2951. /** Image height */
  2952. height?: HTMLImageElement['height'];
  2953. /** https://developer.mozilla.org/en-US/docs/Web/HTML/Element/img#decoding */
  2954. decoding?: HTMLImageElement['decoding'];
  2955. /** Provides a hint of the relative priority to use when fetching the image */
  2956. fetchPriority?: HTMLImageElement['fetchPriority'];
  2957. /** Provides a hint of the importance of the image */
  2958. ismap?: HTMLImageElement['isMap'];
  2959. /** The partial URL (starting with #) of an image map associated with the element */
  2960. usemap?: HTMLImageElement['useMap'];
  2961. }
  2962. type UseImageReturn = UseAsyncStateReturn<HTMLImageElement | undefined, any[], true>;
  2963. /**
  2964. * Reactive load an image in the browser, you can wait the result to display it or show a fallback.
  2965. *
  2966. * @see https://vueuse.org/useImage
  2967. * @param options Image attributes, as used in the <img> tag
  2968. * @param asyncStateOptions
  2969. */
  2970. declare function useImage<Shallow extends true>(options: MaybeRefOrGetter<UseImageOptions>, asyncStateOptions?: UseAsyncStateOptions<Shallow>): UseImageReturn;
  2971. //#endregion
  2972. //#region useScroll/index.d.ts
  2973. interface UseScrollOptions extends ConfigurableWindow {
  2974. /**
  2975. * Throttle time for scroll event, it’s disabled by default.
  2976. *
  2977. * @default 0
  2978. */
  2979. throttle?: number;
  2980. /**
  2981. * The check time when scrolling ends.
  2982. * This configuration will be setting to (throttle + idle) when the `throttle` is configured.
  2983. *
  2984. * @default 200
  2985. */
  2986. idle?: number;
  2987. /**
  2988. * Offset arrived states by x pixels
  2989. *
  2990. */
  2991. offset?: {
  2992. left?: number;
  2993. right?: number;
  2994. top?: number;
  2995. bottom?: number;
  2996. };
  2997. /**
  2998. * Use MutationObserver to monitor specific DOM changes,
  2999. * such as attribute modifications, child node additions or removals, or subtree changes.
  3000. * @default { mutation: boolean }
  3001. */
  3002. observe?: boolean | {
  3003. mutation?: boolean;
  3004. };
  3005. /**
  3006. * Trigger it when scrolling.
  3007. *
  3008. */
  3009. onScroll?: (e: Event) => void;
  3010. /**
  3011. * Trigger it when scrolling ends.
  3012. *
  3013. */
  3014. onStop?: (e: Event) => void;
  3015. /**
  3016. * Listener options for scroll event.
  3017. *
  3018. * @default {capture: false, passive: true}
  3019. */
  3020. eventListenerOptions?: boolean | AddEventListenerOptions;
  3021. /**
  3022. * Optionally specify a scroll behavior of `auto` (default, not smooth scrolling) or
  3023. * `smooth` (for smooth scrolling) which takes effect when changing the `x` or `y` refs.
  3024. *
  3025. * @default 'auto'
  3026. */
  3027. behavior?: MaybeRefOrGetter<ScrollBehavior>;
  3028. /**
  3029. * On error callback
  3030. *
  3031. * Default log error to `console.error`
  3032. */
  3033. onError?: (error: unknown) => void;
  3034. }
  3035. interface UseScrollReturn {
  3036. x: WritableComputedRef<number>;
  3037. y: WritableComputedRef<number>;
  3038. isScrolling: ShallowRef<boolean>;
  3039. arrivedState: {
  3040. left: boolean;
  3041. right: boolean;
  3042. top: boolean;
  3043. bottom: boolean;
  3044. };
  3045. directions: {
  3046. left: boolean;
  3047. right: boolean;
  3048. top: boolean;
  3049. bottom: boolean;
  3050. };
  3051. measure: () => void;
  3052. }
  3053. /**
  3054. * Reactive scroll.
  3055. *
  3056. * @see https://vueuse.org/useScroll
  3057. * @param element
  3058. * @param options
  3059. */
  3060. declare function useScroll(element: MaybeRefOrGetter<HTMLElement | SVGElement | Window | Document | null | undefined>, options?: UseScrollOptions): UseScrollReturn;
  3061. //#endregion
  3062. //#region useInfiniteScroll/index.d.ts
  3063. type InfiniteScrollElement = HTMLElement | SVGElement | Window | Document | null | undefined;
  3064. interface UseInfiniteScrollOptions<T extends InfiniteScrollElement = InfiniteScrollElement> extends UseScrollOptions {
  3065. /**
  3066. * The minimum distance between the bottom of the element and the bottom of the viewport
  3067. *
  3068. * @default 0
  3069. */
  3070. distance?: number;
  3071. /**
  3072. * The direction in which to listen the scroll.
  3073. *
  3074. * @default 'bottom'
  3075. */
  3076. direction?: 'top' | 'bottom' | 'left' | 'right';
  3077. /**
  3078. * The interval time between two load more (to avoid too many invokes).
  3079. *
  3080. * @default 100
  3081. */
  3082. interval?: number;
  3083. /**
  3084. * A function that determines whether more content can be loaded for a specific element.
  3085. * Should return `true` if loading more content is allowed for the given element,
  3086. * and `false` otherwise.
  3087. */
  3088. canLoadMore?: (el: T) => boolean;
  3089. }
  3090. interface UseInfiniteScrollReturn {
  3091. isLoading: ComputedRef<boolean>;
  3092. reset: () => void;
  3093. }
  3094. /**
  3095. * Reactive infinite scroll.
  3096. *
  3097. * @see https://vueuse.org/useInfiniteScroll
  3098. */
  3099. declare function useInfiniteScroll<T extends InfiniteScrollElement>(element: MaybeRefOrGetter<T>, onLoadMore: (state: UnwrapNestedRefs<UseScrollReturn>) => Awaitable<void>, options?: UseInfiniteScrollOptions<T>): UseInfiniteScrollReturn;
  3100. //#endregion
  3101. //#region useKeyModifier/index.d.ts
  3102. type KeyModifier = 'Alt' | 'AltGraph' | 'CapsLock' | 'Control' | 'Fn' | 'FnLock' | 'Meta' | 'NumLock' | 'ScrollLock' | 'Shift' | 'Symbol' | 'SymbolLock';
  3103. interface UseModifierOptions<Initial> extends ConfigurableDocument {
  3104. /**
  3105. * Event names that will prompt update to modifier states
  3106. *
  3107. * @default ['mousedown', 'mouseup', 'keydown', 'keyup']
  3108. */
  3109. events?: WindowEventName[];
  3110. /**
  3111. * Initial value of the returned ref
  3112. *
  3113. * @default null
  3114. */
  3115. initial?: Initial;
  3116. }
  3117. type UseKeyModifierReturn<Initial> = ShallowRef<Initial extends boolean ? boolean : boolean | null>;
  3118. declare function useKeyModifier<Initial extends boolean | null>(modifier: KeyModifier, options?: UseModifierOptions<Initial>): UseKeyModifierReturn<Initial>;
  3119. //#endregion
  3120. //#region useLocalStorage/index.d.ts
  3121. declare function useLocalStorage(key: MaybeRefOrGetter<string>, initialValue: MaybeRefOrGetter<string>, options?: UseStorageOptions<string>): RemovableRef<string>;
  3122. declare function useLocalStorage(key: MaybeRefOrGetter<string>, initialValue: MaybeRefOrGetter<boolean>, options?: UseStorageOptions<boolean>): RemovableRef<boolean>;
  3123. declare function useLocalStorage(key: MaybeRefOrGetter<string>, initialValue: MaybeRefOrGetter<number>, options?: UseStorageOptions<number>): RemovableRef<number>;
  3124. declare function useLocalStorage<T>(key: MaybeRefOrGetter<string>, initialValue: MaybeRefOrGetter<T>, options?: UseStorageOptions<T>): RemovableRef<T>;
  3125. declare function useLocalStorage<T = unknown>(key: MaybeRefOrGetter<string>, initialValue: MaybeRefOrGetter<null>, options?: UseStorageOptions<T>): RemovableRef<T>;
  3126. //#endregion
  3127. //#region useMagicKeys/aliasMap.d.ts
  3128. declare const DefaultMagicKeysAliasMap: Readonly<Record<string, string>>;
  3129. //#endregion
  3130. //#region useMagicKeys/index.d.ts
  3131. interface UseMagicKeysOptions<Reactive extends boolean> {
  3132. /**
  3133. * Returns a reactive object instead of an object of refs
  3134. *
  3135. * @default false
  3136. */
  3137. reactive?: Reactive;
  3138. /**
  3139. * Target for listening events
  3140. *
  3141. * @default window
  3142. */
  3143. target?: MaybeRefOrGetter<EventTarget>;
  3144. /**
  3145. * Alias map for keys, all the keys should be lowercase
  3146. * { target: keycode }
  3147. *
  3148. * @example { ctrl: "control" }
  3149. * @default <predefined-map>
  3150. */
  3151. aliasMap?: Record<string, string>;
  3152. /**
  3153. * Register passive listener
  3154. *
  3155. * @default true
  3156. */
  3157. passive?: boolean;
  3158. /**
  3159. * Custom event handler for keydown/keyup event.
  3160. * Useful when you want to apply custom logic.
  3161. *
  3162. * When using `e.preventDefault()`, you will need to pass `passive: false` to useMagicKeys().
  3163. */
  3164. onEventFired?: (e: KeyboardEvent) => void | boolean;
  3165. }
  3166. interface MagicKeysInternal {
  3167. /**
  3168. * A Set of currently pressed keys,
  3169. * Stores raw keyCodes.
  3170. *
  3171. * @see https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/key
  3172. */
  3173. current: Set<string>;
  3174. }
  3175. type UseMagicKeysReturn<Reactive extends boolean> = Readonly<Record<string, Reactive extends true ? boolean : ComputedRef<boolean>> & MagicKeysInternal>;
  3176. /**
  3177. * Reactive keys pressed state, with magical keys combination support.
  3178. *
  3179. * @see https://vueuse.org/useMagicKeys
  3180. */
  3181. declare function useMagicKeys<T extends boolean = false>(options?: UseMagicKeysOptions<T>): UseMagicKeysReturn<T>;
  3182. //#endregion
  3183. //#region useMediaControls/index.d.ts
  3184. /**
  3185. * Many of the jsdoc definitions here are modified version of the
  3186. * documentation from MDN(https://developer.mozilla.org/en-US/docs/Web/API/HTMLMediaElement)
  3187. */
  3188. interface UseMediaSource {
  3189. /**
  3190. * The source url for the media
  3191. */
  3192. src: string;
  3193. /**
  3194. * The media codec type
  3195. */
  3196. type?: string;
  3197. /**
  3198. * Specifies the media query for the resource's intended media.
  3199. */
  3200. media?: string;
  3201. }
  3202. interface UseMediaTextTrackSource {
  3203. /**
  3204. * Indicates that the track should be enabled unless the user's preferences indicate
  3205. * that another track is more appropriate
  3206. */
  3207. default?: boolean;
  3208. /**
  3209. * How the text track is meant to be used. If omitted the default kind is subtitles.
  3210. */
  3211. kind: TextTrackKind;
  3212. /**
  3213. * A user-readable title of the text track which is used by the browser
  3214. * when listing available text tracks.
  3215. */
  3216. label: string;
  3217. /**
  3218. * Address of the track (.vtt file). Must be a valid URL. This attribute
  3219. * must be specified and its URL value must have the same origin as the document
  3220. */
  3221. src: string;
  3222. /**
  3223. * Language of the track text data. It must be a valid BCP 47 language tag.
  3224. * If the kind attribute is set to subtitles, then srclang must be defined.
  3225. */
  3226. srcLang: string;
  3227. }
  3228. interface UseMediaControlsOptions extends ConfigurableDocument {
  3229. /**
  3230. * The source for the media, may either be a string, a `UseMediaSource` object, or a list
  3231. * of `UseMediaSource` objects.
  3232. */
  3233. src?: MaybeRefOrGetter<string | UseMediaSource | UseMediaSource[]>;
  3234. /**
  3235. * A list of text tracks for the media
  3236. */
  3237. tracks?: MaybeRefOrGetter<UseMediaTextTrackSource[]>;
  3238. }
  3239. interface UseMediaTextTrack {
  3240. /**
  3241. * The index of the text track
  3242. */
  3243. id: number;
  3244. /**
  3245. * The text track label
  3246. */
  3247. label: string;
  3248. /**
  3249. * Language of the track text data. It must be a valid BCP 47 language tag.
  3250. * If the kind attribute is set to subtitles, then srclang must be defined.
  3251. */
  3252. language: string;
  3253. /**
  3254. * Specifies the display mode of the text track, either `disabled`,
  3255. * `hidden`, or `showing`
  3256. */
  3257. mode: TextTrackMode;
  3258. /**
  3259. * How the text track is meant to be used. If omitted the default kind is subtitles.
  3260. */
  3261. kind: TextTrackKind;
  3262. /**
  3263. * Indicates the track's in-band metadata track dispatch type.
  3264. */
  3265. inBandMetadataTrackDispatchType: string;
  3266. /**
  3267. * A list of text track cues
  3268. */
  3269. cues: TextTrackCueList | null;
  3270. /**
  3271. * A list of active text track cues
  3272. */
  3273. activeCues: TextTrackCueList | null;
  3274. }
  3275. interface UseMediaControlsReturn {
  3276. currentTime: ShallowRef<number>;
  3277. duration: ShallowRef<number>;
  3278. waiting: ShallowRef<boolean>;
  3279. seeking: ShallowRef<boolean>;
  3280. ended: ShallowRef<boolean>;
  3281. stalled: ShallowRef<boolean>;
  3282. buffered: ShallowRef<[number, number][]>;
  3283. playing: ShallowRef<boolean>;
  3284. rate: ShallowRef<number>;
  3285. volume: ShallowRef<number>;
  3286. muted: ShallowRef<boolean>;
  3287. tracks: ShallowRef<UseMediaTextTrack[]>;
  3288. selectedTrack: ShallowRef<number>;
  3289. enableTrack: (track: number | UseMediaTextTrack, disableTracks?: boolean) => void;
  3290. disableTrack: (track?: number | UseMediaTextTrack) => void;
  3291. supportsPictureInPicture: boolean;
  3292. togglePictureInPicture: () => Promise<PictureInPictureWindow | void>;
  3293. isPictureInPicture: ShallowRef<boolean>;
  3294. onSourceError: EventHookOn<Event>;
  3295. onPlaybackError: EventHookOn<Event>;
  3296. }
  3297. declare function useMediaControls(target: MaybeRef<HTMLMediaElement | null | undefined>, options?: UseMediaControlsOptions): UseMediaControlsReturn;
  3298. //#endregion
  3299. //#region useMediaQuery/index.d.ts
  3300. /**
  3301. * Reactive Media Query.
  3302. *
  3303. * @see https://vueuse.org/useMediaQuery
  3304. * @param query
  3305. * @param options
  3306. */
  3307. declare function useMediaQuery(query: MaybeRefOrGetter<string>, options?: ConfigurableWindow & {
  3308. ssrWidth?: number;
  3309. }): _$vue.ComputedRef<boolean>;
  3310. //#endregion
  3311. //#region useMemoize/index.d.ts
  3312. type CacheKey = any;
  3313. /**
  3314. * Custom memoize cache handler
  3315. */
  3316. interface UseMemoizeCache<Key, Value> {
  3317. /**
  3318. * Get value for key
  3319. */
  3320. get: (key: Key) => Value | undefined;
  3321. /**
  3322. * Set value for key
  3323. */
  3324. set: (key: Key, value: Value) => void;
  3325. /**
  3326. * Return flag if key exists
  3327. */
  3328. has: (key: Key) => boolean;
  3329. /**
  3330. * Delete value for key
  3331. */
  3332. delete: (key: Key) => void;
  3333. /**
  3334. * Clear cache
  3335. */
  3336. clear: () => void;
  3337. }
  3338. /**
  3339. * Memoized function
  3340. */
  3341. interface UseMemoizeReturn<Result, Args extends unknown[]> {
  3342. /**
  3343. * Get result from cache or call memoized function
  3344. */
  3345. (...args: Args): Result;
  3346. /**
  3347. * Call memoized function and update cache
  3348. */
  3349. load: (...args: Args) => Result;
  3350. /**
  3351. * Delete cache of given arguments
  3352. */
  3353. delete: (...args: Args) => void;
  3354. /**
  3355. * Clear cache
  3356. */
  3357. clear: () => void;
  3358. /**
  3359. * Generate cache key for given arguments
  3360. */
  3361. generateKey: (...args: Args) => CacheKey;
  3362. /**
  3363. * Cache container
  3364. */
  3365. cache: UseMemoizeCache<CacheKey, Result>;
  3366. }
  3367. interface UseMemoizeOptions<Result, Args extends unknown[]> {
  3368. getKey?: (...args: Args) => string | number;
  3369. cache?: UseMemoizeCache<CacheKey, Result>;
  3370. }
  3371. /**
  3372. * Reactive function result cache based on arguments
  3373. *
  3374. * @__NO_SIDE_EFFECTS__
  3375. */
  3376. declare function useMemoize<Result, Args extends unknown[]>(resolver: (...args: Args) => Result, options?: UseMemoizeOptions<Result, Args>): UseMemoizeReturn<Result, Args>;
  3377. //#endregion
  3378. //#region useMemory/index.d.ts
  3379. /**
  3380. * Performance.memory
  3381. *
  3382. * @see https://developer.mozilla.org/en-US/docs/Web/API/Performance/memory
  3383. */
  3384. interface MemoryInfo {
  3385. /**
  3386. * The maximum size of the heap, in bytes, that is available to the context.
  3387. */
  3388. readonly jsHeapSizeLimit: number;
  3389. /**
  3390. * The total allocated heap size, in bytes.
  3391. */
  3392. readonly totalJSHeapSize: number;
  3393. /**
  3394. * The currently active segment of JS heap, in bytes.
  3395. */
  3396. readonly usedJSHeapSize: number;
  3397. [Symbol.toStringTag]: 'MemoryInfo';
  3398. }
  3399. interface UseMemoryOptions extends ConfigurableScheduler {
  3400. /**
  3401. * Start the timer immediately
  3402. *
  3403. * @deprecated Please use `scheduler` option instead
  3404. * @default true
  3405. */
  3406. immediate?: boolean;
  3407. /**
  3408. * Execute the callback immediately after calling `resume`
  3409. *
  3410. * @deprecated Please use `scheduler` option instead
  3411. * @default false
  3412. */
  3413. immediateCallback?: boolean;
  3414. /** @deprecated Please use `scheduler` option instead */
  3415. interval?: number;
  3416. }
  3417. interface UseMemoryReturn extends Supportable {
  3418. memory: ShallowRef<MemoryInfo | undefined>;
  3419. }
  3420. /**
  3421. * Reactive Memory Info.
  3422. *
  3423. * @see https://vueuse.org/useMemory
  3424. * @param options
  3425. *
  3426. * @__NO_SIDE_EFFECTS__
  3427. */
  3428. declare function useMemory(options?: UseMemoryOptions): UseMemoryReturn;
  3429. //#endregion
  3430. //#region useMounted/index.d.ts
  3431. /**
  3432. * Mounted state in ref.
  3433. *
  3434. * @see https://vueuse.org/useMounted
  3435. *
  3436. * @__NO_SIDE_EFFECTS__
  3437. */
  3438. declare function useMounted(): _$vue.ShallowRef<boolean, boolean>;
  3439. //#endregion
  3440. //#region useMouse/index.d.ts
  3441. type UseMouseCoordType = 'page' | 'client' | 'screen' | 'movement';
  3442. type UseMouseSourceType = 'mouse' | 'touch' | null;
  3443. type UseMouseEventExtractor = (event: MouseEvent | Touch) => [x: number, y: number] | null | undefined;
  3444. interface UseMouseOptions extends ConfigurableWindow, ConfigurableEventFilter {
  3445. /**
  3446. * Mouse position based by page, client, screen, or relative to previous position
  3447. *
  3448. * @default 'page'
  3449. */
  3450. type?: UseMouseCoordType | UseMouseEventExtractor;
  3451. /**
  3452. * Listen events on `target` element
  3453. *
  3454. * @default 'Window'
  3455. */
  3456. target?: MaybeRefOrGetter<Window | EventTarget | null | undefined>;
  3457. /**
  3458. * Listen to `touchmove` events
  3459. *
  3460. * @default true
  3461. */
  3462. touch?: boolean;
  3463. /**
  3464. * Listen to `scroll` events on window, only effective on type `page`
  3465. *
  3466. * @default true
  3467. */
  3468. scroll?: boolean;
  3469. /**
  3470. * Reset to initial value when `touchend` event fired
  3471. *
  3472. * @default false
  3473. */
  3474. resetOnTouchEnds?: boolean;
  3475. /**
  3476. * Initial values
  3477. */
  3478. initialValue?: Position;
  3479. }
  3480. interface UseMouseReturn {
  3481. x: ShallowRef<number>;
  3482. y: ShallowRef<number>;
  3483. sourceType: ShallowRef<UseMouseSourceType>;
  3484. }
  3485. /**
  3486. * Reactive mouse position.
  3487. *
  3488. * @see https://vueuse.org/useMouse
  3489. * @param options
  3490. */
  3491. declare function useMouse(options?: UseMouseOptions): UseMouseReturn;
  3492. //#endregion
  3493. //#region useMouseInElement/index.d.ts
  3494. interface MouseInElementOptions extends UseMouseOptions {
  3495. /**
  3496. * Whether to handle mouse events when the cursor is outside the target element.
  3497. * When enabled, mouse position will continue to be tracked even when outside the element bounds.
  3498. *
  3499. * @default true
  3500. */
  3501. handleOutside?: boolean;
  3502. /**
  3503. * Listen to window resize event
  3504. *
  3505. * @default true
  3506. */
  3507. windowScroll?: boolean;
  3508. /**
  3509. * Listen to window scroll event
  3510. *
  3511. * @default true
  3512. */
  3513. windowResize?: boolean;
  3514. }
  3515. interface UseMouseInElementReturn extends UseMouseReturn {
  3516. elementX: ShallowRef<number>;
  3517. elementY: ShallowRef<number>;
  3518. elementPositionX: ShallowRef<number>;
  3519. elementPositionY: ShallowRef<number>;
  3520. elementHeight: ShallowRef<number>;
  3521. elementWidth: ShallowRef<number>;
  3522. isOutside: ShallowRef<boolean>;
  3523. stop: () => void;
  3524. }
  3525. /**
  3526. * Reactive mouse position related to an element.
  3527. *
  3528. * @see https://vueuse.org/useMouseInElement
  3529. * @param target
  3530. * @param options
  3531. */
  3532. declare function useMouseInElement(target?: MaybeElementRef, options?: MouseInElementOptions): {
  3533. x: ShallowRef<number>;
  3534. y: ShallowRef<number>;
  3535. sourceType: ShallowRef<UseMouseSourceType>;
  3536. elementX: ShallowRef<number, number>;
  3537. elementY: ShallowRef<number, number>;
  3538. elementPositionX: ShallowRef<number, number>;
  3539. elementPositionY: ShallowRef<number, number>;
  3540. elementHeight: ShallowRef<number, number>;
  3541. elementWidth: ShallowRef<number, number>;
  3542. isOutside: ShallowRef<boolean, boolean>;
  3543. stop: () => void;
  3544. };
  3545. //#endregion
  3546. //#region useMousePressed/index.d.ts
  3547. interface UseMousePressedOptions extends ConfigurableWindow {
  3548. /**
  3549. * Listen to `touchstart` `touchend` events
  3550. *
  3551. * @default true
  3552. */
  3553. touch?: boolean;
  3554. /**
  3555. * Listen to `dragstart` `drop` and `dragend` events
  3556. *
  3557. * @default true
  3558. */
  3559. drag?: boolean;
  3560. /**
  3561. * Add event listeners with the `capture` option set to `true`
  3562. * (see [MDN](https://developer.mozilla.org/en-US/docs/Web/API/EventTarget/addEventListener#capture))
  3563. *
  3564. * @default false
  3565. */
  3566. capture?: boolean;
  3567. /**
  3568. * Initial values
  3569. *
  3570. * @default false
  3571. */
  3572. initialValue?: boolean;
  3573. /**
  3574. * Element target to be capture the click
  3575. */
  3576. target?: MaybeComputedElementRef;
  3577. /**
  3578. * Callback to be called when the mouse is pressed
  3579. *
  3580. * @param event
  3581. */
  3582. onPressed?: (event: MouseEvent | TouchEvent | DragEvent) => void;
  3583. /**
  3584. * Callback to be called when the mouse is released
  3585. *
  3586. * @param event
  3587. */
  3588. onReleased?: (event: MouseEvent | TouchEvent | DragEvent) => void;
  3589. }
  3590. /** @deprecated use {@link UseMousePressedOptions} instead */
  3591. type MousePressedOptions = UseMousePressedOptions;
  3592. interface UseMousePressedReturn {
  3593. pressed: ShallowRef<boolean>;
  3594. sourceType: ShallowRef<UseMouseSourceType>;
  3595. }
  3596. /**
  3597. * Reactive mouse pressing state.
  3598. *
  3599. * @see https://vueuse.org/useMousePressed
  3600. * @param options
  3601. */
  3602. declare function useMousePressed(options?: UseMousePressedOptions): UseMousePressedReturn;
  3603. //#endregion
  3604. //#region useMutationObserver/index.d.ts
  3605. interface UseMutationObserverOptions extends MutationObserverInit, ConfigurableWindow {}
  3606. interface UseMutationObserverReturn extends Supportable {
  3607. stop: () => void;
  3608. takeRecords: () => MutationRecord[] | undefined;
  3609. }
  3610. /**
  3611. * Watch for changes being made to the DOM tree.
  3612. *
  3613. * @see https://vueuse.org/useMutationObserver
  3614. * @see https://developer.mozilla.org/en-US/docs/Web/API/MutationObserver MutationObserver MDN
  3615. * @param target
  3616. * @param callback
  3617. * @param options
  3618. */
  3619. declare function useMutationObserver(target: MaybeComputedElementRef | MaybeComputedElementRef[] | MaybeRefOrGetter<MaybeElement[]>, callback: MutationCallback, options?: UseMutationObserverOptions): UseMutationObserverReturn;
  3620. //#endregion
  3621. //#region useNavigatorLanguage/index.d.ts
  3622. interface NavigatorLanguageState extends Supportable {
  3623. /**
  3624. *
  3625. * ISO 639-1 standard Language Code
  3626. *
  3627. * @info The detected user agent language preference as a language tag
  3628. * (which is sometimes referred to as a "locale identifier").
  3629. * This consists of a 2-3 letter base language tag that indicates a
  3630. * language, optionally followed by additional subtags separated by
  3631. * '-'. The most common extra information is the country or region
  3632. * variant (like 'en-US' or 'fr-CA').
  3633. *
  3634. *
  3635. * @see https://www.iso.org/iso-639-language-codes.html
  3636. * @see https://www.loc.gov/standards/iso639-2/php/code_list.php
  3637. *
  3638. */
  3639. language: ShallowRef<string | undefined>;
  3640. }
  3641. interface UseNavigatorLanguageOptions extends ConfigurableWindow {}
  3642. type UseNavigatorLanguageReturn = Readonly<NavigatorLanguageState>;
  3643. /**
  3644. *
  3645. * Reactive useNavigatorLanguage
  3646. *
  3647. * Detects the currently selected user language and returns a reactive language
  3648. * @see https://vueuse.org/useNavigatorLanguage
  3649. *
  3650. * @__NO_SIDE_EFFECTS__
  3651. */
  3652. declare function useNavigatorLanguage(options?: UseNavigatorLanguageOptions): UseNavigatorLanguageReturn;
  3653. //#endregion
  3654. //#region useNetwork/index.d.ts
  3655. interface UseNetworkOptions extends ConfigurableWindow {}
  3656. type NetworkType = 'bluetooth' | 'cellular' | 'ethernet' | 'none' | 'wifi' | 'wimax' | 'other' | 'unknown';
  3657. type NetworkEffectiveType = 'slow-2g' | '2g' | '3g' | '4g' | undefined;
  3658. interface NetworkState extends Supportable {
  3659. /**
  3660. * If the user is currently connected.
  3661. */
  3662. isOnline: Readonly<ShallowRef<boolean>>;
  3663. /**
  3664. * The time since the user was last connected.
  3665. */
  3666. offlineAt: Readonly<ShallowRef<number | undefined>>;
  3667. /**
  3668. * At this time, if the user is offline and reconnects
  3669. */
  3670. onlineAt: Readonly<ShallowRef<number | undefined>>;
  3671. /**
  3672. * The download speed in Mbps.
  3673. */
  3674. downlink: Readonly<ShallowRef<number | undefined>>;
  3675. /**
  3676. * The max reachable download speed in Mbps.
  3677. */
  3678. downlinkMax: Readonly<ShallowRef<number | undefined>>;
  3679. /**
  3680. * The detected effective speed type.
  3681. */
  3682. effectiveType: Readonly<ShallowRef<NetworkEffectiveType | undefined>>;
  3683. /**
  3684. * The estimated effective round-trip time of the current connection.
  3685. */
  3686. rtt: Readonly<ShallowRef<number | undefined>>;
  3687. /**
  3688. * If the user activated data saver mode.
  3689. */
  3690. saveData: Readonly<ShallowRef<boolean | undefined>>;
  3691. /**
  3692. * The detected connection/network type.
  3693. */
  3694. type: Readonly<ShallowRef<NetworkType>>;
  3695. }
  3696. type UseNetworkReturn = Readonly<NetworkState>;
  3697. /**
  3698. * Reactive Network status.
  3699. *
  3700. * @see https://vueuse.org/useNetwork
  3701. * @param options
  3702. *
  3703. * @__NO_SIDE_EFFECTS__
  3704. */
  3705. declare function useNetwork(options?: UseNetworkOptions): UseNetworkReturn;
  3706. //#endregion
  3707. //#region useNow/index.d.ts
  3708. interface UseNowOptions<Controls extends boolean> extends ConfigurableScheduler {
  3709. /**
  3710. * Expose more controls
  3711. *
  3712. * @default false
  3713. */
  3714. controls?: Controls;
  3715. /**
  3716. * Start the clock immediately
  3717. *
  3718. * @deprecated Please use `scheduler` option instead
  3719. * @default true
  3720. */
  3721. immediate?: boolean;
  3722. /**
  3723. * Update interval in milliseconds, or use requestAnimationFrame
  3724. *
  3725. * @deprecated Please use `scheduler` option instead
  3726. * @default requestAnimationFrame
  3727. */
  3728. interval?: 'requestAnimationFrame' | number;
  3729. }
  3730. type UseNowReturn<Controls extends boolean> = Controls extends true ? ({
  3731. now: ShallowRef<Date>;
  3732. } & Pausable) : ShallowRef<Date>;
  3733. /**
  3734. * Reactive current Date instance.
  3735. *
  3736. * @see https://vueuse.org/useNow
  3737. * @param options
  3738. *
  3739. * @__NO_SIDE_EFFECTS__
  3740. */
  3741. declare function useNow(options?: UseNowOptions<false>): ShallowRef<Date>;
  3742. declare function useNow(options: UseNowOptions<true>): {
  3743. now: ShallowRef<Date>;
  3744. } & Pausable;
  3745. //#endregion
  3746. //#region useObjectUrl/index.d.ts
  3747. /**
  3748. * Reactive URL representing an object.
  3749. *
  3750. * @see https://vueuse.org/useObjectUrl
  3751. * @param object
  3752. */
  3753. declare function useObjectUrl(object: MaybeRefOrGetter<Blob | MediaSource | null | undefined>): Readonly<_$vue.ShallowRef<string | undefined, string | undefined>>;
  3754. //#endregion
  3755. //#region useOffsetPagination/index.d.ts
  3756. interface UseOffsetPaginationOptions {
  3757. /**
  3758. * Total number of items.
  3759. */
  3760. total?: MaybeRefOrGetter<number>;
  3761. /**
  3762. * The number of items to display per page.
  3763. * @default 10
  3764. */
  3765. pageSize?: MaybeRefOrGetter<number>;
  3766. /**
  3767. * The current page number.
  3768. * @default 1
  3769. */
  3770. page?: MaybeRef<number>;
  3771. /**
  3772. * Callback when the `page` change.
  3773. */
  3774. onPageChange?: (returnValue: UnwrapNestedRefs<UseOffsetPaginationReturn>) => unknown;
  3775. /**
  3776. * Callback when the `pageSize` change.
  3777. */
  3778. onPageSizeChange?: (returnValue: UnwrapNestedRefs<UseOffsetPaginationReturn>) => unknown;
  3779. /**
  3780. * Callback when the `pageCount` change.
  3781. */
  3782. onPageCountChange?: (returnValue: UnwrapNestedRefs<UseOffsetPaginationReturn>) => unknown;
  3783. }
  3784. interface UseOffsetPaginationReturn {
  3785. currentPage: Ref<number>;
  3786. currentPageSize: Ref<number>;
  3787. pageCount: ComputedRef<number>;
  3788. isFirstPage: ComputedRef<boolean>;
  3789. isLastPage: ComputedRef<boolean>;
  3790. prev: () => void;
  3791. next: () => void;
  3792. }
  3793. type UseOffsetPaginationInfinityPageReturn = Omit<UseOffsetPaginationReturn, 'isLastPage'>;
  3794. declare function useOffsetPagination(options: Omit<UseOffsetPaginationOptions, 'total'>): UseOffsetPaginationInfinityPageReturn;
  3795. declare function useOffsetPagination(options: UseOffsetPaginationOptions): UseOffsetPaginationReturn;
  3796. //#endregion
  3797. //#region useOnline/index.d.ts
  3798. /**
  3799. * Reactive online state.
  3800. *
  3801. * @see https://vueuse.org/useOnline
  3802. * @param options
  3803. *
  3804. * @__NO_SIDE_EFFECTS__
  3805. */
  3806. declare function useOnline(options?: ConfigurableWindow): Readonly<_$vue.ShallowRef<boolean>>;
  3807. //#endregion
  3808. //#region usePageLeave/index.d.ts
  3809. interface UsePageLeaveOptions extends ConfigurableWindow {}
  3810. type UsePageLeaveReturn = ShallowRef<boolean>;
  3811. /**
  3812. * Reactive state to show whether mouse leaves the page.
  3813. *
  3814. * @see https://vueuse.org/usePageLeave
  3815. * @param options
  3816. *
  3817. * @__NO_SIDE_EFFECTS__
  3818. */
  3819. declare function usePageLeave(options?: UsePageLeaveOptions): UsePageLeaveReturn;
  3820. //#endregion
  3821. //#region useParallax/index.d.ts
  3822. interface UseParallaxOptions extends ConfigurableWindow {
  3823. deviceOrientationTiltAdjust?: (i: number) => number;
  3824. deviceOrientationRollAdjust?: (i: number) => number;
  3825. mouseTiltAdjust?: (i: number) => number;
  3826. mouseRollAdjust?: (i: number) => number;
  3827. }
  3828. interface UseParallaxReturn {
  3829. /**
  3830. * Roll value. Scaled to `-0.5 ~ 0.5`
  3831. */
  3832. roll: ComputedRef<number>;
  3833. /**
  3834. * Tilt value. Scaled to `-0.5 ~ 0.5`
  3835. */
  3836. tilt: ComputedRef<number>;
  3837. /**
  3838. * Sensor source, can be `mouse` or `deviceOrientation`
  3839. */
  3840. source: ComputedRef<'deviceOrientation' | 'mouse'>;
  3841. }
  3842. /**
  3843. * Create parallax effect easily. It uses `useDeviceOrientation` and fallback to `useMouse`
  3844. * if orientation is not supported.
  3845. *
  3846. * @param target
  3847. * @param options
  3848. */
  3849. declare function useParallax(target: MaybeElementRef, options?: UseParallaxOptions): UseParallaxReturn;
  3850. //#endregion
  3851. //#region useParentElement/index.d.ts
  3852. declare function useParentElement(element?: MaybeRefOrGetter<HTMLElement | SVGElement | null | undefined>): Readonly<ShallowRef<HTMLElement | SVGElement | null | undefined>>;
  3853. //#endregion
  3854. //#region usePerformanceObserver/index.d.ts
  3855. type UsePerformanceObserverOptions = PerformanceObserverInit & ConfigurableWindow & {
  3856. /**
  3857. * Start the observer immediate.
  3858. *
  3859. * @default true
  3860. */
  3861. immediate?: boolean;
  3862. };
  3863. /**
  3864. * Observe performance metrics.
  3865. *
  3866. * @see https://vueuse.org/usePerformanceObserver
  3867. * @param options
  3868. */
  3869. declare function usePerformanceObserver(options: UsePerformanceObserverOptions, callback: PerformanceObserverCallback): {
  3870. isSupported: UseSupportedReturn;
  3871. start: () => void;
  3872. stop: () => void;
  3873. };
  3874. //#endregion
  3875. //#region usePermission/index.d.ts
  3876. type DescriptorNamePolyfill = 'accelerometer' | 'accessibility-events' | 'ambient-light-sensor' | 'background-sync' | 'camera' | 'clipboard-read' | 'clipboard-write' | 'gyroscope' | 'magnetometer' | 'microphone' | 'notifications' | 'payment-handler' | 'persistent-storage' | 'push' | 'speaker' | 'local-fonts';
  3877. type GeneralPermissionDescriptor = PermissionDescriptor | {
  3878. name: DescriptorNamePolyfill;
  3879. };
  3880. interface UsePermissionOptions<Controls extends boolean> extends ConfigurableNavigator {
  3881. /**
  3882. * Expose more controls
  3883. *
  3884. * @default false
  3885. */
  3886. controls?: Controls;
  3887. }
  3888. type UsePermissionReturn = Readonly<ShallowRef<PermissionState | undefined>>;
  3889. interface UsePermissionReturnWithControls extends Supportable {
  3890. state: UsePermissionReturn;
  3891. query: () => Promise<PermissionStatus | undefined>;
  3892. }
  3893. /**
  3894. * Reactive Permissions API.
  3895. *
  3896. * @see https://vueuse.org/usePermission
  3897. *
  3898. * @__NO_SIDE_EFFECTS__
  3899. */
  3900. declare function usePermission(permissionDesc: GeneralPermissionDescriptor | GeneralPermissionDescriptor['name'], options?: UsePermissionOptions<false>): UsePermissionReturn;
  3901. declare function usePermission(permissionDesc: GeneralPermissionDescriptor | GeneralPermissionDescriptor['name'], options: UsePermissionOptions<true>): UsePermissionReturnWithControls;
  3902. //#endregion
  3903. //#region usePointer/index.d.ts
  3904. interface UsePointerState extends Position {
  3905. pressure: number;
  3906. pointerId: number;
  3907. tiltX: number;
  3908. tiltY: number;
  3909. width: number;
  3910. height: number;
  3911. twist: number;
  3912. pointerType: PointerType | null;
  3913. }
  3914. interface UsePointerOptions extends ConfigurableWindow {
  3915. /**
  3916. * Pointer types that listen to.
  3917. *
  3918. * @default ['mouse', 'touch', 'pen']
  3919. */
  3920. pointerTypes?: PointerType[];
  3921. /**
  3922. * Initial values
  3923. */
  3924. initialValue?: MaybeRef<Partial<UsePointerState>>;
  3925. /**
  3926. * @default window
  3927. */
  3928. target?: MaybeRef<EventTarget | null | undefined> | Document | Window;
  3929. }
  3930. interface UsePointerReturn {
  3931. pressure: Ref<number>;
  3932. pointerId: Ref<number>;
  3933. tiltX: Ref<number>;
  3934. tiltY: Ref<number>;
  3935. width: Ref<number>;
  3936. height: Ref<number>;
  3937. twist: Ref<number>;
  3938. pointerType: Ref<PointerType | null>;
  3939. x: Ref<number>;
  3940. y: Ref<number>;
  3941. isInside: ShallowRef<boolean>;
  3942. }
  3943. /**
  3944. * Reactive pointer state.
  3945. *
  3946. * @see https://vueuse.org/usePointer
  3947. * @param options
  3948. */
  3949. declare function usePointer(options?: UsePointerOptions): UsePointerReturn;
  3950. //#endregion
  3951. //#region usePointerLock/index.d.ts
  3952. interface UsePointerLockOptions extends ConfigurableDocument {}
  3953. interface UsePointerLockReturn extends Supportable {
  3954. element: ShallowRef<MaybeElement>;
  3955. triggerElement: ShallowRef<MaybeElement>;
  3956. lock: (e: MaybeElementRef | Event) => Promise<MaybeElement>;
  3957. unlock: () => Promise<boolean>;
  3958. }
  3959. /**
  3960. * Reactive pointer lock.
  3961. *
  3962. * @see https://vueuse.org/usePointerLock
  3963. * @param target
  3964. * @param options
  3965. *
  3966. * @__NO_SIDE_EFFECTS__
  3967. */
  3968. declare function usePointerLock(target?: MaybeElementRef, options?: UsePointerLockOptions): UsePointerLockReturn;
  3969. //#endregion
  3970. //#region useSwipe/index.d.ts
  3971. type UseSwipeDirection = 'up' | 'down' | 'left' | 'right' | 'none';
  3972. interface UseSwipeOptions extends ConfigurableWindow {
  3973. /**
  3974. * Register events as passive
  3975. *
  3976. * @default true
  3977. */
  3978. passive?: boolean;
  3979. /**
  3980. * @default 50
  3981. */
  3982. threshold?: number;
  3983. /**
  3984. * Callback on swipe start
  3985. */
  3986. onSwipeStart?: (e: TouchEvent) => void;
  3987. /**
  3988. * Callback on swipe moves
  3989. */
  3990. onSwipe?: (e: TouchEvent) => void;
  3991. /**
  3992. * Callback on swipe ends
  3993. */
  3994. onSwipeEnd?: (e: TouchEvent, direction: UseSwipeDirection) => void;
  3995. }
  3996. interface UseSwipeReturn {
  3997. isSwiping: ShallowRef<boolean>;
  3998. direction: ComputedRef<UseSwipeDirection>;
  3999. coordsStart: Readonly<Position>;
  4000. coordsEnd: Readonly<Position>;
  4001. lengthX: ComputedRef<number>;
  4002. lengthY: ComputedRef<number>;
  4003. stop: () => void;
  4004. }
  4005. /**
  4006. * Reactive swipe detection.
  4007. *
  4008. * @see https://vueuse.org/useSwipe
  4009. * @param target
  4010. * @param options
  4011. */
  4012. declare function useSwipe(target: MaybeRefOrGetter<EventTarget | null | undefined>, options?: UseSwipeOptions): UseSwipeReturn;
  4013. //#endregion
  4014. //#region usePointerSwipe/index.d.ts
  4015. interface UsePointerSwipeOptions {
  4016. /**
  4017. * @default 50
  4018. */
  4019. threshold?: number;
  4020. /**
  4021. * Callback on swipe start.
  4022. */
  4023. onSwipeStart?: (e: PointerEvent) => void;
  4024. /**
  4025. * Callback on swipe move.
  4026. */
  4027. onSwipe?: (e: PointerEvent) => void;
  4028. /**
  4029. * Callback on swipe end.
  4030. */
  4031. onSwipeEnd?: (e: PointerEvent, direction: UseSwipeDirection) => void;
  4032. /**
  4033. * Pointer types to listen to.
  4034. *
  4035. * @default ['mouse', 'touch', 'pen']
  4036. */
  4037. pointerTypes?: PointerType[];
  4038. /**
  4039. * Disable text selection on swipe.
  4040. *
  4041. * @default false
  4042. */
  4043. disableTextSelect?: boolean;
  4044. }
  4045. interface UsePointerSwipeReturn {
  4046. readonly isSwiping: ShallowRef<boolean>;
  4047. direction: Readonly<ShallowRef<UseSwipeDirection>>;
  4048. readonly posStart: DeepReadonly<Position>;
  4049. readonly posEnd: DeepReadonly<Position>;
  4050. distanceX: Readonly<ComputedRef<number>>;
  4051. distanceY: Readonly<ComputedRef<number>>;
  4052. stop: () => void;
  4053. }
  4054. /**
  4055. * Reactive swipe detection based on PointerEvents.
  4056. *
  4057. * @see https://vueuse.org/usePointerSwipe
  4058. * @param target
  4059. * @param options
  4060. */
  4061. declare function usePointerSwipe(target: MaybeRefOrGetter<HTMLElement | null | undefined>, options?: UsePointerSwipeOptions): UsePointerSwipeReturn;
  4062. //#endregion
  4063. //#region usePreferredColorScheme/index.d.ts
  4064. type ColorSchemeType = 'dark' | 'light' | 'no-preference';
  4065. /**
  4066. * Reactive prefers-color-scheme media query.
  4067. *
  4068. * @see https://vueuse.org/usePreferredColorScheme
  4069. * @param [options]
  4070. *
  4071. * @__NO_SIDE_EFFECTS__
  4072. */
  4073. declare function usePreferredColorScheme(options?: ConfigurableWindow): _$vue.ComputedRef<ColorSchemeType>;
  4074. //#endregion
  4075. //#region usePreferredContrast/index.d.ts
  4076. type ContrastType = 'more' | 'less' | 'custom' | 'no-preference';
  4077. /**
  4078. * Reactive prefers-contrast media query.
  4079. *
  4080. * @see https://vueuse.org/usePreferredContrast
  4081. * @param [options]
  4082. *
  4083. * @__NO_SIDE_EFFECTS__
  4084. */
  4085. declare function usePreferredContrast(options?: ConfigurableWindow): _$vue.ComputedRef<ContrastType>;
  4086. //#endregion
  4087. //#region usePreferredDark/index.d.ts
  4088. /**
  4089. * Reactive dark theme preference.
  4090. *
  4091. * @see https://vueuse.org/usePreferredDark
  4092. * @param [options]
  4093. *
  4094. * @__NO_SIDE_EFFECTS__
  4095. */
  4096. declare function usePreferredDark(options?: ConfigurableWindow): _$vue.ComputedRef<boolean>;
  4097. //#endregion
  4098. //#region usePreferredLanguages/index.d.ts
  4099. /**
  4100. * Reactive Navigator Languages.
  4101. *
  4102. * @see https://vueuse.org/usePreferredLanguages
  4103. * @param options
  4104. *
  4105. * @__NO_SIDE_EFFECTS__
  4106. */
  4107. declare function usePreferredLanguages(options?: ConfigurableWindow): ShallowRef<readonly string[]>;
  4108. //#endregion
  4109. //#region usePreferredReducedMotion/index.d.ts
  4110. type ReducedMotionType = 'reduce' | 'no-preference';
  4111. /**
  4112. * Reactive prefers-reduced-motion media query.
  4113. *
  4114. * @see https://vueuse.org/usePreferredReducedMotion
  4115. * @param [options]
  4116. *
  4117. * @__NO_SIDE_EFFECTS__
  4118. */
  4119. declare function usePreferredReducedMotion(options?: ConfigurableWindow): _$vue.ComputedRef<ReducedMotionType>;
  4120. //#endregion
  4121. //#region usePreferredReducedTransparency/index.d.ts
  4122. type ReducedTransparencyType = 'reduce' | 'no-preference';
  4123. /**
  4124. * Reactive prefers-reduced-transparency media query.
  4125. *
  4126. * @see https://vueuse.org/usePreferredReducedTransparency
  4127. * @param [options]
  4128. *
  4129. * @__NO_SIDE_EFFECTS__
  4130. */
  4131. declare function usePreferredReducedTransparency(options?: ConfigurableWindow): _$vue.ComputedRef<ReducedTransparencyType>;
  4132. //#endregion
  4133. //#region usePrevious/index.d.ts
  4134. /**
  4135. * Holds the previous value of a ref.
  4136. *
  4137. * @see {@link https://vueuse.org/usePrevious}
  4138. */
  4139. declare function usePrevious<T>(value: MaybeRefOrGetter<T>): Readonly<ShallowRef<T | undefined>>;
  4140. declare function usePrevious<T>(value: MaybeRefOrGetter<T>, initialValue: T): Readonly<ShallowRef<T>>;
  4141. //#endregion
  4142. //#region useRafFn/index.d.ts
  4143. interface UseRafFnCallbackArguments {
  4144. /**
  4145. * Time elapsed between this and the last frame.
  4146. */
  4147. delta: number;
  4148. /**
  4149. * Time elapsed since the creation of the web page. See {@link https://developer.mozilla.org/en-US/docs/Web/API/DOMHighResTimeStamp#the_time_origin Time origin}.
  4150. */
  4151. timestamp: DOMHighResTimeStamp;
  4152. }
  4153. interface UseRafFnOptions extends ConfigurableWindow {
  4154. /**
  4155. * Start the requestAnimationFrame loop immediately on creation
  4156. *
  4157. * @default true
  4158. */
  4159. immediate?: boolean;
  4160. /**
  4161. * The maximum frame per second to execute the function.
  4162. * Set to `null` to disable the limit.
  4163. *
  4164. * @default null
  4165. */
  4166. fpsLimit?: MaybeRefOrGetter<number | null>;
  4167. /**
  4168. * After the requestAnimationFrame loop executed once, it will be automatically stopped.
  4169. *
  4170. * @default false
  4171. */
  4172. once?: boolean;
  4173. }
  4174. /**
  4175. * Call function on every `requestAnimationFrame`. With controls of pausing and resuming.
  4176. *
  4177. * @see https://vueuse.org/useRafFn
  4178. * @param fn
  4179. * @param options
  4180. */
  4181. declare function useRafFn(fn: (args: UseRafFnCallbackArguments) => void, options?: UseRafFnOptions): Pausable;
  4182. //#endregion
  4183. //#region useSSRWidth/index.d.ts
  4184. declare function useSSRWidth(): number | undefined;
  4185. declare function provideSSRWidth(width: number | null, app?: App<unknown>): void;
  4186. //#endregion
  4187. //#region useScreenOrientation/index.d.ts
  4188. type OrientationType = 'portrait-primary' | 'portrait-secondary' | 'landscape-primary' | 'landscape-secondary';
  4189. type OrientationLockType = 'any' | 'natural' | 'landscape' | 'portrait' | 'portrait-primary' | 'portrait-secondary' | 'landscape-primary' | 'landscape-secondary';
  4190. interface ScreenOrientation extends EventTarget {
  4191. lock: (orientation: OrientationLockType) => Promise<void>;
  4192. unlock: () => void;
  4193. readonly type: OrientationType;
  4194. readonly angle: number;
  4195. addEventListener: (type: 'change', listener: (this: this, ev: Event) => any, useCapture?: boolean) => void;
  4196. }
  4197. interface UseScreenOrientationOptions extends ConfigurableWindow {}
  4198. interface UseScreenOrientationReturn extends Supportable {
  4199. orientation: ShallowRef<OrientationType | undefined>;
  4200. angle: ShallowRef<number>;
  4201. lockOrientation: (type: OrientationLockType) => Promise<void>;
  4202. unlockOrientation: () => void;
  4203. }
  4204. /**
  4205. * Reactive screen orientation
  4206. *
  4207. * @see https://vueuse.org/useScreenOrientation
  4208. *
  4209. * @__NO_SIDE_EFFECTS__
  4210. */
  4211. declare function useScreenOrientation(options?: UseScreenOrientationOptions): UseScreenOrientationReturn;
  4212. //#endregion
  4213. //#region useScreenSafeArea/index.d.ts
  4214. interface UseScreenSafeAreaReturn {
  4215. top: ShallowRef<string>;
  4216. right: ShallowRef<string>;
  4217. bottom: ShallowRef<string>;
  4218. left: ShallowRef<string>;
  4219. update: () => void;
  4220. }
  4221. /**
  4222. * Reactive `env(safe-area-inset-*)`
  4223. *
  4224. * @see https://vueuse.org/useScreenSafeArea
  4225. */
  4226. declare function useScreenSafeArea(): UseScreenSafeAreaReturn;
  4227. //#endregion
  4228. //#region useScriptTag/index.d.ts
  4229. interface UseScriptTagOptions extends ConfigurableDocument {
  4230. /**
  4231. * Load the script immediately
  4232. *
  4233. * @default true
  4234. */
  4235. immediate?: boolean;
  4236. /**
  4237. * Add `async` attribute to the script tag
  4238. *
  4239. * @default true
  4240. */
  4241. async?: boolean;
  4242. /**
  4243. * Script type
  4244. *
  4245. * @default 'text/javascript'
  4246. */
  4247. type?: string;
  4248. /**
  4249. * Manual controls the timing of loading and unloading
  4250. *
  4251. * @default false
  4252. */
  4253. manual?: boolean;
  4254. crossOrigin?: 'anonymous' | 'use-credentials';
  4255. referrerPolicy?: 'no-referrer' | 'no-referrer-when-downgrade' | 'origin' | 'origin-when-cross-origin' | 'same-origin' | 'strict-origin' | 'strict-origin-when-cross-origin' | 'unsafe-url';
  4256. noModule?: boolean;
  4257. defer?: boolean;
  4258. /**
  4259. * Add custom attribute to the script tag
  4260. *
  4261. */
  4262. attrs?: Record<string, string>;
  4263. /**
  4264. * Nonce value for CSP (Content Security Policy)
  4265. * @default undefined
  4266. */
  4267. nonce?: string;
  4268. }
  4269. interface UseScriptTagReturn {
  4270. scriptTag: ShallowRef<HTMLScriptElement | null>;
  4271. load: (waitForScriptLoad?: boolean) => Promise<HTMLScriptElement | boolean>;
  4272. unload: () => void;
  4273. }
  4274. /**
  4275. * Async script tag loading.
  4276. *
  4277. * @see https://vueuse.org/useScriptTag
  4278. * @param src
  4279. * @param onLoaded
  4280. * @param options
  4281. */
  4282. declare function useScriptTag(src: MaybeRefOrGetter<string>, onLoaded?: (el: HTMLScriptElement) => void, options?: UseScriptTagOptions): UseScriptTagReturn;
  4283. //#endregion
  4284. //#region useScrollLock/index.d.ts
  4285. /**
  4286. * Lock scrolling of the element.
  4287. *
  4288. * @see https://vueuse.org/useScrollLock
  4289. * @param element
  4290. */
  4291. declare function useScrollLock(element: MaybeRefOrGetter<HTMLElement | SVGElement | Window | Document | null | undefined>, initialState?: boolean): _$vue.WritableComputedRef<boolean, boolean>;
  4292. //#endregion
  4293. //#region useSessionStorage/index.d.ts
  4294. declare function useSessionStorage(key: MaybeRefOrGetter<string>, initialValue: MaybeRefOrGetter<string>, options?: UseStorageOptions<string>): RemovableRef<string>;
  4295. declare function useSessionStorage(key: MaybeRefOrGetter<string>, initialValue: MaybeRefOrGetter<boolean>, options?: UseStorageOptions<boolean>): RemovableRef<boolean>;
  4296. declare function useSessionStorage(key: MaybeRefOrGetter<string>, initialValue: MaybeRefOrGetter<number>, options?: UseStorageOptions<number>): RemovableRef<number>;
  4297. declare function useSessionStorage<T>(key: MaybeRefOrGetter<string>, initialValue: MaybeRefOrGetter<T>, options?: UseStorageOptions<T>): RemovableRef<T>;
  4298. declare function useSessionStorage<T = unknown>(key: MaybeRefOrGetter<string>, initialValue: MaybeRefOrGetter<null>, options?: UseStorageOptions<T>): RemovableRef<T>;
  4299. //#endregion
  4300. //#region useShare/index.d.ts
  4301. interface UseShareOptions {
  4302. title?: string;
  4303. files?: File[];
  4304. text?: string;
  4305. url?: string;
  4306. }
  4307. interface UseShareReturn extends Supportable {
  4308. share: (overrideOptions?: MaybeRefOrGetter<UseShareOptions>) => Promise<void>;
  4309. }
  4310. /**
  4311. * Reactive Web Share API.
  4312. *
  4313. * @see https://vueuse.org/useShare
  4314. * @param shareOptions
  4315. * @param options
  4316. *
  4317. * @__NO_SIDE_EFFECTS__
  4318. */
  4319. declare function useShare(shareOptions?: MaybeRefOrGetter<UseShareOptions>, options?: ConfigurableNavigator): UseShareReturn;
  4320. //#endregion
  4321. //#region useSorted/index.d.ts
  4322. type UseSortedCompareFn<T = any> = (a: T, b: T) => number;
  4323. type UseSortedFn<T = any> = (arr: T[], compareFn: UseSortedCompareFn<T>) => T[];
  4324. interface UseSortedOptions<T = any> {
  4325. /**
  4326. * sort algorithm
  4327. */
  4328. sortFn?: UseSortedFn<T>;
  4329. /**
  4330. * compare function
  4331. */
  4332. compareFn?: UseSortedCompareFn<T>;
  4333. /**
  4334. * change the value of the source array
  4335. * @default false
  4336. */
  4337. dirty?: boolean;
  4338. }
  4339. /**
  4340. * reactive sort array
  4341. *
  4342. * @see https://vueuse.org/useSorted
  4343. */
  4344. declare function useSorted<T = any>(source: MaybeRefOrGetter<T[]>, compareFn?: UseSortedCompareFn<T>): Ref<T[]>;
  4345. declare function useSorted<T = any>(source: MaybeRefOrGetter<T[]>, options?: UseSortedOptions<T>): Ref<T[]>;
  4346. declare function useSorted<T = any>(source: MaybeRefOrGetter<T[]>, compareFn?: UseSortedCompareFn<T>, options?: Omit<UseSortedOptions<T>, 'compareFn'>): Ref<T[]>;
  4347. //#endregion
  4348. //#region useSpeechRecognition/types.d.ts
  4349. type SpeechRecognitionErrorCode = 'aborted' | 'audio-capture' | 'bad-grammar' | 'language-not-supported' | 'network' | 'no-speech' | 'not-allowed' | 'service-not-allowed';
  4350. interface SpeechGrammar {
  4351. src: string;
  4352. weight: number;
  4353. }
  4354. interface SpeechGrammarList {
  4355. readonly length: number;
  4356. addFromString: (string: string, weight?: number) => void;
  4357. addFromURI: (src: string, weight?: number) => void;
  4358. item: (index: number) => SpeechGrammar;
  4359. [index: number]: SpeechGrammar;
  4360. }
  4361. interface SpeechRecognitionErrorEvent extends Event {
  4362. readonly error: SpeechRecognitionErrorCode;
  4363. readonly message: string;
  4364. }
  4365. interface SpeechRecognitionEvent extends Event {
  4366. readonly resultIndex: number;
  4367. readonly results: SpeechRecognitionResultList;
  4368. }
  4369. interface SpeechRecognitionEventMap {
  4370. audioend: Event;
  4371. audiostart: Event;
  4372. end: Event;
  4373. error: SpeechRecognitionErrorEvent;
  4374. nomatch: SpeechRecognitionEvent;
  4375. result: SpeechRecognitionEvent;
  4376. soundend: Event;
  4377. soundstart: Event;
  4378. speechend: Event;
  4379. speechstart: Event;
  4380. start: Event;
  4381. }
  4382. interface SpeechRecognition extends EventTarget {
  4383. continuous: boolean;
  4384. grammars: SpeechGrammarList;
  4385. interimResults: boolean;
  4386. lang: string;
  4387. maxAlternatives: number;
  4388. onaudioend: ((this: SpeechRecognition, ev: Event) => any) | null;
  4389. onaudiostart: ((this: SpeechRecognition, ev: Event) => any) | null;
  4390. onend: ((this: SpeechRecognition, ev: Event) => any) | null;
  4391. onerror: ((this: SpeechRecognition, ev: SpeechRecognitionErrorEvent) => any) | null;
  4392. onnomatch: ((this: SpeechRecognition, ev: SpeechRecognitionEvent) => any) | null;
  4393. onresult: ((this: SpeechRecognition, ev: SpeechRecognitionEvent) => any) | null;
  4394. onsoundend: ((this: SpeechRecognition, ev: Event) => any) | null;
  4395. onsoundstart: ((this: SpeechRecognition, ev: Event) => any) | null;
  4396. onspeechend: ((this: SpeechRecognition, ev: Event) => any) | null;
  4397. onspeechstart: ((this: SpeechRecognition, ev: Event) => any) | null;
  4398. onstart: ((this: SpeechRecognition, ev: Event) => any) | null;
  4399. abort: () => void;
  4400. start: () => void;
  4401. stop: () => void;
  4402. addEventListener: (<K extends keyof SpeechRecognitionEventMap>(type: K, listener: (this: SpeechRecognition, ev: SpeechRecognitionEventMap[K]) => any, options?: boolean | AddEventListenerOptions) => void) & ((type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions) => void);
  4403. removeEventListener: (<K extends keyof SpeechRecognitionEventMap>(type: K, listener: (this: SpeechRecognition, ev: SpeechRecognitionEventMap[K]) => any, options?: boolean | EventListenerOptions) => void) & ((type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions) => void);
  4404. }
  4405. //#endregion
  4406. //#region useSpeechRecognition/index.d.ts
  4407. interface UseSpeechRecognitionOptions extends ConfigurableWindow {
  4408. /**
  4409. * Controls whether continuous results are returned for each recognition, or only a single result.
  4410. *
  4411. * @default true
  4412. */
  4413. continuous?: boolean;
  4414. /**
  4415. * Controls whether interim results should be returned (true) or not (false.) Interim results are results that are not yet final
  4416. *
  4417. * @default true
  4418. */
  4419. interimResults?: boolean;
  4420. /**
  4421. * Language for SpeechRecognition
  4422. *
  4423. * @default 'en-US'
  4424. */
  4425. lang?: MaybeRefOrGetter<string>;
  4426. /**
  4427. * A number representing the maximum returned alternatives for each result.
  4428. *
  4429. * @see https://developer.mozilla.org/en-US/docs/Web/API/SpeechRecognition/maxAlternatives
  4430. * @default 1
  4431. */
  4432. maxAlternatives?: number;
  4433. }
  4434. interface UseSpeechRecognitionReturn extends Supportable {
  4435. isListening: ShallowRef<boolean>;
  4436. isFinal: ShallowRef<boolean>;
  4437. recognition: SpeechRecognition | undefined;
  4438. result: ShallowRef<string>;
  4439. error: ShallowRef<SpeechRecognitionErrorEvent | Error | undefined>;
  4440. toggle: (value?: boolean) => void;
  4441. start: () => void;
  4442. stop: () => void;
  4443. }
  4444. /**
  4445. * Reactive SpeechRecognition.
  4446. *
  4447. * @see https://vueuse.org/useSpeechRecognition
  4448. * @see https://developer.mozilla.org/en-US/docs/Web/API/SpeechRecognition SpeechRecognition
  4449. * @param options
  4450. */
  4451. declare function useSpeechRecognition(options?: UseSpeechRecognitionOptions): UseSpeechRecognitionReturn;
  4452. //#endregion
  4453. //#region useSpeechSynthesis/index.d.ts
  4454. type UseSpeechSynthesisStatus = 'init' | 'play' | 'pause' | 'end';
  4455. interface UseSpeechSynthesisOptions extends ConfigurableWindow {
  4456. /**
  4457. * Language for SpeechSynthesis
  4458. *
  4459. * @default 'en-US'
  4460. */
  4461. lang?: MaybeRefOrGetter<string>;
  4462. /**
  4463. * Gets and sets the pitch at which the utterance will be spoken at.
  4464. *
  4465. * @default 1
  4466. */
  4467. pitch?: MaybeRefOrGetter<SpeechSynthesisUtterance['pitch']>;
  4468. /**
  4469. * Gets and sets the speed at which the utterance will be spoken at.
  4470. *
  4471. * @default 1
  4472. */
  4473. rate?: MaybeRefOrGetter<SpeechSynthesisUtterance['rate']>;
  4474. /**
  4475. * Gets and sets the voice that will be used to speak the utterance.
  4476. */
  4477. voice?: MaybeRef<SpeechSynthesisVoice>;
  4478. /**
  4479. * Gets and sets the volume that the utterance will be spoken at.
  4480. *
  4481. * @default 1
  4482. */
  4483. volume?: MaybeRefOrGetter<SpeechSynthesisUtterance['volume']>;
  4484. /**
  4485. * Callback function that is called when the boundary event is triggered.
  4486. */
  4487. onBoundary?: (event: SpeechSynthesisEvent) => void;
  4488. }
  4489. interface UseSpeechSynthesisReturn extends Supportable {
  4490. isPlaying: ShallowRef<boolean>;
  4491. status: ShallowRef<UseSpeechSynthesisStatus>;
  4492. utterance: ComputedRef<SpeechSynthesisUtterance>;
  4493. error: ShallowRef<SpeechSynthesisErrorEvent | undefined>;
  4494. stop: () => void;
  4495. toggle: (value?: boolean) => void;
  4496. speak: () => void;
  4497. }
  4498. /**
  4499. * Reactive SpeechSynthesis.
  4500. *
  4501. * @see https://vueuse.org/useSpeechSynthesis
  4502. * @see https://developer.mozilla.org/en-US/docs/Web/API/SpeechSynthesis SpeechSynthesis
  4503. */
  4504. declare function useSpeechSynthesis(text: MaybeRefOrGetter<string>, options?: UseSpeechSynthesisOptions): UseSpeechSynthesisReturn;
  4505. //#endregion
  4506. //#region useStepper/index.d.ts
  4507. interface UseStepperReturn<StepName, Steps, Step> {
  4508. /** List of steps. */
  4509. steps: Readonly<Ref<Steps>>;
  4510. /** List of step names. */
  4511. stepNames: Readonly<Ref<StepName[]>>;
  4512. /** Index of the current step. */
  4513. index: Ref<number>;
  4514. /** Current step. */
  4515. current: ComputedRef<Step>;
  4516. /** Next step, or undefined if the current step is the last one. */
  4517. next: ComputedRef<StepName | undefined>;
  4518. /** Previous step, or undefined if the current step is the first one. */
  4519. previous: ComputedRef<StepName | undefined>;
  4520. /** Whether the current step is the first one. */
  4521. isFirst: ComputedRef<boolean>;
  4522. /** Whether the current step is the last one. */
  4523. isLast: ComputedRef<boolean>;
  4524. /** Get the step at the specified index. */
  4525. at: (index: number) => Step | undefined;
  4526. /** Get a step by the specified name. */
  4527. get: (step: StepName) => Step | undefined;
  4528. /** Go to the specified step. */
  4529. goTo: (step: StepName) => void;
  4530. /** Go to the next step. Does nothing if the current step is the last one. */
  4531. goToNext: () => void;
  4532. /** Go to the previous step. Does nothing if the current step is the previous one. */
  4533. goToPrevious: () => void;
  4534. /** Go back to the given step, only if the current step is after. */
  4535. goBackTo: (step: StepName) => void;
  4536. /** Checks whether the given step is the next step. */
  4537. isNext: (step: StepName) => boolean;
  4538. /** Checks whether the given step is the previous step. */
  4539. isPrevious: (step: StepName) => boolean;
  4540. /** Checks whether the given step is the current step. */
  4541. isCurrent: (step: StepName) => boolean;
  4542. /** Checks if the current step is before the given step. */
  4543. isBefore: (step: StepName) => boolean;
  4544. /** Checks if the current step is after the given step. */
  4545. isAfter: (step: StepName) => boolean;
  4546. }
  4547. declare function useStepper<T extends string | number>(steps: MaybeRef<T[]>, initialStep?: T): UseStepperReturn<T, T[], T>;
  4548. declare function useStepper<T extends Record<string, any>>(steps: MaybeRef<T>, initialStep?: keyof T): UseStepperReturn<Exclude<keyof T, symbol>, T, T[keyof T]>;
  4549. //#endregion
  4550. //#region useStorageAsync/index.d.ts
  4551. interface UseStorageAsyncOptions<T> extends Omit<UseStorageOptions<T>, 'serializer'> {
  4552. /**
  4553. * Custom data serialization
  4554. */
  4555. serializer?: SerializerAsync<T>;
  4556. /**
  4557. * On first value loaded hook.
  4558. */
  4559. onReady?: (value: T) => void;
  4560. }
  4561. declare function useStorageAsync(key: string, initialValue: MaybeRefOrGetter<string>, storage?: StorageLikeAsync, options?: UseStorageAsyncOptions<string>): RemovableRef<string> & Promise<RemovableRef<string>>;
  4562. declare function useStorageAsync(key: string, initialValue: MaybeRefOrGetter<boolean>, storage?: StorageLikeAsync, options?: UseStorageAsyncOptions<boolean>): RemovableRef<boolean> & Promise<RemovableRef<boolean>>;
  4563. declare function useStorageAsync(key: string, initialValue: MaybeRefOrGetter<number>, storage?: StorageLikeAsync, options?: UseStorageAsyncOptions<number>): RemovableRef<number> & Promise<RemovableRef<number>>;
  4564. declare function useStorageAsync<T>(key: string, initialValue: MaybeRefOrGetter<T>, storage?: StorageLikeAsync, options?: UseStorageAsyncOptions<T>): RemovableRef<T> & Promise<RemovableRef<T>>;
  4565. declare function useStorageAsync<T = unknown>(key: string, initialValue: MaybeRefOrGetter<null>, storage?: StorageLikeAsync, options?: UseStorageAsyncOptions<T>): RemovableRef<T> & Promise<RemovableRef<T>>;
  4566. //#endregion
  4567. //#region useStyleTag/index.d.ts
  4568. interface UseStyleTagOptions extends ConfigurableDocument {
  4569. /**
  4570. * Media query for styles to apply
  4571. */
  4572. media?: string;
  4573. /**
  4574. * Load the style immediately
  4575. *
  4576. * @default true
  4577. */
  4578. immediate?: boolean;
  4579. /**
  4580. * Manual controls the timing of loading and unloading
  4581. *
  4582. * @default false
  4583. */
  4584. manual?: boolean;
  4585. /**
  4586. * DOM id of the style tag
  4587. *
  4588. * @default auto-incremented
  4589. */
  4590. id?: string;
  4591. /**
  4592. * Nonce value for CSP (Content Security Policy)
  4593. *
  4594. * @default undefined
  4595. */
  4596. nonce?: string;
  4597. }
  4598. interface UseStyleTagReturn {
  4599. id: string;
  4600. css: ShallowRef<string>;
  4601. load: () => void;
  4602. unload: () => void;
  4603. isLoaded: Readonly<ShallowRef<boolean>>;
  4604. }
  4605. /**
  4606. * Inject <style> element in head.
  4607. *
  4608. * Overload: Omitted id
  4609. *
  4610. * @see https://vueuse.org/useStyleTag
  4611. * @param css
  4612. * @param options
  4613. */
  4614. declare function useStyleTag(css: MaybeRef<string>, options?: UseStyleTagOptions): UseStyleTagReturn;
  4615. //#endregion
  4616. //#region useSupported/index.d.ts
  4617. type UseSupportedReturn = ComputedRef<boolean>;
  4618. declare function useSupported(callback: () => unknown): UseSupportedReturn;
  4619. //#endregion
  4620. //#region useTemplateRefsList/index.d.ts
  4621. type TemplateRefsList<T> = T[] & {
  4622. set: (el: object | null) => void;
  4623. };
  4624. declare function useTemplateRefsList<T = Element>(): Readonly<Ref<Readonly<TemplateRefsList<T>>>>;
  4625. //#endregion
  4626. //#region useTextDirection/index.d.ts
  4627. type UseTextDirectionValue = 'ltr' | 'rtl' | 'auto';
  4628. interface UseTextDirectionOptions extends ConfigurableDocument {
  4629. /**
  4630. * CSS Selector for the target element applying to
  4631. *
  4632. * @default 'html'
  4633. */
  4634. selector?: string;
  4635. /**
  4636. * Observe `document.querySelector(selector)` changes using MutationObserve
  4637. *
  4638. * @default false
  4639. */
  4640. observe?: boolean;
  4641. /**
  4642. * Initial value
  4643. *
  4644. * @default 'ltr'
  4645. */
  4646. initialValue?: UseTextDirectionValue;
  4647. }
  4648. /**
  4649. * Reactive dir of the element's text.
  4650. *
  4651. * @see https://vueuse.org/useTextDirection
  4652. *
  4653. * @__NO_SIDE_EFFECTS__
  4654. */
  4655. declare function useTextDirection(options?: UseTextDirectionOptions): _$vue.WritableComputedRef<UseTextDirectionValue, UseTextDirectionValue>;
  4656. //#endregion
  4657. //#region useTextSelection/index.d.ts
  4658. interface UseTextSelectionOptions extends ConfigurableWindow {}
  4659. interface UseTextSelectionReturn {
  4660. text: ComputedRef<string>;
  4661. rects: ComputedRef<DOMRect[]>;
  4662. ranges: ComputedRef<Range[]>;
  4663. selection: ShallowRef<Selection | null>;
  4664. }
  4665. /**
  4666. * Reactively track user text selection based on [`Window.getSelection`](https://developer.mozilla.org/en-US/docs/Web/API/Window/getSelection).
  4667. *
  4668. * @see https://vueuse.org/useTextSelection
  4669. *
  4670. * @__NO_SIDE_EFFECTS__
  4671. */
  4672. declare function useTextSelection(options?: UseTextSelectionOptions): UseTextSelectionReturn;
  4673. //#endregion
  4674. //#region useTextareaAutosize/index.d.ts
  4675. interface UseTextareaAutosizeOptions extends ConfigurableWindow {
  4676. /** Textarea element to autosize. */
  4677. element?: MaybeRef<HTMLTextAreaElement | undefined | null>;
  4678. /** Textarea content. */
  4679. input?: MaybeRef<string>;
  4680. /** Maximum autosized height in pixels. */
  4681. maxHeight?: number;
  4682. /** Watch sources that should trigger a textarea resize. */
  4683. watch?: WatchSource | MultiWatchSources;
  4684. /** Function called when the textarea size changes. */
  4685. onResize?: () => void;
  4686. /** Specify style target to apply the height based on textarea content. If not provided it will use textarea it self. */
  4687. styleTarget?: MaybeRef<HTMLElement | undefined>;
  4688. /** Specify the style property that will be used to manipulate height. Can be `height | minHeight`. Default value is `height`. */
  4689. styleProp?: 'height' | 'minHeight';
  4690. }
  4691. interface UseTextareaAutosizeReturn {
  4692. textarea: Ref<HTMLTextAreaElement | undefined | null>;
  4693. input: Ref<string>;
  4694. triggerResize: () => void;
  4695. }
  4696. declare function useTextareaAutosize(options?: UseTextareaAutosizeOptions): UseTextareaAutosizeReturn;
  4697. //#endregion
  4698. //#region useThrottledRefHistory/index.d.ts
  4699. type UseThrottledRefHistoryOptions<Raw, Serialized = Raw> = Omit<UseRefHistoryOptions<Raw, Serialized>, 'eventFilter'> & {
  4700. throttle?: MaybeRef<number>;
  4701. trailing?: boolean;
  4702. };
  4703. type UseThrottledRefHistoryReturn<Raw, Serialized = Raw> = UseRefHistoryReturn<Raw, Serialized>;
  4704. /**
  4705. * Shorthand for [useRefHistory](https://vueuse.org/useRefHistory) with throttled filter.
  4706. *
  4707. * @see https://vueuse.org/useThrottledRefHistory
  4708. * @param source
  4709. * @param options
  4710. */
  4711. declare function useThrottledRefHistory<Raw, Serialized = Raw>(source: Ref<Raw>, options?: UseThrottledRefHistoryOptions<Raw, Serialized>): UseThrottledRefHistoryReturn<Raw, Serialized>;
  4712. //#endregion
  4713. //#region useTimeAgo/index.d.ts
  4714. type UseTimeAgoFormatter<T = number> = (value: T, isPast: boolean) => string;
  4715. type UseTimeAgoUnitNamesDefault = 'second' | 'minute' | 'hour' | 'day' | 'week' | 'month' | 'year';
  4716. interface UseTimeAgoMessagesBuiltIn {
  4717. justNow: string;
  4718. past: string | UseTimeAgoFormatter<string>;
  4719. future: string | UseTimeAgoFormatter<string>;
  4720. invalid: string;
  4721. }
  4722. type UseTimeAgoMessages<UnitNames extends string = UseTimeAgoUnitNamesDefault> = UseTimeAgoMessagesBuiltIn & Record<UnitNames, string | UseTimeAgoFormatter<number>>;
  4723. interface FormatTimeAgoOptions<UnitNames extends string = UseTimeAgoUnitNamesDefault> {
  4724. /**
  4725. * Maximum unit (of diff in milliseconds) to display the full date instead of relative
  4726. *
  4727. * @default undefined
  4728. */
  4729. max?: UnitNames | number;
  4730. /**
  4731. * Formatter for full date
  4732. */
  4733. fullDateFormatter?: (date: Date) => string;
  4734. /**
  4735. * Messages for formatting the string
  4736. */
  4737. messages?: UseTimeAgoMessages<UnitNames>;
  4738. /**
  4739. * Minimum display time unit (default is minute)
  4740. *
  4741. * @default false
  4742. */
  4743. showSecond?: boolean;
  4744. /**
  4745. * Rounding method to apply.
  4746. *
  4747. * @default 'round'
  4748. */
  4749. rounding?: 'round' | 'ceil' | 'floor' | number;
  4750. /**
  4751. * Custom units
  4752. */
  4753. units?: UseTimeAgoUnit<UnitNames>[];
  4754. }
  4755. interface UseTimeAgoOptions<Controls extends boolean, UnitNames extends string = UseTimeAgoUnitNamesDefault> extends FormatTimeAgoOptions<UnitNames>, ConfigurableScheduler {
  4756. /**
  4757. * Expose more controls
  4758. *
  4759. * @default false
  4760. */
  4761. controls?: Controls;
  4762. /**
  4763. * Intervals to update, set 0 to disable auto update
  4764. *
  4765. * @deprecated Please use `scheduler` option instead
  4766. * @default 30_000
  4767. */
  4768. updateInterval?: number;
  4769. }
  4770. interface UseTimeAgoUnit<Unit extends string = UseTimeAgoUnitNamesDefault> {
  4771. max: number;
  4772. value: number;
  4773. name: Unit;
  4774. }
  4775. type UseTimeAgoReturn<Controls extends boolean = false> = Controls extends true ? {
  4776. timeAgo: ComputedRef<string>;
  4777. } & Pausable : ComputedRef<string>;
  4778. /**
  4779. * Reactive time ago formatter.
  4780. *
  4781. * @see https://vueuse.org/useTimeAgo
  4782. *
  4783. * @__NO_SIDE_EFFECTS__
  4784. */
  4785. declare function useTimeAgo<UnitNames extends string = UseTimeAgoUnitNamesDefault>(time: MaybeRefOrGetter<Date | number | string>, options?: UseTimeAgoOptions<false, UnitNames>): UseTimeAgoReturn<false>;
  4786. declare function useTimeAgo<UnitNames extends string = UseTimeAgoUnitNamesDefault>(time: MaybeRefOrGetter<Date | number | string>, options: UseTimeAgoOptions<true, UnitNames>): UseTimeAgoReturn<true>;
  4787. declare function formatTimeAgo<UnitNames extends string = UseTimeAgoUnitNamesDefault>(from: Date, options?: FormatTimeAgoOptions<UnitNames>, now?: Date | number): string;
  4788. //#endregion
  4789. //#region useTimeAgoIntl/index.d.ts
  4790. type Locale = Intl.UnicodeBCP47LocaleIdentifier | Intl.Locale;
  4791. interface FormatTimeAgoIntlOptions {
  4792. /**
  4793. * The locale to format with
  4794. *
  4795. * @default undefined
  4796. * @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/RelativeTimeFormat/RelativeTimeFormat#locales
  4797. */
  4798. locale?: Locale;
  4799. /**
  4800. * @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/RelativeTimeFormat/RelativeTimeFormat#options
  4801. */
  4802. relativeTimeFormatOptions?: Intl.RelativeTimeFormatOptions;
  4803. /**
  4804. * Whether to insert spaces between parts.
  4805. *
  4806. * Ignored if `joinParts` is provided.
  4807. *
  4808. * @default true
  4809. */
  4810. insertSpace?: boolean;
  4811. /**
  4812. * Custom function to join the parts returned by `Intl.RelativeTimeFormat.formatToParts`.
  4813. *
  4814. * If provided, it will be used instead of the default join logic.
  4815. */
  4816. joinParts?: (parts: Intl.RelativeTimeFormatPart[], locale?: Intl.UnicodeBCP47LocaleIdentifier | Intl.Locale) => string;
  4817. /**
  4818. * Custom units
  4819. */
  4820. units?: TimeAgoUnit[];
  4821. }
  4822. interface UseTimeAgoIntlOptions<Controls extends boolean> extends FormatTimeAgoIntlOptions, ConfigurableScheduler {
  4823. /**
  4824. * Expose more controls and the raw `parts` result.
  4825. *
  4826. * @default false
  4827. */
  4828. controls?: Controls;
  4829. /**
  4830. * Update interval in milliseconds, set 0 to disable auto update
  4831. *
  4832. * @deprecated Please use `scheduler` option instead
  4833. * @default 30_000
  4834. */
  4835. updateInterval?: number;
  4836. }
  4837. type UseTimeAgoReturn$1<Controls extends boolean = false> = Controls extends true ? {
  4838. timeAgoIntl: ComputedRef<string>;
  4839. parts: ComputedRef<Intl.RelativeTimeFormatPart[]>;
  4840. } & Pausable : ComputedRef<string>;
  4841. interface TimeAgoUnit {
  4842. name: Intl.RelativeTimeFormatUnit;
  4843. ms: number;
  4844. }
  4845. /**
  4846. * A reactive wrapper for `Intl.RelativeTimeFormat`.
  4847. */
  4848. declare function useTimeAgoIntl(time: MaybeRefOrGetter<Date | number | string>, options?: UseTimeAgoIntlOptions<false>): UseTimeAgoReturn$1<false>;
  4849. declare function useTimeAgoIntl(time: MaybeRefOrGetter<Date | number | string>, options: UseTimeAgoIntlOptions<true>): UseTimeAgoReturn$1<true>;
  4850. /**
  4851. * Non-reactive version of useTimeAgoIntl
  4852. */
  4853. declare function formatTimeAgoIntl(from: Date, options?: FormatTimeAgoIntlOptions, now?: Date | number): string;
  4854. /**
  4855. * Format parts into a string
  4856. */
  4857. declare function formatTimeAgoIntlParts(parts: Intl.RelativeTimeFormatPart[], options?: FormatTimeAgoIntlOptions): string;
  4858. //#endregion
  4859. //#region useTimeoutPoll/index.d.ts
  4860. interface UseTimeoutPollOptions {
  4861. /**
  4862. * Start the timer immediately
  4863. *
  4864. * @default true
  4865. */
  4866. immediate?: boolean;
  4867. /**
  4868. * Execute the callback immediately after calling `resume`
  4869. *
  4870. * @default false
  4871. */
  4872. immediateCallback?: boolean;
  4873. }
  4874. declare function useTimeoutPoll(fn: () => Awaitable<void>, interval: MaybeRefOrGetter<number>, options?: UseTimeoutFnOptions): Pausable;
  4875. //#endregion
  4876. //#region useTimestamp/index.d.ts
  4877. interface UseTimestampOptions<Controls extends boolean> extends ConfigurableScheduler {
  4878. /**
  4879. * Expose more controls
  4880. *
  4881. * @default false
  4882. */
  4883. controls?: Controls;
  4884. /**
  4885. * Offset value adding to the value
  4886. *
  4887. * @default 0
  4888. */
  4889. offset?: number;
  4890. /**
  4891. * Update the timestamp immediately
  4892. *
  4893. * @deprecated Please use `scheduler` option instead
  4894. * @default true
  4895. */
  4896. immediate?: boolean;
  4897. /**
  4898. * Update interval, or use requestAnimationFrame
  4899. *
  4900. * @deprecated Please use `scheduler` option instead
  4901. * @default requestAnimationFrame
  4902. */
  4903. interval?: 'requestAnimationFrame' | number;
  4904. /**
  4905. * Callback on each update
  4906. */
  4907. callback?: (timestamp: number) => void;
  4908. }
  4909. type UseTimestampReturn<Controls extends boolean> = Controls extends true ? ({
  4910. timestamp: ShallowRef<number>;
  4911. } & Pausable) : ShallowRef<number>;
  4912. /**
  4913. * Reactive current timestamp.
  4914. *
  4915. * @see https://vueuse.org/useTimestamp
  4916. * @param options
  4917. */
  4918. declare function useTimestamp(options?: UseTimestampOptions<false>): ShallowRef<number>;
  4919. declare function useTimestamp(options: UseTimestampOptions<true>): {
  4920. timestamp: ShallowRef<number>;
  4921. } & Pausable;
  4922. //#endregion
  4923. //#region useTitle/index.d.ts
  4924. type UseTitleOptionsBase = {
  4925. /**
  4926. * Restore the original title when unmounted
  4927. * @param originTitle original title
  4928. * @returns restored title
  4929. */
  4930. restoreOnUnmount?: false | ((originalTitle: string, currentTitle: string) => string | null | undefined);
  4931. } & ({
  4932. /**
  4933. * Observe `document.title` changes using MutationObserve
  4934. * Cannot be used together with `titleTemplate` option.
  4935. *
  4936. * @default false
  4937. */
  4938. observe?: boolean;
  4939. } | {
  4940. /**
  4941. * The template string to parse the title (e.g., '%s | My Website')
  4942. * Cannot be used together with `observe` option.
  4943. *
  4944. * @default '%s'
  4945. */
  4946. titleTemplate?: MaybeRef<string> | ((title: string) => string);
  4947. });
  4948. type UseTitleOptions = ConfigurableDocument & UseTitleOptionsBase;
  4949. type UseTitleReturn = ComputedRef<string | null | undefined> | Ref<string | null | undefined>;
  4950. /**
  4951. * Reactive document title.
  4952. *
  4953. * @see https://vueuse.org/useTitle
  4954. * @param newTitle
  4955. * @param options
  4956. * @description It's not SSR compatible. Your value will be applied only on client-side.
  4957. */
  4958. declare function useTitle(newTitle: ReadonlyRefOrGetter<string | null | undefined>, options?: UseTitleOptions): ComputedRef<string | null | undefined>;
  4959. declare function useTitle(newTitle?: MaybeRef<string | null | undefined>, options?: UseTitleOptions): Ref<string | null | undefined>;
  4960. //#endregion
  4961. //#region useTransition/index.d.ts
  4962. /**
  4963. * Cubic bezier points
  4964. */
  4965. type CubicBezierPoints = [number, number, number, number];
  4966. /**
  4967. * Easing function
  4968. */
  4969. type EasingFunction = (n: number) => number;
  4970. /**
  4971. * Interpolation function
  4972. */
  4973. type InterpolationFunction<T> = (from: T, to: T, t: number) => T;
  4974. /**
  4975. * Transition options
  4976. */
  4977. interface TransitionOptions<T> extends ConfigurableWindow {
  4978. /**
  4979. * Manually abort a transition
  4980. */
  4981. abort?: () => any;
  4982. /**
  4983. * Transition duration in milliseconds
  4984. */
  4985. duration?: MaybeRef<number>;
  4986. /**
  4987. * Easing function or cubic bezier points to calculate transition progress
  4988. */
  4989. easing?: MaybeRef<EasingFunction | CubicBezierPoints>;
  4990. /**
  4991. * Custom interpolation function
  4992. */
  4993. interpolation?: InterpolationFunction<T>;
  4994. /**
  4995. * Easing function or cubic bezier points to calculate transition progress
  4996. * @deprecated The `transition` option is deprecated, use `easing` instead.
  4997. */
  4998. transition?: MaybeRef<EasingFunction | CubicBezierPoints>;
  4999. }
  5000. interface UseTransitionOptions<T> extends TransitionOptions<T> {
  5001. /**
  5002. * Milliseconds to wait before starting transition
  5003. */
  5004. delay?: MaybeRef<number>;
  5005. /**
  5006. * Disables the transition
  5007. */
  5008. disabled?: MaybeRef<boolean>;
  5009. /**
  5010. * Callback to execute after transition finishes
  5011. */
  5012. onFinished?: () => void;
  5013. /**
  5014. * Callback to execute after transition starts
  5015. */
  5016. onStarted?: () => void;
  5017. }
  5018. declare const _TransitionPresets: {
  5019. readonly easeInSine: readonly [0.12, 0, 0.39, 0];
  5020. readonly easeOutSine: readonly [0.61, 1, 0.88, 1];
  5021. readonly easeInOutSine: readonly [0.37, 0, 0.63, 1];
  5022. readonly easeInQuad: readonly [0.11, 0, 0.5, 0];
  5023. readonly easeOutQuad: readonly [0.5, 1, 0.89, 1];
  5024. readonly easeInOutQuad: readonly [0.45, 0, 0.55, 1];
  5025. readonly easeInCubic: readonly [0.32, 0, 0.67, 0];
  5026. readonly easeOutCubic: readonly [0.33, 1, 0.68, 1];
  5027. readonly easeInOutCubic: readonly [0.65, 0, 0.35, 1];
  5028. readonly easeInQuart: readonly [0.5, 0, 0.75, 0];
  5029. readonly easeOutQuart: readonly [0.25, 1, 0.5, 1];
  5030. readonly easeInOutQuart: readonly [0.76, 0, 0.24, 1];
  5031. readonly easeInQuint: readonly [0.64, 0, 0.78, 0];
  5032. readonly easeOutQuint: readonly [0.22, 1, 0.36, 1];
  5033. readonly easeInOutQuint: readonly [0.83, 0, 0.17, 1];
  5034. readonly easeInExpo: readonly [0.7, 0, 0.84, 0];
  5035. readonly easeOutExpo: readonly [0.16, 1, 0.3, 1];
  5036. readonly easeInOutExpo: readonly [0.87, 0, 0.13, 1];
  5037. readonly easeInCirc: readonly [0.55, 0, 1, 0.45];
  5038. readonly easeOutCirc: readonly [0, 0.55, 0.45, 1];
  5039. readonly easeInOutCirc: readonly [0.85, 0, 0.15, 1];
  5040. readonly easeInBack: readonly [0.36, 0, 0.66, -0.56];
  5041. readonly easeOutBack: readonly [0.34, 1.56, 0.64, 1];
  5042. readonly easeInOutBack: readonly [0.68, -0.6, 0.32, 1.6];
  5043. };
  5044. /**
  5045. * Common transitions
  5046. *
  5047. * @see https://easings.net
  5048. */
  5049. declare const TransitionPresets: Record<keyof typeof _TransitionPresets, CubicBezierPoints> & {
  5050. linear: EasingFunction;
  5051. };
  5052. /**
  5053. * Transition from one value to another.
  5054. *
  5055. * @param source
  5056. * @param from
  5057. * @param to
  5058. * @param options
  5059. */
  5060. declare function transition<T>(source: Ref<T>, from: MaybeRefOrGetter<T>, to: MaybeRefOrGetter<T>, options?: TransitionOptions<T>): PromiseLike<void>;
  5061. /**
  5062. * Transition from one value to another.
  5063. * @deprecated The `executeTransition` function is deprecated, use `transition` instead.
  5064. *
  5065. * @param source
  5066. * @param from
  5067. * @param to
  5068. * @param options
  5069. */
  5070. declare function executeTransition<T>(source: Ref<T>, from: MaybeRefOrGetter<T>, to: MaybeRefOrGetter<T>, options?: TransitionOptions<T>): PromiseLike<void>;
  5071. declare function useTransition<T extends MaybeRefOrGetter<number>[]>(source: [...T], options?: UseTransitionOptions<T>): ComputedRef<{ [K in keyof T]: number }>;
  5072. declare function useTransition<T extends MaybeRefOrGetter<number[]>>(source: T, options?: UseTransitionOptions<T>): ComputedRef<number[]>;
  5073. declare function useTransition<T>(source: MaybeRefOrGetter<T>, options?: UseTransitionOptions<T>): ComputedRef<T>;
  5074. //#endregion
  5075. //#region useUrlSearchParams/index.d.ts
  5076. type UrlParams = Record<string, string[] | string>;
  5077. interface UseUrlSearchParamsOptions<T> extends ConfigurableWindow {
  5078. /**
  5079. * @default true
  5080. */
  5081. removeNullishValues?: boolean;
  5082. /**
  5083. * @default false
  5084. */
  5085. removeFalsyValues?: boolean;
  5086. /**
  5087. * @default {}
  5088. */
  5089. initialValue?: T;
  5090. /**
  5091. * Write back to `window.history` automatically
  5092. *
  5093. * @default true
  5094. */
  5095. write?: boolean;
  5096. /**
  5097. * Write mode for `window.history` when `write` is enabled
  5098. * - `replace`: replace the current history entry
  5099. * - `push`: push a new history entry
  5100. * @default 'replace'
  5101. */
  5102. writeMode?: 'replace' | 'push';
  5103. /**
  5104. * Custom function to serialize URL parameters
  5105. * When provided, this function will be used instead of the default URLSearchParams.toString()
  5106. * @param params The URLSearchParams object to serialize
  5107. * @returns The serialized query string (should not include the leading '?' or '#')
  5108. */
  5109. stringify?: (params: URLSearchParams) => string;
  5110. }
  5111. /**
  5112. * Reactive URLSearchParams
  5113. *
  5114. * @see https://vueuse.org/useUrlSearchParams
  5115. * @param mode
  5116. * @param options
  5117. */
  5118. declare function useUrlSearchParams<T extends Record<string, any> = UrlParams>(mode?: 'history' | 'hash' | 'hash-params', options?: UseUrlSearchParamsOptions<T>): T;
  5119. //#endregion
  5120. //#region useUserMedia/index.d.ts
  5121. interface UseUserMediaOptions extends ConfigurableNavigator {
  5122. /**
  5123. * If the stream is enabled
  5124. * @default false
  5125. */
  5126. enabled?: MaybeRef<boolean>;
  5127. /**
  5128. * Recreate stream when deviceIds or constraints changed
  5129. *
  5130. * @default true
  5131. */
  5132. autoSwitch?: MaybeRef<boolean>;
  5133. /**
  5134. * MediaStreamConstraints to be applied to the requested MediaStream
  5135. * If provided, the constraints will override videoDeviceId and audioDeviceId
  5136. *
  5137. * @default {}
  5138. */
  5139. constraints?: MaybeRef<MediaStreamConstraints>;
  5140. }
  5141. interface UseUserMediaReturn extends Supportable {
  5142. stream: Ref<MediaStream | undefined>;
  5143. start: () => Promise<MediaStream | undefined>;
  5144. stop: () => void;
  5145. restart: () => Promise<MediaStream | undefined>;
  5146. constraints: Ref<MediaStreamConstraints | undefined>;
  5147. enabled: ShallowRef<boolean>;
  5148. autoSwitch: ShallowRef<boolean>;
  5149. }
  5150. /**
  5151. * Reactive `mediaDevices.getUserMedia` streaming
  5152. *
  5153. * @see https://vueuse.org/useUserMedia
  5154. * @param options
  5155. */
  5156. declare function useUserMedia(options?: UseUserMediaOptions): UseUserMediaReturn;
  5157. //#endregion
  5158. //#region useVModel/index.d.ts
  5159. interface UseVModelOptions<T, Passive extends boolean = false> {
  5160. /**
  5161. * When passive is set to `true`, it will use `watch` to sync with props and ref.
  5162. * Instead of relying on the `v-model` or `.sync` to work.
  5163. *
  5164. * @default false
  5165. */
  5166. passive?: Passive;
  5167. /**
  5168. * When eventName is set, it's value will be used to overwrite the emit event name.
  5169. *
  5170. * @default undefined
  5171. */
  5172. eventName?: string;
  5173. /**
  5174. * Attempting to check for changes of properties in a deeply nested object or array.
  5175. * Apply only when `passive` option is set to `true`
  5176. *
  5177. * @default false
  5178. */
  5179. deep?: boolean;
  5180. /**
  5181. * Defining default value for return ref when no value is passed.
  5182. *
  5183. * @default undefined
  5184. */
  5185. defaultValue?: T;
  5186. /**
  5187. * Clone the props.
  5188. * Accepts a custom clone function.
  5189. * When setting to `true`, it will use `JSON.parse(JSON.stringify(value))` to clone.
  5190. *
  5191. * @default false
  5192. */
  5193. clone?: boolean | CloneFn<T>;
  5194. /**
  5195. * The hook before triggering the emit event can be used for form validation.
  5196. * if false is returned, the emit event will not be triggered.
  5197. *
  5198. * @default undefined
  5199. */
  5200. shouldEmit?: (v: T) => boolean;
  5201. }
  5202. /**
  5203. * Shorthand for v-model binding, props + emit -> ref
  5204. *
  5205. * @see https://vueuse.org/useVModel
  5206. * @param props
  5207. * @param key (default 'modelValue')
  5208. * @param emit
  5209. * @param options
  5210. *
  5211. * @__NO_SIDE_EFFECTS__
  5212. */
  5213. declare function useVModel<P extends object, K extends keyof P, Name extends string>(props: P, key?: K, emit?: (name: Name, ...args: any[]) => void, options?: UseVModelOptions<P[K], false>): WritableComputedRef<P[K]>;
  5214. declare function useVModel<P extends object, K extends keyof P, Name extends string>(props: P, key?: K, emit?: (name: Name, ...args: any[]) => void, options?: UseVModelOptions<P[K], true>): Ref<UnwrapRef<P[K]>>;
  5215. //#endregion
  5216. //#region useVModels/index.d.ts
  5217. /**
  5218. * Shorthand for props v-model binding. Think like `toRefs(props)` but changes will also emit out.
  5219. *
  5220. * @see https://vueuse.org/useVModels
  5221. * @param props
  5222. * @param emit
  5223. * @param options
  5224. *
  5225. * @__NO_SIDE_EFFECTS__
  5226. */
  5227. declare function useVModels<P extends object, Name extends string>(props: P, emit?: (name: Name, ...args: any[]) => void, options?: UseVModelOptions<any, true>): ToRefs<P>;
  5228. declare function useVModels<P extends object, Name extends string>(props: P, emit?: (name: Name, ...args: any[]) => void, options?: UseVModelOptions<any, false>): ToRefs<P>;
  5229. //#endregion
  5230. //#region useVibrate/index.d.ts
  5231. interface UseVibrateOptions extends ConfigurableNavigator, ConfigurableScheduler {
  5232. /**
  5233. *
  5234. * Vibration Pattern
  5235. *
  5236. * An array of values describes alternating periods in which the
  5237. * device is vibrating and not vibrating. Each value in the array
  5238. * is converted to an integer, then interpreted alternately as
  5239. * the number of milliseconds the device should vibrate and the
  5240. * number of milliseconds it should not be vibrating
  5241. *
  5242. * @default []
  5243. *
  5244. */
  5245. pattern?: MaybeRefOrGetter<Arrayable<number>>;
  5246. /**
  5247. * Interval to run a persistent vibration, in ms
  5248. *
  5249. * Pass `0` to disable
  5250. *
  5251. * @deprecated Please use `scheduler` option instead
  5252. * @default 0
  5253. *
  5254. */
  5255. interval: number;
  5256. }
  5257. interface UseVibrateReturn extends Supportable {
  5258. pattern: MaybeRefOrGetter<Arrayable<number>>;
  5259. intervalControls?: Pausable;
  5260. vibrate: (pattern?: Arrayable<number>) => void;
  5261. stop: () => void;
  5262. }
  5263. /**
  5264. * Reactive vibrate
  5265. *
  5266. * @see https://vueuse.org/useVibrate
  5267. * @see https://developer.mozilla.org/en-US/docs/Web/API/Vibration_API
  5268. * @param options
  5269. *
  5270. * @__NO_SIDE_EFFECTS__
  5271. */
  5272. declare function useVibrate(options?: UseVibrateOptions): UseVibrateReturn;
  5273. //#endregion
  5274. //#region useVirtualList/index.d.ts
  5275. type UseVirtualListItemSize = number | ((index: number) => number);
  5276. interface UseHorizontalVirtualListOptions extends UseVirtualListOptionsBase {
  5277. /**
  5278. * item width, accept a pixel value or a function that returns the width
  5279. *
  5280. * @default 0
  5281. */
  5282. itemWidth: UseVirtualListItemSize;
  5283. }
  5284. interface UseVerticalVirtualListOptions extends UseVirtualListOptionsBase {
  5285. /**
  5286. * item height, accept a pixel value or a function that returns the height
  5287. *
  5288. * @default 0
  5289. */
  5290. itemHeight: UseVirtualListItemSize;
  5291. }
  5292. interface UseVirtualListOptionsBase {
  5293. /**
  5294. * the extra buffer items outside of the view area
  5295. *
  5296. * @default 5
  5297. */
  5298. overscan?: number;
  5299. }
  5300. type UseVirtualListOptions = UseHorizontalVirtualListOptions | UseVerticalVirtualListOptions;
  5301. interface UseVirtualListItem<T> {
  5302. data: T;
  5303. index: number;
  5304. }
  5305. interface UseVirtualListReturn<T> {
  5306. list: Ref<UseVirtualListItem<T>[]>;
  5307. scrollTo: (index: number) => void;
  5308. containerProps: {
  5309. ref: Ref<HTMLElement | null>;
  5310. onScroll: () => void;
  5311. style: StyleValue;
  5312. };
  5313. wrapperProps: ComputedRef<{
  5314. style: {
  5315. width: string;
  5316. height: string;
  5317. marginTop: string;
  5318. } | {
  5319. width: string;
  5320. height: string;
  5321. marginLeft: string;
  5322. display: string;
  5323. };
  5324. }>;
  5325. }
  5326. /**
  5327. * Please consider using [`vue-virtual-scroller`](https://github.com/Akryum/vue-virtual-scroller) if you are looking for more features.
  5328. */
  5329. declare function useVirtualList<T = any>(list: MaybeRef<readonly T[]>, options: UseVirtualListOptions): UseVirtualListReturn<T>;
  5330. //#endregion
  5331. //#region useWakeLock/index.d.ts
  5332. type WakeLockType = 'screen';
  5333. interface WakeLockSentinel extends EventTarget {
  5334. type: WakeLockType;
  5335. released: boolean;
  5336. release: () => Promise<void>;
  5337. }
  5338. type UseWakeLockOptions = ConfigurableNavigator & ConfigurableDocument;
  5339. interface UseWakeLockReturn extends Supportable {
  5340. sentinel: ShallowRef<WakeLockSentinel | null>;
  5341. isActive: ComputedRef<boolean>;
  5342. request: (type: WakeLockType) => Promise<void>;
  5343. forceRequest: (type: WakeLockType) => Promise<void>;
  5344. release: () => Promise<void>;
  5345. }
  5346. /**
  5347. * Reactive Screen Wake Lock API.
  5348. *
  5349. * @see https://vueuse.org/useWakeLock
  5350. * @param options
  5351. *
  5352. * @__NO_SIDE_EFFECTS__
  5353. */
  5354. declare function useWakeLock(options?: UseWakeLockOptions): UseWakeLockReturn;
  5355. //#endregion
  5356. //#region useWebNotification/index.d.ts
  5357. interface WebNotificationOptions {
  5358. /**
  5359. * The title read-only property of the Notification interface indicates
  5360. * the title of the notification
  5361. *
  5362. * @default ''
  5363. */
  5364. title?: string;
  5365. /**
  5366. * The body string of the notification as specified in the constructor's
  5367. * options parameter.
  5368. *
  5369. * @default ''
  5370. */
  5371. body?: string;
  5372. /**
  5373. * The text direction of the notification as specified in the constructor's
  5374. * options parameter.
  5375. *
  5376. * @default ''
  5377. */
  5378. dir?: 'auto' | 'ltr' | 'rtl';
  5379. /**
  5380. * The language code of the notification as specified in the constructor's
  5381. * options parameter.
  5382. *
  5383. * @default DOMString
  5384. */
  5385. lang?: string;
  5386. /**
  5387. * The ID of the notification(if any) as specified in the constructor's options
  5388. * parameter.
  5389. *
  5390. * @default ''
  5391. */
  5392. tag?: string;
  5393. /**
  5394. * The URL of the image used as an icon of the notification as specified
  5395. * in the constructor's options parameter.
  5396. *
  5397. * @default ''
  5398. */
  5399. icon?: string;
  5400. /**
  5401. * Specifies whether the user should be notified after a new notification
  5402. * replaces an old one.
  5403. *
  5404. * @default false
  5405. */
  5406. renotify?: boolean;
  5407. /**
  5408. * A boolean value indicating that a notification should remain active until the
  5409. * user clicks or dismisses it, rather than closing automatically.
  5410. *
  5411. * @default false
  5412. */
  5413. requireInteraction?: boolean;
  5414. /**
  5415. * The silent read-only property of the Notification interface specifies
  5416. * whether the notification should be silent, i.e., no sounds or vibrations
  5417. * should be issued, regardless of the device settings.
  5418. *
  5419. * @default false
  5420. */
  5421. silent?: boolean;
  5422. /**
  5423. * Specifies a vibration pattern for devices with vibration hardware to emit.
  5424. * A vibration pattern, as specified in the Vibration API spec
  5425. *
  5426. * @see https://w3c.github.io/vibration/
  5427. */
  5428. vibrate?: number[];
  5429. }
  5430. interface UseWebNotificationOptions extends ConfigurableWindow, WebNotificationOptions {
  5431. /**
  5432. * Request for permissions onMounted if it's not granted.
  5433. *
  5434. * Can be disabled and calling `ensurePermissions` to grant afterwords.
  5435. *
  5436. * @default true
  5437. */
  5438. requestPermissions?: boolean;
  5439. }
  5440. interface UseWebNotificationReturn extends Supportable {
  5441. notification: ShallowRef<Notification | null>;
  5442. ensurePermissions: () => Promise<boolean | undefined>;
  5443. permissionGranted: ShallowRef<boolean>;
  5444. show: (overrides?: WebNotificationOptions) => Promise<Notification | undefined>;
  5445. close: () => void;
  5446. onClick: EventHookOn<Event>;
  5447. onShow: EventHookOn<Event>;
  5448. onError: EventHookOn<Event>;
  5449. onClose: EventHookOn<Event>;
  5450. }
  5451. /**
  5452. * Reactive useWebNotification
  5453. *
  5454. * @see https://vueuse.org/useWebNotification
  5455. * @see https://developer.mozilla.org/en-US/docs/Web/API/notification
  5456. */
  5457. declare function useWebNotification(options?: UseWebNotificationOptions): UseWebNotificationReturn;
  5458. //#endregion
  5459. //#region useWebSocket/index.d.ts
  5460. type WebSocketStatus = 'OPEN' | 'CONNECTING' | 'CLOSED';
  5461. type WebSocketHeartbeatMessage = string | ArrayBuffer | Blob;
  5462. interface UseWebSocketOptions {
  5463. onConnected?: (ws: WebSocket) => void;
  5464. onDisconnected?: (ws: WebSocket, event: CloseEvent) => void;
  5465. onError?: (ws: WebSocket, event: Event) => void;
  5466. onMessage?: (ws: WebSocket, event: MessageEvent) => void;
  5467. /**
  5468. * Send heartbeat for every x milliseconds passed
  5469. *
  5470. * @default false
  5471. */
  5472. heartbeat?: boolean | ConfigurableScheduler & {
  5473. /**
  5474. * Message for the heartbeat
  5475. *
  5476. * @default 'ping'
  5477. */
  5478. message?: MaybeRefOrGetter<WebSocketHeartbeatMessage>;
  5479. /**
  5480. * Response message for the heartbeat, if undefined the message will be used
  5481. */
  5482. responseMessage?: MaybeRefOrGetter<WebSocketHeartbeatMessage>;
  5483. /**
  5484. * Interval, in milliseconds
  5485. *
  5486. * @deprecated Please use `scheduler` option instead
  5487. * @default 1000
  5488. */
  5489. interval?: number;
  5490. /**
  5491. * Heartbeat response timeout, in milliseconds
  5492. *
  5493. * @default 1000
  5494. */
  5495. pongTimeout?: number;
  5496. };
  5497. /**
  5498. * Enabled auto reconnect
  5499. *
  5500. * @default false
  5501. */
  5502. autoReconnect?: boolean | {
  5503. /**
  5504. * Maximum retry times.
  5505. *
  5506. * Or you can pass a predicate function (which returns true if you want to retry).
  5507. *
  5508. * @default -1
  5509. */
  5510. retries?: number | ((retried: number) => boolean);
  5511. /**
  5512. * Delay for reconnect, in milliseconds
  5513. *
  5514. * Or you can pass a function to calculate the delay based on the number of retries.
  5515. *
  5516. * @default 1000
  5517. */
  5518. delay?: number | ((retries: number) => number);
  5519. /**
  5520. * On maximum retry times reached.
  5521. */
  5522. onFailed?: Fn;
  5523. };
  5524. /**
  5525. * Immediately open the connection when calling this composable
  5526. *
  5527. * @default true
  5528. */
  5529. immediate?: boolean;
  5530. /**
  5531. * Automatically connect to the websocket when URL changes
  5532. *
  5533. * @default true
  5534. */
  5535. autoConnect?: boolean;
  5536. /**
  5537. * Automatically close a connection
  5538. *
  5539. * @default true
  5540. */
  5541. autoClose?: boolean;
  5542. /**
  5543. * List of one or more sub-protocol strings
  5544. *
  5545. * @default []
  5546. */
  5547. protocols?: string[];
  5548. }
  5549. interface UseWebSocketReturn<T> {
  5550. /**
  5551. * Reference to the latest data received via the websocket,
  5552. * can be watched to respond to incoming messages
  5553. */
  5554. data: ShallowRef<T | null>;
  5555. /**
  5556. * The current websocket status, can be only one of:
  5557. * 'OPEN', 'CONNECTING', 'CLOSED'
  5558. */
  5559. status: ShallowRef<WebSocketStatus>;
  5560. /**
  5561. * Closes the websocket connection gracefully.
  5562. */
  5563. close: WebSocket['close'];
  5564. /**
  5565. * Reopen the websocket connection.
  5566. * If there the current one is active, will close it before opening a new one.
  5567. */
  5568. open: Fn;
  5569. /**
  5570. * Sends data through the websocket connection.
  5571. *
  5572. * @param data
  5573. * @param useBuffer when the socket is not yet open, store the data into the buffer and sent them one connected. Default to true.
  5574. */
  5575. send: (data: string | ArrayBuffer | Blob, useBuffer?: boolean) => boolean;
  5576. /**
  5577. * Reference to the WebSocket instance.
  5578. */
  5579. ws: ShallowRef<WebSocket | undefined>;
  5580. }
  5581. /**
  5582. * Reactive WebSocket client.
  5583. *
  5584. * @see https://vueuse.org/useWebSocket
  5585. * @param url
  5586. */
  5587. declare function useWebSocket<Data = any>(url: MaybeRefOrGetter<string | URL | undefined>, options?: UseWebSocketOptions): UseWebSocketReturn<Data>;
  5588. //#endregion
  5589. //#region useWebWorker/index.d.ts
  5590. type PostMessage = typeof Worker.prototype['postMessage'];
  5591. interface UseWebWorkerReturn<Data = any> {
  5592. data: ShallowRef<Data>;
  5593. post: PostMessage;
  5594. terminate: () => void;
  5595. worker: ShallowRef<Worker | undefined>;
  5596. }
  5597. type WorkerFn = (...args: unknown[]) => Worker;
  5598. /**
  5599. * Simple Web Workers registration and communication.
  5600. *
  5601. * @see https://vueuse.org/useWebWorker
  5602. * @param url
  5603. * @param workerOptions
  5604. * @param options
  5605. */
  5606. declare function useWebWorker<T = any>(url: string, workerOptions?: WorkerOptions, options?: ConfigurableWindow): UseWebWorkerReturn<T>;
  5607. /**
  5608. * Simple Web Workers registration and communication.
  5609. *
  5610. * @see https://vueuse.org/useWebWorker
  5611. */
  5612. declare function useWebWorker<T = any>(worker: Worker | WorkerFn): UseWebWorkerReturn<T>;
  5613. //#endregion
  5614. //#region useWebWorkerFn/index.d.ts
  5615. type WebWorkerStatus = 'PENDING' | 'SUCCESS' | 'RUNNING' | 'ERROR' | 'TIMEOUT_EXPIRED';
  5616. interface UseWebWorkerOptions extends ConfigurableWindow {
  5617. /**
  5618. * Number of milliseconds before killing the worker
  5619. *
  5620. * @default undefined
  5621. */
  5622. timeout?: number;
  5623. /**
  5624. * An array that contains the external dependencies needed to run the worker
  5625. */
  5626. dependencies?: string[];
  5627. /**
  5628. * An array that contains the local dependencies needed to run the worker
  5629. */
  5630. localDependencies?: Function[];
  5631. }
  5632. interface UseWebWorkerFnReturn<T extends (...fnArgs: any[]) => any> {
  5633. workerFn: (...fnArgs: Parameters<T>) => Promise<ReturnType<T>>;
  5634. workerStatus: ShallowRef<WebWorkerStatus>;
  5635. workerTerminate: (status?: WebWorkerStatus) => void;
  5636. }
  5637. /**
  5638. * Run expensive function without blocking the UI, using a simple syntax that makes use of Promise.
  5639. *
  5640. * @see https://vueuse.org/useWebWorkerFn
  5641. * @param fn
  5642. * @param options
  5643. */
  5644. declare function useWebWorkerFn<T extends (...fnArgs: any[]) => any>(fn: T, options?: UseWebWorkerOptions): UseWebWorkerFnReturn<T>;
  5645. //#endregion
  5646. //#region useWindowFocus/index.d.ts
  5647. /**
  5648. * Reactively track window focus with `window.onfocus` and `window.onblur`.
  5649. *
  5650. * @see https://vueuse.org/useWindowFocus
  5651. *
  5652. * @__NO_SIDE_EFFECTS__
  5653. */
  5654. declare function useWindowFocus(options?: ConfigurableWindow): ShallowRef<boolean>;
  5655. //#endregion
  5656. //#region useWindowScroll/index.d.ts
  5657. interface UseWindowScrollOptions extends ConfigurableWindow, UseScrollOptions {}
  5658. interface UseWindowScrollReturn extends UseScrollReturn {}
  5659. /**
  5660. * Reactive window scroll.
  5661. *
  5662. * @see https://vueuse.org/useWindowScroll
  5663. * @param options
  5664. */
  5665. declare function useWindowScroll(options?: UseWindowScrollOptions): UseWindowScrollReturn;
  5666. //#endregion
  5667. //#region useWindowSize/index.d.ts
  5668. interface UseWindowSizeOptions extends ConfigurableWindow {
  5669. initialWidth?: number;
  5670. initialHeight?: number;
  5671. /**
  5672. * Listen to window `orientationchange` event
  5673. *
  5674. * @default true
  5675. */
  5676. listenOrientation?: boolean;
  5677. /**
  5678. * Whether the scrollbar should be included in the width and height
  5679. * Only effective when `type` is `'inner'`
  5680. *
  5681. * @default true
  5682. */
  5683. includeScrollbar?: boolean;
  5684. /**
  5685. * Use `window.innerWidth` or `window.outerWidth` or `window.visualViewport`
  5686. * visualViewport documentation from MDN(https://developer.mozilla.org/zh-CN/docs/Web/API/VisualViewport)
  5687. * @default 'inner'
  5688. */
  5689. type?: 'inner' | 'outer' | 'visual';
  5690. }
  5691. interface UseWindowSizeReturn {
  5692. width: ShallowRef<number>;
  5693. height: ShallowRef<number>;
  5694. }
  5695. /**
  5696. * Reactive window size.
  5697. *
  5698. * @see https://vueuse.org/useWindowSize
  5699. * @param options
  5700. *
  5701. * @__NO_SIDE_EFFECTS__
  5702. */
  5703. declare function useWindowSize(options?: UseWindowSizeOptions): UseWindowSizeReturn;
  5704. //#endregion
  5705. export { AfterFetchContext, AsyncComputedOnCancel, AsyncComputedOptions, BasicColorMode, BasicColorSchema, BatteryManager, BeforeFetchContext, Breakpoints, BrowserLocationState, CloneFn, ColorSchemeType, ComputedInjectGetter, ComputedInjectGetterWithDefault, ComputedInjectSetter, ConfigurableDeepRefs, ConfigurableDocument, ConfigurableDocumentOrShadowRoot, ConfigurableLocation, ConfigurableNavigator, ConfigurableScheduler, ConfigurableWindow, ContrastType, CreateFetchOptions, CreateReusableTemplateOptions, CubicBezierPoints, DefaultMagicKeysAliasMap, DefineTemplateComponent, DeviceMotionOptions, DocumentEventName, EasingFunction, ElementSize, EventBusEvents, EventBusIdentifier, EventBusKey, EventBusListener, EventSourceStatus, EyeDropper, EyeDropperOpenOptions, FileSystemAccessShowOpenFileOptions, FileSystemAccessShowSaveFileOptions, FileSystemAccessWindow, FileSystemFileHandle, FormatTimeAgoIntlOptions, FormatTimeAgoOptions, GeneralEventListener, GeneralPermissionDescriptor, InterpolationFunction, KeyFilter, KeyModifier, KeyPredicate, KeyStrokeEventName, MagicKeysInternal, MaybeComputedElementRef, MaybeElement, MaybeElementRef, MemoryInfo, MouseInElementOptions, MousePressedOptions, NavigatorLanguageState, NetworkEffectiveType, NetworkState, NetworkType, OnClickOutsideHandler, OnClickOutsideOptions, OnClickOutsideReturn, OnElementRemovalOptions, OnFetchErrorContext, OnKeyStrokeOptions, OnLongPressModifiers, OnLongPressOptions, OnLongPressReturn, OrientationLockType, OrientationType, PointerType, Position, ReducedMotionType, ReducedTransparencyType, RenderableComponent, ResizeObserverCallback, ResizeObserverEntry, ResizeObserverSize, ReusableTemplatePair, ReuseTemplateComponent, SSRHandlersMap, ScreenOrientation, Serializer, SerializerAsync, ShadowRootEventName, StorageEventLike, StorageLike, StorageLikeAsync, StorageSerializers, Supportable, TemplatePromise, TemplatePromiseOptions, TemplatePromiseProps, TemplateRefsList, TimeAgoUnit, ToDataURLOptions, TransitionOptions, TransitionPresets, UnRefElementReturn, UnrefFn, UrlParams, UseActiveElementOptions, UseActiveElementReturn, UseAnimateKeyframes, UseAnimateOptions, UseAnimateReturn, UseAsyncQueueOptions, UseAsyncQueueResult, UseAsyncQueueReturn, UseAsyncQueueTask, UseAsyncStateOptions, UseAsyncStateReturn, UseAsyncStateReturnBase, UseBase64ObjectOptions, UseBase64Options, UseBase64Return, UseBatteryOptions, UseBatteryReturn, UseBluetoothOptions, UseBluetoothRequestDeviceOptions, UseBluetoothReturn, UseBreakpointReturn, UseBreakpointsOptions, UseBroadcastChannelOptions, UseBroadcastChannelReturn, UseBrowserLocationOptions, UseBrowserLocationReturn, UseCachedOptions, UseCachedReturn, UseClipboardItemsOptions, UseClipboardItemsReturn, UseClipboardOptions, UseClipboardReturn, UseClonedOptions, UseClonedReturn, UseColorModeOptions, UseColorModeReturn, UseConfirmDialogReturn, UseConfirmDialogRevealResult, UseCountdownOptions, UseCountdownReturn, UseCssSupportsOptions, UseCssSupportsReturn, UseCssVarOptions, UseCycleListOptions, UseCycleListReturn, UseDarkOptions, UseDarkReturn, UseDeviceMotionOptions, UseDeviceMotionReturn, UseDeviceOrientationOptions, UseDeviceOrientationReturn, UseDevicePixelRatioOptions, UseDevicePixelRatioReturn, UseDevicesListOptions, UseDevicesListReturn, UseDisplayMediaOptions, UseDisplayMediaReturn, UseDocumentVisibilityOptions, UseDocumentVisibilityReturn, UseDraggableOptions, UseDraggableReturn, UseDropZoneOptions, UseDropZoneReturn, UseElementBoundingOptions, UseElementBoundingReturn, UseElementByPointOptions, UseElementByPointReturn, UseElementHoverOptions, UseElementSizeOptions, UseElementSizeReturn, UseElementVisibilityOptions, UseElementVisibilityReturn, UseElementVisibilityReturnWithControls, UseEventBusReturn, UseEventSourceOptions, UseEventSourceReturn, UseEyeDropperOptions, UseEyeDropperReturn, UseFaviconOptions, UseFaviconReturn, UseFetchOptions, UseFetchReturn, UseFileDialogOptions, UseFileDialogReturn, UseFileSystemAccessCommonOptions, UseFileSystemAccessOptions, UseFileSystemAccessReturn, UseFileSystemAccessShowSaveFileOptions, UseFocusOptions, UseFocusReturn, UseFocusWithinReturn, UseFpsOptions, UseFullscreenOptions, UseFullscreenReturn, UseGamepadOptions, UseGamepadReturn, UseGeolocationOptions, UseGeolocationReturn, UseHorizontalVirtualListOptions, UseIdleOptions, UseIdleReturn, UseImageOptions, UseImageReturn, UseInfiniteScrollOptions, UseInfiniteScrollReturn, UseIntersectionObserverOptions, UseIntersectionObserverReturn, UseKeyModifierReturn, UseMagicKeysOptions, UseMagicKeysReturn, UseManualRefHistoryOptions, UseManualRefHistoryReturn, UseMediaControlsReturn, UseMediaSource, UseMediaTextTrack, UseMediaTextTrackSource, UseMemoizeCache, UseMemoizeOptions, UseMemoizeReturn, UseMemoryOptions, UseMemoryReturn, UseModifierOptions, UseMouseCoordType, UseMouseEventExtractor, UseMouseInElementReturn, UseMouseOptions, UseMousePressedOptions, UseMousePressedReturn, UseMouseReturn, UseMouseSourceType, UseMutationObserverOptions, UseMutationObserverReturn, UseNavigatorLanguageOptions, UseNavigatorLanguageReturn, UseNetworkOptions, UseNetworkReturn, UseNowOptions, UseNowReturn, UseOffsetPaginationInfinityPageReturn, UseOffsetPaginationOptions, UseOffsetPaginationReturn, UseOnLongPressReturn, UsePageLeaveOptions, UsePageLeaveReturn, UseParallaxOptions, UseParallaxReturn, UsePerformanceObserverOptions, UsePermissionOptions, UsePermissionReturn, UsePermissionReturnWithControls, UsePointerLockOptions, UsePointerLockReturn, UsePointerOptions, UsePointerReturn, UsePointerState, UsePointerSwipeOptions, UsePointerSwipeReturn, UseRafFnCallbackArguments, UseRafFnOptions, UseRefHistoryOptions, UseRefHistoryRecord, UseRefHistoryReturn, UseResizeObserverOptions, UseResizeObserverReturn, UseScreenOrientationOptions, UseScreenOrientationReturn, UseScreenSafeAreaReturn, UseScriptTagOptions, UseScriptTagReturn, UseScrollOptions, UseScrollReturn, UseShareOptions, UseShareReturn, UseSortedCompareFn, UseSortedFn, UseSortedOptions, UseSpeechRecognitionOptions, UseSpeechRecognitionReturn, UseSpeechSynthesisOptions, UseSpeechSynthesisReturn, UseSpeechSynthesisStatus, UseStepperReturn, UseStorageAsyncOptions, UseStorageOptions, UseStyleTagOptions, UseStyleTagReturn, UseSupportedReturn, UseSwipeDirection, UseSwipeOptions, UseSwipeReturn, UseTextDirectionOptions, UseTextDirectionValue, UseTextSelectionOptions, UseTextSelectionReturn, UseTextareaAutosizeOptions, UseTextareaAutosizeReturn, UseThrottledRefHistoryOptions, UseThrottledRefHistoryReturn, UseTimeAgoFormatter, UseTimeAgoIntlOptions, UseTimeAgoMessages, UseTimeAgoMessagesBuiltIn, UseTimeAgoOptions, UseTimeAgoReturn, UseTimeAgoUnit, UseTimeAgoUnitNamesDefault, UseTimeoutPollOptions, UseTimestampOptions, UseTimestampReturn, UseTitleOptions, UseTitleOptionsBase, UseTitleReturn, UseTransitionOptions, UseUrlSearchParamsOptions, UseUserMediaOptions, UseUserMediaReturn, UseVModelOptions, UseVerticalVirtualListOptions, UseVibrateOptions, UseVibrateReturn, UseVirtualListItem, UseVirtualListOptions, UseVirtualListOptionsBase, UseVirtualListReturn, UseWakeLockOptions, UseWakeLockReturn, UseWebNotificationOptions, UseWebNotificationReturn, UseWebSocketOptions, UseWebSocketReturn, UseWebWorkerFnReturn, UseWebWorkerOptions, UseWebWorkerReturn, UseWindowScrollOptions, UseWindowScrollReturn, UseWindowSizeOptions, UseWindowSizeReturn, VueInstance, WakeLockSentinel, WebNotificationOptions, WebSocketHeartbeatMessage, WebSocketStatus, WebWorkerStatus, WindowEventName, WritableComputedInjectOptions, WritableComputedInjectOptionsWithDefault, asyncComputed, breakpointsAntDesign, breakpointsBootstrapV5, breakpointsElement, breakpointsMasterCss, breakpointsPrimeFlex, breakpointsQuasar, breakpointsSematic, breakpointsTailwind, breakpointsVuetify, breakpointsVuetifyV2, breakpointsVuetifyV3, cloneFnJSON, computedAsync, computedInject, createFetch, createReusableTemplate, createTemplatePromise, createUnrefFn, customStorageEventName, defaultDocument, defaultLocation, defaultNavigator, defaultWindow, executeTransition, formatTimeAgo, formatTimeAgoIntl, formatTimeAgoIntlParts, getSSRHandler, mapGamepadToXbox360Controller, onClickOutside, onElementRemoval, onKeyDown, onKeyPressed, onKeyStroke, onKeyUp, onLongPress, onStartTyping, provideSSRWidth, setSSRHandler, templateRef, transition, unrefElement, useActiveElement, useAnimate, useAsyncQueue, useAsyncState, useBase64, useBattery, useBluetooth, useBreakpoints, useBroadcastChannel, useBrowserLocation, useCached, useClipboard, useClipboardItems, useCloned, useColorMode, useConfirmDialog, useCountdown, useCssSupports, useCssVar, useCurrentElement, useCycleList, useDark, useDebouncedRefHistory, useDeviceMotion, useDeviceOrientation, useDevicePixelRatio, useDevicesList, useDisplayMedia, useDocumentVisibility, useDraggable, useDropZone, useElementBounding, useElementByPoint, useElementHover, useElementSize, useElementVisibility, useEventBus, useEventListener, useEventSource, useEyeDropper, useFavicon, useFetch, useFileDialog, useFileSystemAccess, useFocus, useFocusWithin, useFps, useFullscreen, useGamepad, useGeolocation, useIdle, useImage, useInfiniteScroll, useIntersectionObserver, useKeyModifier, useLocalStorage, useMagicKeys, useManualRefHistory, useMediaControls, useMediaQuery, useMemoize, useMemory, useMounted, useMouse, useMouseInElement, useMousePressed, useMutationObserver, useNavigatorLanguage, useNetwork, useNow, useObjectUrl, useOffsetPagination, useOnline, usePageLeave, useParallax, useParentElement, usePerformanceObserver, usePermission, usePointer, usePointerLock, usePointerSwipe, usePreferredColorScheme, usePreferredContrast, usePreferredDark, usePreferredLanguages, usePreferredReducedMotion, usePreferredReducedTransparency, usePrevious, useRafFn, useRefHistory, useResizeObserver, useSSRWidth, useScreenOrientation, useScreenSafeArea, useScriptTag, useScroll, useScrollLock, useSessionStorage, useShare, useSorted, useSpeechRecognition, useSpeechSynthesis, useStepper, useStorage, useStorageAsync, useStyleTag, useSupported, useSwipe, useTemplateRefsList, useTextDirection, useTextSelection, useTextareaAutosize, useThrottledRefHistory, useTimeAgo, useTimeAgoIntl, useTimeoutPoll, useTimestamp, useTitle, useTransition, useUrlSearchParams, useUserMedia, useVModel, useVModels, useVibrate, useVirtualList, useWakeLock, useWebNotification, useWebSocket, useWebWorker, useWebWorkerFn, useWindowFocus, useWindowScroll, useWindowSize };