index.d.ts 135 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268
  1. /**
  2. * @license Angular v19.2.4
  3. * (c) 2010-2025 Google LLC. https://angular.io/
  4. * License: MIT
  5. */
  6. import * as i0 from '@angular/core';
  7. import { ɵNavigation as _Navigation, ɵNavigationHistoryEntry as _NavigationHistoryEntry, ɵNavigationUpdateCurrentEntryOptions as _NavigationUpdateCurrentEntryOptions, ɵNavigationTransition as _NavigationTransition, ɵNavigationNavigateOptions as _NavigationNavigateOptions, ɵNavigationResult as _NavigationResult, ɵNavigationReloadOptions as _NavigationReloadOptions, ɵNavigationOptions as _NavigationOptions, ɵNavigateEvent as _NavigateEvent, ɵNavigationCurrentEntryChangeEvent as _NavigationCurrentEntryChangeEvent, InjectionToken, OnDestroy, DoCheck, ElementRef, Renderer2, OnChanges, Type, Injector, NgModuleFactory, ViewContainerRef, SimpleChanges, NgIterable, TrackByFunction, TemplateRef, IterableDiffers, KeyValueDiffers, PipeTransform, ChangeDetectorRef, Version, Provider, OnInit } from '@angular/core';
  8. export { ɵIMAGE_CONFIG as IMAGE_CONFIG, ɵImageConfig as ImageConfig } from '@angular/core';
  9. import { SubscriptionLike, Observable, Subscribable } from 'rxjs';
  10. declare function getDOM(): DomAdapter;
  11. declare function setRootDomAdapter(adapter: DomAdapter): void;
  12. /**
  13. * Provides DOM operations in an environment-agnostic way.
  14. *
  15. * @security Tread carefully! Interacting with the DOM directly is dangerous and
  16. * can introduce XSS risks.
  17. */
  18. declare abstract class DomAdapter {
  19. abstract dispatchEvent(el: any, evt: any): any;
  20. abstract readonly supportsDOMEvents: boolean;
  21. abstract remove(el: any): void;
  22. abstract createElement(tagName: any, doc?: any): HTMLElement;
  23. abstract createHtmlDocument(): Document;
  24. abstract getDefaultDocument(): Document;
  25. abstract isElementNode(node: any): boolean;
  26. abstract isShadowRoot(node: any): boolean;
  27. abstract onAndCancel(el: any, evt: any, listener: any, options?: any): Function;
  28. abstract getGlobalEventTarget(doc: Document, target: string): any;
  29. abstract getBaseHref(doc: Document): string | null;
  30. abstract resetBaseElement(): void;
  31. abstract getUserAgent(): string;
  32. abstract getCookie(name: string): string | null;
  33. }
  34. /**
  35. * This class wraps the platform Navigation API which allows server-specific and test
  36. * implementations.
  37. */
  38. declare abstract class PlatformNavigation implements _Navigation {
  39. abstract entries(): _NavigationHistoryEntry[];
  40. abstract currentEntry: _NavigationHistoryEntry | null;
  41. abstract updateCurrentEntry(options: _NavigationUpdateCurrentEntryOptions): void;
  42. abstract transition: _NavigationTransition | null;
  43. abstract canGoBack: boolean;
  44. abstract canGoForward: boolean;
  45. abstract navigate(url: string, options?: _NavigationNavigateOptions | undefined): _NavigationResult;
  46. abstract reload(options?: _NavigationReloadOptions | undefined): _NavigationResult;
  47. abstract traverseTo(key: string, options?: _NavigationOptions | undefined): _NavigationResult;
  48. abstract back(options?: _NavigationOptions | undefined): _NavigationResult;
  49. abstract forward(options?: _NavigationOptions | undefined): _NavigationResult;
  50. abstract onnavigate: ((this: _Navigation, ev: _NavigateEvent) => any) | null;
  51. abstract onnavigatesuccess: ((this: _Navigation, ev: Event) => any) | null;
  52. abstract onnavigateerror: ((this: _Navigation, ev: ErrorEvent) => any) | null;
  53. abstract oncurrententrychange: ((this: _Navigation, ev: _NavigationCurrentEntryChangeEvent) => any) | null;
  54. abstract addEventListener(type: unknown, listener: unknown, options?: unknown): void;
  55. abstract removeEventListener(type: unknown, listener: unknown, options?: unknown): void;
  56. abstract dispatchEvent(event: Event): boolean;
  57. static ɵfac: i0.ɵɵFactoryDeclaration<PlatformNavigation, never>;
  58. static ɵprov: i0.ɵɵInjectableDeclaration<PlatformNavigation>;
  59. }
  60. /**
  61. * This class should not be used directly by an application developer. Instead, use
  62. * {@link Location}.
  63. *
  64. * `PlatformLocation` encapsulates all calls to DOM APIs, which allows the Router to be
  65. * platform-agnostic.
  66. * This means that we can have different implementation of `PlatformLocation` for the different
  67. * platforms that Angular supports. For example, `@angular/platform-browser` provides an
  68. * implementation specific to the browser environment, while `@angular/platform-server` provides
  69. * one suitable for use with server-side rendering.
  70. *
  71. * The `PlatformLocation` class is used directly by all implementations of {@link LocationStrategy}
  72. * when they need to interact with the DOM APIs like pushState, popState, etc.
  73. *
  74. * {@link LocationStrategy} in turn is used by the {@link Location} service which is used directly
  75. * by the {@link /api/router/Router Router} in order to navigate between routes. Since all interactions between
  76. * {@link /api/router/Router Router} /
  77. * {@link Location} / {@link LocationStrategy} and DOM APIs flow through the `PlatformLocation`
  78. * class, they are all platform-agnostic.
  79. *
  80. * @publicApi
  81. */
  82. declare abstract class PlatformLocation {
  83. abstract getBaseHrefFromDOM(): string;
  84. abstract getState(): unknown;
  85. /**
  86. * Returns a function that, when executed, removes the `popstate` event handler.
  87. */
  88. abstract onPopState(fn: LocationChangeListener): VoidFunction;
  89. /**
  90. * Returns a function that, when executed, removes the `hashchange` event handler.
  91. */
  92. abstract onHashChange(fn: LocationChangeListener): VoidFunction;
  93. abstract get href(): string;
  94. abstract get protocol(): string;
  95. abstract get hostname(): string;
  96. abstract get port(): string;
  97. abstract get pathname(): string;
  98. abstract get search(): string;
  99. abstract get hash(): string;
  100. abstract replaceState(state: any, title: string, url: string): void;
  101. abstract pushState(state: any, title: string, url: string): void;
  102. abstract forward(): void;
  103. abstract back(): void;
  104. historyGo?(relativePosition: number): void;
  105. static ɵfac: i0.ɵɵFactoryDeclaration<PlatformLocation, never>;
  106. static ɵprov: i0.ɵɵInjectableDeclaration<PlatformLocation>;
  107. }
  108. /**
  109. * @description
  110. * Indicates when a location is initialized.
  111. *
  112. * @publicApi
  113. */
  114. declare const LOCATION_INITIALIZED: InjectionToken<Promise<any>>;
  115. /**
  116. * @description
  117. * A serializable version of the event from `onPopState` or `onHashChange`
  118. *
  119. * @publicApi
  120. */
  121. interface LocationChangeEvent {
  122. type: string;
  123. state: any;
  124. }
  125. /**
  126. * @publicApi
  127. */
  128. interface LocationChangeListener {
  129. (event: LocationChangeEvent): any;
  130. }
  131. /**
  132. * `PlatformLocation` encapsulates all of the direct calls to platform APIs.
  133. * This class should not be used directly by an application developer. Instead, use
  134. * {@link Location}.
  135. *
  136. * @publicApi
  137. */
  138. declare class BrowserPlatformLocation extends PlatformLocation {
  139. private _location;
  140. private _history;
  141. private _doc;
  142. constructor();
  143. getBaseHrefFromDOM(): string;
  144. onPopState(fn: LocationChangeListener): VoidFunction;
  145. onHashChange(fn: LocationChangeListener): VoidFunction;
  146. get href(): string;
  147. get protocol(): string;
  148. get hostname(): string;
  149. get port(): string;
  150. get pathname(): string;
  151. get search(): string;
  152. get hash(): string;
  153. set pathname(newPath: string);
  154. pushState(state: any, title: string, url: string): void;
  155. replaceState(state: any, title: string, url: string): void;
  156. forward(): void;
  157. back(): void;
  158. historyGo(relativePosition?: number): void;
  159. getState(): unknown;
  160. static ɵfac: i0.ɵɵFactoryDeclaration<BrowserPlatformLocation, never>;
  161. static ɵprov: i0.ɵɵInjectableDeclaration<BrowserPlatformLocation>;
  162. }
  163. /**
  164. * Enables the `Location` service to read route state from the browser's URL.
  165. * Angular provides two strategies:
  166. * `HashLocationStrategy` and `PathLocationStrategy`.
  167. *
  168. * Applications should use the `Router` or `Location` services to
  169. * interact with application route state.
  170. *
  171. * For instance, `HashLocationStrategy` produces URLs like
  172. * <code class="no-auto-link">http://example.com/#/foo</code>,
  173. * and `PathLocationStrategy` produces
  174. * <code class="no-auto-link">http://example.com/foo</code> as an equivalent URL.
  175. *
  176. * See these two classes for more.
  177. *
  178. * @publicApi
  179. */
  180. declare abstract class LocationStrategy {
  181. abstract path(includeHash?: boolean): string;
  182. abstract prepareExternalUrl(internal: string): string;
  183. abstract getState(): unknown;
  184. abstract pushState(state: any, title: string, url: string, queryParams: string): void;
  185. abstract replaceState(state: any, title: string, url: string, queryParams: string): void;
  186. abstract forward(): void;
  187. abstract back(): void;
  188. historyGo?(relativePosition: number): void;
  189. abstract onPopState(fn: LocationChangeListener): void;
  190. abstract getBaseHref(): string;
  191. static ɵfac: i0.ɵɵFactoryDeclaration<LocationStrategy, never>;
  192. static ɵprov: i0.ɵɵInjectableDeclaration<LocationStrategy>;
  193. }
  194. /**
  195. * A predefined DI token for the base href
  196. * to be used with the `PathLocationStrategy`.
  197. * The base href is the URL prefix that should be preserved when generating
  198. * and recognizing URLs.
  199. *
  200. * @usageNotes
  201. *
  202. * The following example shows how to use this token to configure the root app injector
  203. * with a base href value, so that the DI framework can supply the dependency anywhere in the app.
  204. *
  205. * ```ts
  206. * import {NgModule} from '@angular/core';
  207. * import {APP_BASE_HREF} from '@angular/common';
  208. *
  209. * @NgModule({
  210. * providers: [{provide: APP_BASE_HREF, useValue: '/my/app'}]
  211. * })
  212. * class AppModule {}
  213. * ```
  214. *
  215. * @publicApi
  216. */
  217. declare const APP_BASE_HREF: InjectionToken<string>;
  218. /**
  219. * @description
  220. * A {@link LocationStrategy} used to configure the {@link Location} service to
  221. * represent its state in the
  222. * [path](https://en.wikipedia.org/wiki/Uniform_Resource_Locator#Syntax) of the
  223. * browser's URL.
  224. *
  225. * If you're using `PathLocationStrategy`, you may provide a {@link APP_BASE_HREF}
  226. * or add a `<base href>` element to the document to override the default.
  227. *
  228. * For instance, if you provide an `APP_BASE_HREF` of `'/my/app/'` and call
  229. * `location.go('/foo')`, the browser's URL will become
  230. * `example.com/my/app/foo`. To ensure all relative URIs resolve correctly,
  231. * the `<base href>` and/or `APP_BASE_HREF` should end with a `/`.
  232. *
  233. * Similarly, if you add `<base href='/my/app/'/>` to the document and call
  234. * `location.go('/foo')`, the browser's URL will become
  235. * `example.com/my/app/foo`.
  236. *
  237. * Note that when using `PathLocationStrategy`, neither the query nor
  238. * the fragment in the `<base href>` will be preserved, as outlined
  239. * by the [RFC](https://tools.ietf.org/html/rfc3986#section-5.2.2).
  240. *
  241. * @usageNotes
  242. *
  243. * ### Example
  244. *
  245. * {@example common/location/ts/path_location_component.ts region='LocationComponent'}
  246. *
  247. * @publicApi
  248. */
  249. declare class PathLocationStrategy extends LocationStrategy implements OnDestroy {
  250. private _platformLocation;
  251. private _baseHref;
  252. private _removeListenerFns;
  253. constructor(_platformLocation: PlatformLocation, href?: string);
  254. /** @nodoc */
  255. ngOnDestroy(): void;
  256. onPopState(fn: LocationChangeListener): void;
  257. getBaseHref(): string;
  258. prepareExternalUrl(internal: string): string;
  259. path(includeHash?: boolean): string;
  260. pushState(state: any, title: string, url: string, queryParams: string): void;
  261. replaceState(state: any, title: string, url: string, queryParams: string): void;
  262. forward(): void;
  263. back(): void;
  264. getState(): unknown;
  265. historyGo(relativePosition?: number): void;
  266. static ɵfac: i0.ɵɵFactoryDeclaration<PathLocationStrategy, [null, { optional: true; }]>;
  267. static ɵprov: i0.ɵɵInjectableDeclaration<PathLocationStrategy>;
  268. }
  269. /**
  270. * @description
  271. * A {@link LocationStrategy} used to configure the {@link Location} service to
  272. * represent its state in the
  273. * [hash fragment](https://en.wikipedia.org/wiki/Uniform_Resource_Locator#Syntax)
  274. * of the browser's URL.
  275. *
  276. * For instance, if you call `location.go('/foo')`, the browser's URL will become
  277. * `example.com#/foo`.
  278. *
  279. * @usageNotes
  280. *
  281. * ### Example
  282. *
  283. * {@example common/location/ts/hash_location_component.ts region='LocationComponent'}
  284. *
  285. * @publicApi
  286. */
  287. declare class HashLocationStrategy extends LocationStrategy implements OnDestroy {
  288. private _platformLocation;
  289. private _baseHref;
  290. private _removeListenerFns;
  291. constructor(_platformLocation: PlatformLocation, _baseHref?: string);
  292. /** @nodoc */
  293. ngOnDestroy(): void;
  294. onPopState(fn: LocationChangeListener): void;
  295. getBaseHref(): string;
  296. path(includeHash?: boolean): string;
  297. prepareExternalUrl(internal: string): string;
  298. pushState(state: any, title: string, path: string, queryParams: string): void;
  299. replaceState(state: any, title: string, path: string, queryParams: string): void;
  300. forward(): void;
  301. back(): void;
  302. getState(): unknown;
  303. historyGo(relativePosition?: number): void;
  304. static ɵfac: i0.ɵɵFactoryDeclaration<HashLocationStrategy, [null, { optional: true; }]>;
  305. static ɵprov: i0.ɵɵInjectableDeclaration<HashLocationStrategy>;
  306. }
  307. /** @publicApi */
  308. interface PopStateEvent {
  309. pop?: boolean;
  310. state?: any;
  311. type?: string;
  312. url?: string;
  313. }
  314. /**
  315. * @description
  316. *
  317. * A service that applications can use to interact with a browser's URL.
  318. *
  319. * Depending on the `LocationStrategy` used, `Location` persists
  320. * to the URL's path or the URL's hash segment.
  321. *
  322. * @usageNotes
  323. *
  324. * It's better to use the `Router.navigate()` service to trigger route changes. Use
  325. * `Location` only if you need to interact with or create normalized URLs outside of
  326. * routing.
  327. *
  328. * `Location` is responsible for normalizing the URL against the application's base href.
  329. * A normalized URL is absolute from the URL host, includes the application's base href, and has no
  330. * trailing slash:
  331. * - `/my/app/user/123` is normalized
  332. * - `my/app/user/123` **is not** normalized
  333. * - `/my/app/user/123/` **is not** normalized
  334. *
  335. * ### Example
  336. *
  337. * {@example common/location/ts/path_location_component.ts region='LocationComponent'}
  338. *
  339. * @publicApi
  340. */
  341. declare class Location implements OnDestroy {
  342. constructor(locationStrategy: LocationStrategy);
  343. /** @nodoc */
  344. ngOnDestroy(): void;
  345. /**
  346. * Normalizes the URL path for this location.
  347. *
  348. * @param includeHash True to include an anchor fragment in the path.
  349. *
  350. * @returns The normalized URL path.
  351. */
  352. path(includeHash?: boolean): string;
  353. /**
  354. * Reports the current state of the location history.
  355. * @returns The current value of the `history.state` object.
  356. */
  357. getState(): unknown;
  358. /**
  359. * Normalizes the given path and compares to the current normalized path.
  360. *
  361. * @param path The given URL path.
  362. * @param query Query parameters.
  363. *
  364. * @returns True if the given URL path is equal to the current normalized path, false
  365. * otherwise.
  366. */
  367. isCurrentPathEqualTo(path: string, query?: string): boolean;
  368. /**
  369. * Normalizes a URL path by stripping any trailing slashes.
  370. *
  371. * @param url String representing a URL.
  372. *
  373. * @returns The normalized URL string.
  374. */
  375. normalize(url: string): string;
  376. /**
  377. * Normalizes an external URL path.
  378. * If the given URL doesn't begin with a leading slash (`'/'`), adds one
  379. * before normalizing. Adds a hash if `HashLocationStrategy` is
  380. * in use, or the `APP_BASE_HREF` if the `PathLocationStrategy` is in use.
  381. *
  382. * @param url String representing a URL.
  383. *
  384. * @returns A normalized platform-specific URL.
  385. */
  386. prepareExternalUrl(url: string): string;
  387. /**
  388. * Changes the browser's URL to a normalized version of a given URL, and pushes a
  389. * new item onto the platform's history.
  390. *
  391. * @param path URL path to normalize.
  392. * @param query Query parameters.
  393. * @param state Location history state.
  394. *
  395. */
  396. go(path: string, query?: string, state?: any): void;
  397. /**
  398. * Changes the browser's URL to a normalized version of the given URL, and replaces
  399. * the top item on the platform's history stack.
  400. *
  401. * @param path URL path to normalize.
  402. * @param query Query parameters.
  403. * @param state Location history state.
  404. */
  405. replaceState(path: string, query?: string, state?: any): void;
  406. /**
  407. * Navigates forward in the platform's history.
  408. */
  409. forward(): void;
  410. /**
  411. * Navigates back in the platform's history.
  412. */
  413. back(): void;
  414. /**
  415. * Navigate to a specific page from session history, identified by its relative position to the
  416. * current page.
  417. *
  418. * @param relativePosition Position of the target page in the history relative to the current
  419. * page.
  420. * A negative value moves backwards, a positive value moves forwards, e.g. `location.historyGo(2)`
  421. * moves forward two pages and `location.historyGo(-2)` moves back two pages. When we try to go
  422. * beyond what's stored in the history session, we stay in the current page. Same behaviour occurs
  423. * when `relativePosition` equals 0.
  424. * @see https://developer.mozilla.org/en-US/docs/Web/API/History_API#Moving_to_a_specific_point_in_history
  425. */
  426. historyGo(relativePosition?: number): void;
  427. /**
  428. * Registers a URL change listener. Use to catch updates performed by the Angular
  429. * framework that are not detectible through "popstate" or "hashchange" events.
  430. *
  431. * @param fn The change handler function, which take a URL and a location history state.
  432. * @returns A function that, when executed, unregisters a URL change listener.
  433. */
  434. onUrlChange(fn: (url: string, state: unknown) => void): VoidFunction;
  435. /**
  436. * Subscribes to the platform's `popState` events.
  437. *
  438. * Note: `Location.go()` does not trigger the `popState` event in the browser. Use
  439. * `Location.onUrlChange()` to subscribe to URL changes instead.
  440. *
  441. * @param value Event that is triggered when the state history changes.
  442. * @param exception The exception to throw.
  443. *
  444. * @see [onpopstate](https://developer.mozilla.org/en-US/docs/Web/API/WindowEventHandlers/onpopstate)
  445. *
  446. * @returns Subscribed events.
  447. */
  448. subscribe(onNext: (value: PopStateEvent) => void, onThrow?: ((exception: any) => void) | null, onReturn?: (() => void) | null): SubscriptionLike;
  449. /**
  450. * Normalizes URL parameters by prepending with `?` if needed.
  451. *
  452. * @param params String of URL parameters.
  453. *
  454. * @returns The normalized URL parameters string.
  455. */
  456. static normalizeQueryParams: (params: string) => string;
  457. /**
  458. * Joins two parts of a URL with a slash if needed.
  459. *
  460. * @param start URL string
  461. * @param end URL string
  462. *
  463. *
  464. * @returns The joined URL string.
  465. */
  466. static joinWithSlash: (start: string, end: string) => string;
  467. /**
  468. * Removes a trailing slash from a URL string if needed.
  469. * Looks for the first occurrence of either `#`, `?`, or the end of the
  470. * line as `/` characters and removes the trailing slash if one exists.
  471. *
  472. * @param url URL string.
  473. *
  474. * @returns The URL string, modified if needed.
  475. */
  476. static stripTrailingSlash: (url: string) => string;
  477. static ɵfac: i0.ɵɵFactoryDeclaration<Location, never>;
  478. static ɵprov: i0.ɵɵInjectableDeclaration<Location>;
  479. }
  480. /**
  481. * @ngModule CommonModule
  482. * @description
  483. *
  484. * Formats a date according to locale rules.
  485. *
  486. * @param value The date to format, as a Date, or a number (milliseconds since UTC epoch)
  487. * or an [ISO date-time string](https://www.w3.org/TR/NOTE-datetime).
  488. * @param format The date-time components to include. See `DatePipe` for details.
  489. * @param locale A locale code for the locale format rules to use.
  490. * @param timezone The time zone. A time zone offset from GMT (such as `'+0430'`).
  491. * If not specified, uses host system settings.
  492. *
  493. * @returns The formatted date string.
  494. *
  495. * @see {@link DatePipe}
  496. * @see [Internationalization (i18n) Guide](guide/i18n)
  497. *
  498. * @publicApi
  499. */
  500. declare function formatDate(value: string | number | Date, format: string, locale: string, timezone?: string): string;
  501. /**
  502. * @ngModule CommonModule
  503. * @description
  504. *
  505. * Formats a number as currency using locale rules.
  506. *
  507. * @param value The number to format.
  508. * @param locale A locale code for the locale format rules to use.
  509. * @param currency A string containing the currency symbol or its name,
  510. * such as "$" or "Canadian Dollar". Used in output string, but does not affect the operation
  511. * of the function.
  512. * @param currencyCode The [ISO 4217](https://en.wikipedia.org/wiki/ISO_4217)
  513. * currency code, such as `USD` for the US dollar and `EUR` for the euro.
  514. * Used to determine the number of digits in the decimal part.
  515. * @param digitsInfo Decimal representation options, specified by a string in the following format:
  516. * `{minIntegerDigits}.{minFractionDigits}-{maxFractionDigits}`. See `DecimalPipe` for more details.
  517. *
  518. * @returns The formatted currency value.
  519. *
  520. * @see {@link formatNumber}
  521. * @see {@link DecimalPipe}
  522. * @see [Internationalization (i18n) Guide](guide/i18n)
  523. *
  524. * @publicApi
  525. */
  526. declare function formatCurrency(value: number, locale: string, currency: string, currencyCode?: string, digitsInfo?: string): string;
  527. /**
  528. * @ngModule CommonModule
  529. * @description
  530. *
  531. * Formats a number as a percentage according to locale rules.
  532. *
  533. * @param value The number to format.
  534. * @param locale A locale code for the locale format rules to use.
  535. * @param digitsInfo Decimal representation options, specified by a string in the following format:
  536. * `{minIntegerDigits}.{minFractionDigits}-{maxFractionDigits}`. See `DecimalPipe` for more details.
  537. *
  538. * @returns The formatted percentage value.
  539. *
  540. * @see {@link formatNumber}
  541. * @see {@link DecimalPipe}
  542. * @see [Internationalization (i18n) Guide](guide/i18n)
  543. * @publicApi
  544. *
  545. */
  546. declare function formatPercent(value: number, locale: string, digitsInfo?: string): string;
  547. /**
  548. * @ngModule CommonModule
  549. * @description
  550. *
  551. * Formats a number as text, with group sizing, separator, and other
  552. * parameters based on the locale.
  553. *
  554. * @param value The number to format.
  555. * @param locale A locale code for the locale format rules to use.
  556. * @param digitsInfo Decimal representation options, specified by a string in the following format:
  557. * `{minIntegerDigits}.{minFractionDigits}-{maxFractionDigits}`. See `DecimalPipe` for more details.
  558. *
  559. * @returns The formatted text string.
  560. * @see [Internationalization (i18n) Guide](guide/i18n)
  561. *
  562. * @publicApi
  563. */
  564. declare function formatNumber(value: number, locale: string, digitsInfo?: string): string;
  565. /**
  566. * @publicApi
  567. */
  568. declare abstract class NgLocalization {
  569. abstract getPluralCategory(value: any, locale?: string): string;
  570. static ɵfac: i0.ɵɵFactoryDeclaration<NgLocalization, never>;
  571. static ɵprov: i0.ɵɵInjectableDeclaration<NgLocalization>;
  572. }
  573. /**
  574. * Returns the plural case based on the locale
  575. *
  576. * @publicApi
  577. */
  578. declare class NgLocaleLocalization extends NgLocalization {
  579. protected locale: string;
  580. constructor(locale: string);
  581. getPluralCategory(value: any, locale?: string): string;
  582. static ɵfac: i0.ɵɵFactoryDeclaration<NgLocaleLocalization, never>;
  583. static ɵprov: i0.ɵɵInjectableDeclaration<NgLocaleLocalization>;
  584. }
  585. /**
  586. * Register global data to be used internally by Angular. See the
  587. * ["I18n guide"](guide/i18n/format-data-locale) to know how to import additional locale
  588. * data.
  589. *
  590. * The signature registerLocaleData(data: any, extraData?: any) is deprecated since v5.1
  591. *
  592. * @publicApi
  593. */
  594. declare function registerLocaleData(data: any, localeId?: string | any, extraData?: any): void;
  595. /**
  596. * Format styles that can be used to represent numbers.
  597. * @see {@link getLocaleNumberFormat}
  598. * @see [Internationalization (i18n) Guide](guide/i18n)
  599. *
  600. * @publicApi
  601. *
  602. * @deprecated `getLocaleNumberFormat` is deprecated
  603. */
  604. declare enum NumberFormatStyle {
  605. Decimal = 0,
  606. Percent = 1,
  607. Currency = 2,
  608. Scientific = 3
  609. }
  610. /**
  611. * Plurality cases used for translating plurals to different languages.
  612. *
  613. * @see {@link NgPlural}
  614. * @see {@link NgPluralCase}
  615. * @see [Internationalization (i18n) Guide](guide/i18n)
  616. *
  617. * @publicApi
  618. *
  619. * @deprecated `getLocalePluralCase` is deprecated
  620. */
  621. declare enum Plural {
  622. Zero = 0,
  623. One = 1,
  624. Two = 2,
  625. Few = 3,
  626. Many = 4,
  627. Other = 5
  628. }
  629. /**
  630. * Context-dependant translation forms for strings.
  631. * Typically the standalone version is for the nominative form of the word,
  632. * and the format version is used for the genitive case.
  633. * @see [CLDR website](http://cldr.unicode.org/translation/date-time-1/date-time#TOC-Standalone-vs.-Format-Styles)
  634. * @see [Internationalization (i18n) Guide](guide/i18n)
  635. *
  636. * @publicApi
  637. *
  638. * @deprecated locale data getters are deprecated
  639. */
  640. declare enum FormStyle {
  641. Format = 0,
  642. Standalone = 1
  643. }
  644. /**
  645. * String widths available for translations.
  646. * The specific character widths are locale-specific.
  647. * Examples are given for the word "Sunday" in English.
  648. *
  649. * @publicApi
  650. *
  651. * @deprecated locale data getters are deprecated
  652. */
  653. declare enum TranslationWidth {
  654. /** 1 character for `en-US`. For example: 'S' */
  655. Narrow = 0,
  656. /** 3 characters for `en-US`. For example: 'Sun' */
  657. Abbreviated = 1,
  658. /** Full length for `en-US`. For example: "Sunday" */
  659. Wide = 2,
  660. /** 2 characters for `en-US`, For example: "Su" */
  661. Short = 3
  662. }
  663. /**
  664. * String widths available for date-time formats.
  665. * The specific character widths are locale-specific.
  666. * Examples are given for `en-US`.
  667. *
  668. * @see {@link getLocaleDateFormat}
  669. * @see {@link getLocaleTimeFormat}
  670. * @see {@link getLocaleDateTimeFormat}
  671. * @see [Internationalization (i18n) Guide](guide/i18n)
  672. * @publicApi
  673. *
  674. * @deprecated Date locale data getters are deprecated
  675. */
  676. declare enum FormatWidth {
  677. /**
  678. * For `en-US`, `'M/d/yy, h:mm a'`
  679. * (Example: `6/15/15, 9:03 AM`)
  680. */
  681. Short = 0,
  682. /**
  683. * For `en-US`, `'MMM d, y, h:mm:ss a'`
  684. * (Example: `Jun 15, 2015, 9:03:01 AM`)
  685. */
  686. Medium = 1,
  687. /**
  688. * For `en-US`, `'MMMM d, y, h:mm:ss a z'`
  689. * (Example: `June 15, 2015 at 9:03:01 AM GMT+1`)
  690. */
  691. Long = 2,
  692. /**
  693. * For `en-US`, `'EEEE, MMMM d, y, h:mm:ss a zzzz'`
  694. * (Example: `Monday, June 15, 2015 at 9:03:01 AM GMT+01:00`)
  695. */
  696. Full = 3
  697. }
  698. /**
  699. * Symbols that can be used to replace placeholders in number patterns.
  700. * Examples are based on `en-US` values.
  701. *
  702. * @see {@link getLocaleNumberSymbol}
  703. * @see [Internationalization (i18n) Guide](guide/i18n)
  704. *
  705. * @publicApi
  706. *
  707. * @deprecated `getLocaleNumberSymbol` is deprecated
  708. *
  709. * @object-literal-as-enum
  710. */
  711. declare const NumberSymbol: {
  712. /**
  713. * Decimal separator.
  714. * For `en-US`, the dot character.
  715. * Example: 2,345`.`67
  716. */
  717. readonly Decimal: 0;
  718. /**
  719. * Grouping separator, typically for thousands.
  720. * For `en-US`, the comma character.
  721. * Example: 2`,`345.67
  722. */
  723. readonly Group: 1;
  724. /**
  725. * List-item separator.
  726. * Example: "one, two, and three"
  727. */
  728. readonly List: 2;
  729. /**
  730. * Sign for percentage (out of 100).
  731. * Example: 23.4%
  732. */
  733. readonly PercentSign: 3;
  734. /**
  735. * Sign for positive numbers.
  736. * Example: +23
  737. */
  738. readonly PlusSign: 4;
  739. /**
  740. * Sign for negative numbers.
  741. * Example: -23
  742. */
  743. readonly MinusSign: 5;
  744. /**
  745. * Computer notation for exponential value (n times a power of 10).
  746. * Example: 1.2E3
  747. */
  748. readonly Exponential: 6;
  749. /**
  750. * Human-readable format of exponential.
  751. * Example: 1.2x103
  752. */
  753. readonly SuperscriptingExponent: 7;
  754. /**
  755. * Sign for permille (out of 1000).
  756. * Example: 23.4‰
  757. */
  758. readonly PerMille: 8;
  759. /**
  760. * Infinity, can be used with plus and minus.
  761. * Example: ∞, +∞, -∞
  762. */
  763. readonly Infinity: 9;
  764. /**
  765. * Not a number.
  766. * Example: NaN
  767. */
  768. readonly NaN: 10;
  769. /**
  770. * Symbol used between time units.
  771. * Example: 10:52
  772. */
  773. readonly TimeSeparator: 11;
  774. /**
  775. * Decimal separator for currency values (fallback to `Decimal`).
  776. * Example: $2,345.67
  777. */
  778. readonly CurrencyDecimal: 12;
  779. /**
  780. * Group separator for currency values (fallback to `Group`).
  781. * Example: $2,345.67
  782. */
  783. readonly CurrencyGroup: 13;
  784. };
  785. type NumberSymbol = (typeof NumberSymbol)[keyof typeof NumberSymbol];
  786. /**
  787. * The value for each day of the week, based on the `en-US` locale
  788. *
  789. * @publicApi
  790. *
  791. * @deprecated Week locale getters are deprecated
  792. */
  793. declare enum WeekDay {
  794. Sunday = 0,
  795. Monday = 1,
  796. Tuesday = 2,
  797. Wednesday = 3,
  798. Thursday = 4,
  799. Friday = 5,
  800. Saturday = 6
  801. }
  802. /**
  803. * Retrieves the locale ID from the currently loaded locale.
  804. * The loaded locale could be, for example, a global one rather than a regional one.
  805. * @param locale A locale code, such as `fr-FR`.
  806. * @returns The locale code. For example, `fr`.
  807. * @see [Internationalization (i18n) Guide](guide/i18n)
  808. *
  809. * @publicApi
  810. *
  811. * @deprecated Angular recommends relying on the `Intl` API for i18n.
  812. * This function serves no purpose when relying on the `Intl` API.
  813. */
  814. declare function getLocaleId(locale: string): string;
  815. /**
  816. * Retrieves day period strings for the given locale.
  817. *
  818. * @param locale A locale code for the locale format rules to use.
  819. * @param formStyle The required grammatical form.
  820. * @param width The required character width.
  821. * @returns An array of localized period strings. For example, `[AM, PM]` for `en-US`.
  822. * @see [Internationalization (i18n) Guide](guide/i18n)
  823. *
  824. * @publicApi
  825. *
  826. * @deprecated Angular recommends relying on the `Intl` API for i18n.
  827. * Use `Intl.DateTimeFormat` for date formating instead.
  828. */
  829. declare function getLocaleDayPeriods(locale: string, formStyle: FormStyle, width: TranslationWidth): Readonly<[string, string]>;
  830. /**
  831. * Retrieves days of the week for the given locale, using the Gregorian calendar.
  832. *
  833. * @param locale A locale code for the locale format rules to use.
  834. * @param formStyle The required grammatical form.
  835. * @param width The required character width.
  836. * @returns An array of localized name strings.
  837. * For example,`[Sunday, Monday, ... Saturday]` for `en-US`.
  838. * @see [Internationalization (i18n) Guide](guide/i18n)
  839. *
  840. * @publicApi
  841. *
  842. * @deprecated Angular recommends relying on the `Intl` API for i18n.
  843. * Use `Intl.DateTimeFormat` for date formating instead.
  844. */
  845. declare function getLocaleDayNames(locale: string, formStyle: FormStyle, width: TranslationWidth): ReadonlyArray<string>;
  846. /**
  847. * Retrieves months of the year for the given locale, using the Gregorian calendar.
  848. *
  849. * @param locale A locale code for the locale format rules to use.
  850. * @param formStyle The required grammatical form.
  851. * @param width The required character width.
  852. * @returns An array of localized name strings.
  853. * For example, `[January, February, ...]` for `en-US`.
  854. * @see [Internationalization (i18n) Guide](guide/i18n)
  855. *
  856. * @publicApi
  857. *
  858. * @deprecated Angular recommends relying on the `Intl` API for i18n.
  859. * Use `Intl.DateTimeFormat` for date formating instead.
  860. */
  861. declare function getLocaleMonthNames(locale: string, formStyle: FormStyle, width: TranslationWidth): ReadonlyArray<string>;
  862. /**
  863. * Retrieves Gregorian-calendar eras for the given locale.
  864. * @param locale A locale code for the locale format rules to use.
  865. * @param width The required character width.
  866. * @returns An array of localized era strings.
  867. * For example, `[AD, BC]` for `en-US`.
  868. * @see [Internationalization (i18n) Guide](guide/i18n)
  869. *
  870. * @publicApi
  871. *
  872. * @deprecated Angular recommends relying on the `Intl` API for i18n.
  873. * Use `Intl.DateTimeFormat` for date formating instead.
  874. */
  875. declare function getLocaleEraNames(locale: string, width: TranslationWidth): Readonly<[string, string]>;
  876. /**
  877. * Retrieves the first day of the week for the given locale.
  878. *
  879. * @param locale A locale code for the locale format rules to use.
  880. * @returns A day index number, using the 0-based week-day index for `en-US`
  881. * (Sunday = 0, Monday = 1, ...).
  882. * For example, for `fr-FR`, returns 1 to indicate that the first day is Monday.
  883. * @see [Internationalization (i18n) Guide](guide/i18n)
  884. *
  885. * @publicApi
  886. *
  887. * @deprecated Angular recommends relying on the `Intl` API for i18n.
  888. * Intl's [`getWeekInfo`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Locale/getWeekInfo) has partial support (Chromium M99 & Safari 17).
  889. * You may want to rely on the following alternatives:
  890. * - Libraries like [`Luxon`](https://moment.github.io/luxon/#/) rely on `Intl` but fallback on the ISO 8601 definition (monday) if `getWeekInfo` is not supported.
  891. * - Other librairies like [`date-fns`](https://date-fns.org/), [`day.js`](https://day.js.org/en/) or [`weekstart`](https://www.npmjs.com/package/weekstart) library provide their own locale based data for the first day of the week.
  892. */
  893. declare function getLocaleFirstDayOfWeek(locale: string): WeekDay;
  894. /**
  895. * Range of week days that are considered the week-end for the given locale.
  896. *
  897. * @param locale A locale code for the locale format rules to use.
  898. * @returns The range of day values, `[startDay, endDay]`.
  899. * @see [Internationalization (i18n) Guide](guide/i18n)
  900. *
  901. * @publicApi
  902. *
  903. * @deprecated Angular recommends relying on the `Intl` API for i18n.
  904. * Intl's [`getWeekInfo`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Locale/getWeekInfo) has partial support (Chromium M99 & Safari 17).
  905. * Libraries like [`Luxon`](https://moment.github.io/luxon/#/) rely on `Intl` but fallback on the ISO 8601 definition (Saturday+Sunday) if `getWeekInfo` is not supported .
  906. */
  907. declare function getLocaleWeekEndRange(locale: string): [WeekDay, WeekDay];
  908. /**
  909. * Retrieves a localized date-value formatting string.
  910. *
  911. * @param locale A locale code for the locale format rules to use.
  912. * @param width The format type.
  913. * @returns The localized formatting string.
  914. * @see {@link FormatWidth}
  915. * @see [Internationalization (i18n) Guide](guide/i18n)
  916. *
  917. * @publicApi
  918. *
  919. * @deprecated Angular recommends relying on the `Intl` API for i18n.
  920. * Use `Intl.DateTimeFormat` for date formating instead.
  921. */
  922. declare function getLocaleDateFormat(locale: string, width: FormatWidth): string;
  923. /**
  924. * Retrieves a localized time-value formatting string.
  925. *
  926. * @param locale A locale code for the locale format rules to use.
  927. * @param width The format type.
  928. * @returns The localized formatting string.
  929. * @see {@link FormatWidth}
  930. * @see [Internationalization (i18n) Guide](guide/i18n)
  931. * @publicApi
  932. * @deprecated Angular recommends relying on the `Intl` API for i18n.
  933. * Use `Intl.DateTimeFormat` for date formating instead.
  934. */
  935. declare function getLocaleTimeFormat(locale: string, width: FormatWidth): string;
  936. /**
  937. * Retrieves a localized date-time formatting string.
  938. *
  939. * @param locale A locale code for the locale format rules to use.
  940. * @param width The format type.
  941. * @returns The localized formatting string.
  942. * @see {@link FormatWidth}
  943. * @see [Internationalization (i18n) Guide](guide/i18n)
  944. *
  945. * @publicApi
  946. *
  947. * @deprecated Angular recommends relying on the `Intl` API for i18n.
  948. * Use `Intl.DateTimeFormat` for date formating instead.
  949. */
  950. declare function getLocaleDateTimeFormat(locale: string, width: FormatWidth): string;
  951. /**
  952. * Retrieves a localized number symbol that can be used to replace placeholders in number formats.
  953. * @param locale The locale code.
  954. * @param symbol The symbol to localize. Must be one of `NumberSymbol`.
  955. * @returns The character for the localized symbol.
  956. * @see {@link NumberSymbol}
  957. * @see [Internationalization (i18n) Guide](guide/i18n)
  958. *
  959. * @publicApi
  960. *
  961. * @deprecated Angular recommends relying on the `Intl` API for i18n.
  962. * Use `Intl.NumberFormat` to format numbers instead.
  963. */
  964. declare function getLocaleNumberSymbol(locale: string, symbol: NumberSymbol): string;
  965. /**
  966. * Retrieves a number format for a given locale.
  967. *
  968. * Numbers are formatted using patterns, like `#,###.00`. For example, the pattern `#,###.00`
  969. * when used to format the number 12345.678 could result in "12'345,678". That would happen if the
  970. * grouping separator for your language is an apostrophe, and the decimal separator is a comma.
  971. *
  972. * <b>Important:</b> The characters `.` `,` `0` `#` (and others below) are special placeholders
  973. * that stand for the decimal separator, and so on, and are NOT real characters.
  974. * You must NOT "translate" the placeholders. For example, don't change `.` to `,` even though in
  975. * your language the decimal point is written with a comma. The symbols should be replaced by the
  976. * local equivalents, using the appropriate `NumberSymbol` for your language.
  977. *
  978. * Here are the special characters used in number patterns:
  979. *
  980. * | Symbol | Meaning |
  981. * |--------|---------|
  982. * | . | Replaced automatically by the character used for the decimal point. |
  983. * | , | Replaced by the "grouping" (thousands) separator. |
  984. * | 0 | Replaced by a digit (or zero if there aren't enough digits). |
  985. * | # | Replaced by a digit (or nothing if there aren't enough). |
  986. * | ¤ | Replaced by a currency symbol, such as $ or USD. |
  987. * | % | Marks a percent format. The % symbol may change position, but must be retained. |
  988. * | E | Marks a scientific format. The E symbol may change position, but must be retained. |
  989. * | ' | Special characters used as literal characters are quoted with ASCII single quotes. |
  990. *
  991. * @param locale A locale code for the locale format rules to use.
  992. * @param type The type of numeric value to be formatted (such as `Decimal` or `Currency`.)
  993. * @returns The localized format string.
  994. * @see {@link NumberFormatStyle}
  995. * @see [CLDR website](http://cldr.unicode.org/translation/number-patterns)
  996. * @see [Internationalization (i18n) Guide](guide/i18n)
  997. *
  998. * @publicApi
  999. *
  1000. * @deprecated Angular recommends relying on the `Intl` API for i18n.
  1001. * Let `Intl.NumberFormat` determine the number format instead
  1002. */
  1003. declare function getLocaleNumberFormat(locale: string, type: NumberFormatStyle): string;
  1004. /**
  1005. * Retrieves the symbol used to represent the currency for the main country
  1006. * corresponding to a given locale. For example, '$' for `en-US`.
  1007. *
  1008. * @param locale A locale code for the locale format rules to use.
  1009. * @returns The localized symbol character,
  1010. * or `null` if the main country cannot be determined.
  1011. * @see [Internationalization (i18n) Guide](guide/i18n)
  1012. *
  1013. * @publicApi
  1014. *
  1015. * @deprecated Use the `Intl` API to format a currency with from currency code
  1016. */
  1017. declare function getLocaleCurrencySymbol(locale: string): string | null;
  1018. /**
  1019. * Retrieves the name of the currency for the main country corresponding
  1020. * to a given locale. For example, 'US Dollar' for `en-US`.
  1021. * @param locale A locale code for the locale format rules to use.
  1022. * @returns The currency name,
  1023. * or `null` if the main country cannot be determined.
  1024. * @see [Internationalization (i18n) Guide](guide/i18n)
  1025. *
  1026. * @publicApi
  1027. *
  1028. * @deprecated Use the `Intl` API to format a currency with from currency code
  1029. */
  1030. declare function getLocaleCurrencyName(locale: string): string | null;
  1031. /**
  1032. * Retrieves the default currency code for the given locale.
  1033. *
  1034. * The default is defined as the first currency which is still in use.
  1035. *
  1036. * @param locale The code of the locale whose currency code we want.
  1037. * @returns The code of the default currency for the given locale.
  1038. *
  1039. * @publicApi
  1040. *
  1041. * @deprecated We recommend you create a map of locale to ISO 4217 currency codes.
  1042. * Time relative currency data is provided by the CLDR project. See https://www.unicode.org/cldr/charts/44/supplemental/detailed_territory_currency_information.html
  1043. */
  1044. declare function getLocaleCurrencyCode(locale: string): string | null;
  1045. /**
  1046. * @publicApi
  1047. *
  1048. * @deprecated Angular recommends relying on the `Intl` API for i18n.
  1049. * Use `Intl.PluralRules` instead
  1050. */
  1051. declare const getLocalePluralCase: (locale: string) => (value: number) => Plural;
  1052. /**
  1053. * Retrieves locale-specific rules used to determine which day period to use
  1054. * when more than one period is defined for a locale.
  1055. *
  1056. * There is a rule for each defined day period. The
  1057. * first rule is applied to the first day period and so on.
  1058. * Fall back to AM/PM when no rules are available.
  1059. *
  1060. * A rule can specify a period as time range, or as a single time value.
  1061. *
  1062. * This functionality is only available when you have loaded the full locale data.
  1063. * See the ["I18n guide"](guide/i18n/format-data-locale).
  1064. *
  1065. * @param locale A locale code for the locale format rules to use.
  1066. * @returns The rules for the locale, a single time value or array of *from-time, to-time*,
  1067. * or null if no periods are available.
  1068. *
  1069. * @see {@link getLocaleExtraDayPeriods}
  1070. * @see [Internationalization (i18n) Guide](guide/i18n)
  1071. *
  1072. * @publicApi
  1073. *
  1074. * @deprecated Angular recommends relying on the `Intl` API for i18n.
  1075. * Let `Intl.DateTimeFormat` determine the day period instead.
  1076. */
  1077. declare function getLocaleExtraDayPeriodRules(locale: string): (Time | [Time, Time])[];
  1078. /**
  1079. * Retrieves locale-specific day periods, which indicate roughly how a day is broken up
  1080. * in different languages.
  1081. * For example, for `en-US`, periods are morning, noon, afternoon, evening, and midnight.
  1082. *
  1083. * This functionality is only available when you have loaded the full locale data.
  1084. * See the ["I18n guide"](guide/i18n/format-data-locale).
  1085. *
  1086. * @param locale A locale code for the locale format rules to use.
  1087. * @param formStyle The required grammatical form.
  1088. * @param width The required character width.
  1089. * @returns The translated day-period strings.
  1090. * @see {@link getLocaleExtraDayPeriodRules}
  1091. * @see [Internationalization (i18n) Guide](guide/i18n)
  1092. *
  1093. * @publicApi
  1094. *
  1095. * @deprecated Angular recommends relying on the `Intl` API for i18n.
  1096. * To extract a day period use `Intl.DateTimeFormat` with the `dayPeriod` option instead.
  1097. */
  1098. declare function getLocaleExtraDayPeriods(locale: string, formStyle: FormStyle, width: TranslationWidth): string[];
  1099. /**
  1100. * Retrieves the writing direction of a specified locale
  1101. * @param locale A locale code for the locale format rules to use.
  1102. * @publicApi
  1103. * @returns 'rtl' or 'ltr'
  1104. * @see [Internationalization (i18n) Guide](guide/i18n)
  1105. *
  1106. * @deprecated Angular recommends relying on the `Intl` API for i18n.
  1107. * For dates and numbers, let `Intl.DateTimeFormat()` and `Intl.NumberFormat()` determine the writing direction.
  1108. * The `Intl` alternative [`getTextInfo`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Locale/getTextInfo).
  1109. * has only partial support (Chromium M99 & Safari 17).
  1110. * 3rd party alternatives like [`rtl-detect`](https://www.npmjs.com/package/rtl-detect) can work around this issue.
  1111. */
  1112. declare function getLocaleDirection(locale: string): 'ltr' | 'rtl';
  1113. /**
  1114. * Represents a time value with hours and minutes.
  1115. *
  1116. * @publicApi
  1117. *
  1118. * @deprecated Locale date getters are deprecated
  1119. */
  1120. type Time = {
  1121. hours: number;
  1122. minutes: number;
  1123. };
  1124. /**
  1125. * Retrieves the currency symbol for a given currency code.
  1126. *
  1127. * For example, for the default `en-US` locale, the code `USD` can
  1128. * be represented by the narrow symbol `$` or the wide symbol `US$`.
  1129. *
  1130. * @param code The currency code.
  1131. * @param format The format, `wide` or `narrow`.
  1132. * @param locale A locale code for the locale format rules to use.
  1133. *
  1134. * @returns The symbol, or the currency code if no symbol is available.
  1135. * @see [Internationalization (i18n) Guide](guide/i18n)
  1136. *
  1137. * @publicApi
  1138. *
  1139. * @deprecated Angular recommends relying on the `Intl` API for i18n.
  1140. * You can use `Intl.NumberFormat().formatToParts()` to extract the currency symbol.
  1141. * For example: `Intl.NumberFormat('en', {style:'currency', currency: 'USD'}).formatToParts().find(part => part.type === 'currency').value`
  1142. * returns `$` for USD currency code in the `en` locale.
  1143. * Note: `US$` is a currency symbol for the `en-ca` locale but not the `en-us` locale.
  1144. */
  1145. declare function getCurrencySymbol(code: string, format: 'wide' | 'narrow', locale?: string): string;
  1146. /**
  1147. * Reports the number of decimal digits for a given currency.
  1148. * The value depends upon the presence of cents in that particular currency.
  1149. *
  1150. * @param code The currency code.
  1151. * @returns The number of decimal digits, typically 0 or 2.
  1152. * @see [Internationalization (i18n) Guide](guide/i18n)
  1153. *
  1154. * @publicApi
  1155. *
  1156. * @deprecated Angular recommends relying on the `Intl` API for i18n.
  1157. * This function should not be used anymore. Let `Intl.NumberFormat` determine the number of digits to display for the currency
  1158. */
  1159. declare function getNumberOfCurrencyDigits(code: string): number;
  1160. declare function parseCookieValue(cookieStr: string, name: string): string | null;
  1161. /**
  1162. * @ngModule CommonModule
  1163. *
  1164. * @usageNotes
  1165. * ```html
  1166. * <some-element [ngClass]="stringExp|arrayExp|objExp|Set">...</some-element>
  1167. *
  1168. * <some-element [ngClass]="{'class1 class2 class3' : true}">...</some-element>
  1169. * ```
  1170. *
  1171. * For more simple use cases you can use the [class bindings](/guide/templates/binding#css-class-and-style-property-bindings) directly.
  1172. * It doesn't require importing a directive.
  1173. *
  1174. * ```html
  1175. * <some-element [class]="'first second'">...</some-element>
  1176. *
  1177. * <some-element [class.expanded]="isExpanded">...</some-element>
  1178. *
  1179. * <some-element [class]="['first', 'second']">...</some-element>
  1180. *
  1181. * <some-element [class]="{'first': true, 'second': true, 'third': false}">...</some-element>
  1182. * ```
  1183. * @description
  1184. *
  1185. * Adds and removes CSS classes on an HTML element.
  1186. *
  1187. * The CSS classes are updated as follows, depending on the type of the expression evaluation:
  1188. * - `string` - the CSS classes listed in the string (space delimited) are added,
  1189. * - `Array` - the CSS classes declared as Array elements are added,
  1190. * - `Object` - keys are CSS classes that get added when the expression given in the value
  1191. * evaluates to a truthy value, otherwise they are removed.
  1192. *
  1193. *
  1194. * @see [Class bindings](/guide/templates/binding#css-class-and-style-property-bindings)
  1195. *
  1196. * @publicApi
  1197. */
  1198. declare class NgClass implements DoCheck {
  1199. private _ngEl;
  1200. private _renderer;
  1201. private initialClasses;
  1202. private rawClass;
  1203. private stateMap;
  1204. constructor(_ngEl: ElementRef, _renderer: Renderer2);
  1205. set klass(value: string);
  1206. set ngClass(value: string | string[] | Set<string> | {
  1207. [klass: string]: any;
  1208. } | null | undefined);
  1209. ngDoCheck(): void;
  1210. private _updateState;
  1211. private _applyStateDiff;
  1212. private _toggleClass;
  1213. static ɵfac: i0.ɵɵFactoryDeclaration<NgClass, never>;
  1214. static ɵdir: i0.ɵɵDirectiveDeclaration<NgClass, "[ngClass]", never, { "klass": { "alias": "class"; "required": false; }; "ngClass": { "alias": "ngClass"; "required": false; }; }, {}, never, never, true, never>;
  1215. }
  1216. /**
  1217. * Instantiates a {@link /api/core/Component Component} type and inserts its Host View into the current View.
  1218. * `NgComponentOutlet` provides a declarative approach for dynamic component creation.
  1219. *
  1220. * `NgComponentOutlet` requires a component type, if a falsy value is set the view will clear and
  1221. * any existing component will be destroyed.
  1222. *
  1223. * @usageNotes
  1224. *
  1225. * ### Fine tune control
  1226. *
  1227. * You can control the component creation process by using the following optional attributes:
  1228. *
  1229. * * `ngComponentOutletInputs`: Optional component inputs object, which will be bind to the
  1230. * component.
  1231. *
  1232. * * `ngComponentOutletInjector`: Optional custom {@link Injector} that will be used as parent for
  1233. * the Component. Defaults to the injector of the current view container.
  1234. *
  1235. * * `ngComponentOutletContent`: Optional list of projectable nodes to insert into the content
  1236. * section of the component, if it exists.
  1237. *
  1238. * * `ngComponentOutletNgModule`: Optional NgModule class reference to allow loading another
  1239. * module dynamically, then loading a component from that module.
  1240. *
  1241. * * `ngComponentOutletNgModuleFactory`: Deprecated config option that allows providing optional
  1242. * NgModule factory to allow loading another module dynamically, then loading a component from that
  1243. * module. Use `ngComponentOutletNgModule` instead.
  1244. *
  1245. * ### Syntax
  1246. *
  1247. * Simple
  1248. * ```html
  1249. * <ng-container *ngComponentOutlet="componentTypeExpression"></ng-container>
  1250. * ```
  1251. *
  1252. * With inputs
  1253. * ```html
  1254. * <ng-container *ngComponentOutlet="componentTypeExpression;
  1255. * inputs: inputsExpression;">
  1256. * </ng-container>
  1257. * ```
  1258. *
  1259. * Customized injector/content
  1260. * ```html
  1261. * <ng-container *ngComponentOutlet="componentTypeExpression;
  1262. * injector: injectorExpression;
  1263. * content: contentNodesExpression;">
  1264. * </ng-container>
  1265. * ```
  1266. *
  1267. * Customized NgModule reference
  1268. * ```html
  1269. * <ng-container *ngComponentOutlet="componentTypeExpression;
  1270. * ngModule: ngModuleClass;">
  1271. * </ng-container>
  1272. * ```
  1273. *
  1274. * ### A simple example
  1275. *
  1276. * {@example common/ngComponentOutlet/ts/module.ts region='SimpleExample'}
  1277. *
  1278. * A more complete example with additional options:
  1279. *
  1280. * {@example common/ngComponentOutlet/ts/module.ts region='CompleteExample'}
  1281. *
  1282. * @publicApi
  1283. * @ngModule CommonModule
  1284. */
  1285. declare class NgComponentOutlet<T = any> implements OnChanges, DoCheck, OnDestroy {
  1286. private _viewContainerRef;
  1287. /** Component that should be rendered in the outlet. */
  1288. ngComponentOutlet: Type<any> | null;
  1289. ngComponentOutletInputs?: Record<string, unknown>;
  1290. ngComponentOutletInjector?: Injector;
  1291. ngComponentOutletContent?: any[][];
  1292. ngComponentOutletNgModule?: Type<any>;
  1293. /**
  1294. * @deprecated This input is deprecated, use `ngComponentOutletNgModule` instead.
  1295. */
  1296. ngComponentOutletNgModuleFactory?: NgModuleFactory<any>;
  1297. private _componentRef;
  1298. private _moduleRef;
  1299. /**
  1300. * A helper data structure that allows us to track inputs that were part of the
  1301. * ngComponentOutletInputs expression. Tracking inputs is necessary for proper removal of ones
  1302. * that are no longer referenced.
  1303. */
  1304. private _inputsUsed;
  1305. /**
  1306. * Gets the instance of the currently-rendered component.
  1307. * Will be null if no component has been rendered.
  1308. */
  1309. get componentInstance(): T | null;
  1310. constructor(_viewContainerRef: ViewContainerRef);
  1311. private _needToReCreateNgModuleInstance;
  1312. private _needToReCreateComponentInstance;
  1313. /** @nodoc */
  1314. ngOnChanges(changes: SimpleChanges): void;
  1315. /** @nodoc */
  1316. ngDoCheck(): void;
  1317. /** @nodoc */
  1318. ngOnDestroy(): void;
  1319. private _applyInputStateDiff;
  1320. static ɵfac: i0.ɵɵFactoryDeclaration<NgComponentOutlet<any>, never>;
  1321. static ɵdir: i0.ɵɵDirectiveDeclaration<NgComponentOutlet<any>, "[ngComponentOutlet]", ["ngComponentOutlet"], { "ngComponentOutlet": { "alias": "ngComponentOutlet"; "required": false; }; "ngComponentOutletInputs": { "alias": "ngComponentOutletInputs"; "required": false; }; "ngComponentOutletInjector": { "alias": "ngComponentOutletInjector"; "required": false; }; "ngComponentOutletContent": { "alias": "ngComponentOutletContent"; "required": false; }; "ngComponentOutletNgModule": { "alias": "ngComponentOutletNgModule"; "required": false; }; "ngComponentOutletNgModuleFactory": { "alias": "ngComponentOutletNgModuleFactory"; "required": false; }; }, {}, never, never, true, never>;
  1322. }
  1323. /**
  1324. * @publicApi
  1325. */
  1326. declare class NgForOfContext<T, U extends NgIterable<T> = NgIterable<T>> {
  1327. /** Reference to the current item from the collection. */
  1328. $implicit: T;
  1329. /**
  1330. * The value of the iterable expression. Useful when the expression is
  1331. * more complex then a property access, for example when using the async pipe
  1332. * (`userStreams | async`).
  1333. */
  1334. ngForOf: U;
  1335. /** Returns an index of the current item in the collection. */
  1336. index: number;
  1337. /** Returns total amount of items in the collection. */
  1338. count: number;
  1339. constructor(
  1340. /** Reference to the current item from the collection. */
  1341. $implicit: T,
  1342. /**
  1343. * The value of the iterable expression. Useful when the expression is
  1344. * more complex then a property access, for example when using the async pipe
  1345. * (`userStreams | async`).
  1346. */
  1347. ngForOf: U,
  1348. /** Returns an index of the current item in the collection. */
  1349. index: number,
  1350. /** Returns total amount of items in the collection. */
  1351. count: number);
  1352. get first(): boolean;
  1353. get last(): boolean;
  1354. get even(): boolean;
  1355. get odd(): boolean;
  1356. }
  1357. /**
  1358. * A [structural directive](guide/directives/structural-directives) that renders
  1359. * a template for each item in a collection.
  1360. * The directive is placed on an element, which becomes the parent
  1361. * of the cloned templates.
  1362. *
  1363. * The `ngForOf` directive is generally used in the
  1364. * [shorthand form](guide/directives/structural-directives#asterisk) `*ngFor`.
  1365. * In this form, the template to be rendered for each iteration is the content
  1366. * of an anchor element containing the directive.
  1367. *
  1368. * The following example shows the shorthand syntax with some options,
  1369. * contained in an `<li>` element.
  1370. *
  1371. * ```html
  1372. * <li *ngFor="let item of items; index as i; trackBy: trackByFn">...</li>
  1373. * ```
  1374. *
  1375. * The shorthand form expands into a long form that uses the `ngForOf` selector
  1376. * on an `<ng-template>` element.
  1377. * The content of the `<ng-template>` element is the `<li>` element that held the
  1378. * short-form directive.
  1379. *
  1380. * Here is the expanded version of the short-form example.
  1381. *
  1382. * ```html
  1383. * <ng-template ngFor let-item [ngForOf]="items" let-i="index" [ngForTrackBy]="trackByFn">
  1384. * <li>...</li>
  1385. * </ng-template>
  1386. * ```
  1387. *
  1388. * Angular automatically expands the shorthand syntax as it compiles the template.
  1389. * The context for each embedded view is logically merged to the current component
  1390. * context according to its lexical position.
  1391. *
  1392. * When using the shorthand syntax, Angular allows only [one structural directive
  1393. * on an element](guide/directives/structural-directives#one-per-element).
  1394. * If you want to iterate conditionally, for example,
  1395. * put the `*ngIf` on a container element that wraps the `*ngFor` element.
  1396. * For further discussion, see
  1397. * [Structural Directives](guide/directives/structural-directives#one-per-element).
  1398. *
  1399. * @usageNotes
  1400. *
  1401. * ### Local variables
  1402. *
  1403. * `NgForOf` provides exported values that can be aliased to local variables.
  1404. * For example:
  1405. *
  1406. * ```html
  1407. * <li *ngFor="let user of users; index as i; first as isFirst">
  1408. * {{i}}/{{users.length}}. {{user}} <span *ngIf="isFirst">default</span>
  1409. * </li>
  1410. * ```
  1411. *
  1412. * The following exported values can be aliased to local variables:
  1413. *
  1414. * - `$implicit: T`: The value of the individual items in the iterable (`ngForOf`).
  1415. * - `ngForOf: NgIterable<T>`: The value of the iterable expression. Useful when the expression is
  1416. * more complex then a property access, for example when using the async pipe (`userStreams |
  1417. * async`).
  1418. * - `index: number`: The index of the current item in the iterable.
  1419. * - `count: number`: The length of the iterable.
  1420. * - `first: boolean`: True when the item is the first item in the iterable.
  1421. * - `last: boolean`: True when the item is the last item in the iterable.
  1422. * - `even: boolean`: True when the item has an even index in the iterable.
  1423. * - `odd: boolean`: True when the item has an odd index in the iterable.
  1424. *
  1425. * ### Change propagation
  1426. *
  1427. * When the contents of the iterator changes, `NgForOf` makes the corresponding changes to the DOM:
  1428. *
  1429. * * When an item is added, a new instance of the template is added to the DOM.
  1430. * * When an item is removed, its template instance is removed from the DOM.
  1431. * * When items are reordered, their respective templates are reordered in the DOM.
  1432. *
  1433. * Angular uses object identity to track insertions and deletions within the iterator and reproduce
  1434. * those changes in the DOM. This has important implications for animations and any stateful
  1435. * controls that are present, such as `<input>` elements that accept user input. Inserted rows can
  1436. * be animated in, deleted rows can be animated out, and unchanged rows retain any unsaved state
  1437. * such as user input.
  1438. * For more on animations, see [Transitions and Triggers](guide/animations/transition-and-triggers).
  1439. *
  1440. * The identities of elements in the iterator can change while the data does not.
  1441. * This can happen, for example, if the iterator is produced from an RPC to the server, and that
  1442. * RPC is re-run. Even if the data hasn't changed, the second response produces objects with
  1443. * different identities, and Angular must tear down the entire DOM and rebuild it (as if all old
  1444. * elements were deleted and all new elements inserted).
  1445. *
  1446. * To avoid this expensive operation, you can customize the default tracking algorithm.
  1447. * by supplying the `trackBy` option to `NgForOf`.
  1448. * `trackBy` takes a function that has two arguments: `index` and `item`.
  1449. * If `trackBy` is given, Angular tracks changes by the return value of the function.
  1450. *
  1451. * @see [Structural Directives](guide/directives/structural-directives)
  1452. * @ngModule CommonModule
  1453. * @publicApi
  1454. */
  1455. declare class NgForOf<T, U extends NgIterable<T> = NgIterable<T>> implements DoCheck {
  1456. private _viewContainer;
  1457. private _template;
  1458. private _differs;
  1459. /**
  1460. * The value of the iterable expression, which can be used as a
  1461. * [template input variable](guide/directives/structural-directives#shorthand).
  1462. */
  1463. set ngForOf(ngForOf: (U & NgIterable<T>) | undefined | null);
  1464. /**
  1465. * Specifies a custom `TrackByFunction` to compute the identity of items in an iterable.
  1466. *
  1467. * If a custom `TrackByFunction` is not provided, `NgForOf` will use the item's [object
  1468. * identity](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is)
  1469. * as the key.
  1470. *
  1471. * `NgForOf` uses the computed key to associate items in an iterable with DOM elements
  1472. * it produces for these items.
  1473. *
  1474. * A custom `TrackByFunction` is useful to provide good user experience in cases when items in an
  1475. * iterable rendered using `NgForOf` have a natural identifier (for example, custom ID or a
  1476. * primary key), and this iterable could be updated with new object instances that still
  1477. * represent the same underlying entity (for example, when data is re-fetched from the server,
  1478. * and the iterable is recreated and re-rendered, but most of the data is still the same).
  1479. *
  1480. * @see {@link TrackByFunction}
  1481. */
  1482. set ngForTrackBy(fn: TrackByFunction<T>);
  1483. get ngForTrackBy(): TrackByFunction<T>;
  1484. private _ngForOf;
  1485. private _ngForOfDirty;
  1486. private _differ;
  1487. private _trackByFn;
  1488. constructor(_viewContainer: ViewContainerRef, _template: TemplateRef<NgForOfContext<T, U>>, _differs: IterableDiffers);
  1489. /**
  1490. * A reference to the template that is stamped out for each item in the iterable.
  1491. * @see [template reference variable](guide/templates/variables#template-reference-variables)
  1492. */
  1493. set ngForTemplate(value: TemplateRef<NgForOfContext<T, U>>);
  1494. /**
  1495. * Applies the changes when needed.
  1496. * @nodoc
  1497. */
  1498. ngDoCheck(): void;
  1499. private _applyChanges;
  1500. /**
  1501. * Asserts the correct type of the context for the template that `NgForOf` will render.
  1502. *
  1503. * The presence of this method is a signal to the Ivy template type-check compiler that the
  1504. * `NgForOf` structural directive renders its template with a specific context type.
  1505. */
  1506. static ngTemplateContextGuard<T, U extends NgIterable<T>>(dir: NgForOf<T, U>, ctx: any): ctx is NgForOfContext<T, U>;
  1507. static ɵfac: i0.ɵɵFactoryDeclaration<NgForOf<any, any>, never>;
  1508. static ɵdir: i0.ɵɵDirectiveDeclaration<NgForOf<any, any>, "[ngFor][ngForOf]", never, { "ngForOf": { "alias": "ngForOf"; "required": false; }; "ngForTrackBy": { "alias": "ngForTrackBy"; "required": false; }; "ngForTemplate": { "alias": "ngForTemplate"; "required": false; }; }, {}, never, never, true, never>;
  1509. }
  1510. /**
  1511. * A structural directive that conditionally includes a template based on the value of
  1512. * an expression coerced to Boolean.
  1513. * When the expression evaluates to true, Angular renders the template
  1514. * provided in a `then` clause, and when false or null,
  1515. * Angular renders the template provided in an optional `else` clause. The default
  1516. * template for the `else` clause is blank.
  1517. *
  1518. * A [shorthand form](guide/directives/structural-directives#asterisk) of the directive,
  1519. * `*ngIf="condition"`, is generally used, provided
  1520. * as an attribute of the anchor element for the inserted template.
  1521. * Angular expands this into a more explicit version, in which the anchor element
  1522. * is contained in an `<ng-template>` element.
  1523. *
  1524. * Simple form with shorthand syntax:
  1525. *
  1526. * ```html
  1527. * <div *ngIf="condition">Content to render when condition is true.</div>
  1528. * ```
  1529. *
  1530. * Simple form with expanded syntax:
  1531. *
  1532. * ```html
  1533. * <ng-template [ngIf]="condition"><div>Content to render when condition is
  1534. * true.</div></ng-template>
  1535. * ```
  1536. *
  1537. * Form with an "else" block:
  1538. *
  1539. * ```html
  1540. * <div *ngIf="condition; else elseBlock">Content to render when condition is true.</div>
  1541. * <ng-template #elseBlock>Content to render when condition is false.</ng-template>
  1542. * ```
  1543. *
  1544. * Shorthand form with "then" and "else" blocks:
  1545. *
  1546. * ```html
  1547. * <div *ngIf="condition; then thenBlock else elseBlock"></div>
  1548. * <ng-template #thenBlock>Content to render when condition is true.</ng-template>
  1549. * <ng-template #elseBlock>Content to render when condition is false.</ng-template>
  1550. * ```
  1551. *
  1552. * Form with storing the value locally:
  1553. *
  1554. * ```html
  1555. * <div *ngIf="condition as value; else elseBlock">{{value}}</div>
  1556. * <ng-template #elseBlock>Content to render when value is null.</ng-template>
  1557. * ```
  1558. *
  1559. * @usageNotes
  1560. *
  1561. * The `*ngIf` directive is most commonly used to conditionally show an inline template,
  1562. * as seen in the following example.
  1563. * The default `else` template is blank.
  1564. *
  1565. * {@example common/ngIf/ts/module.ts region='NgIfSimple'}
  1566. *
  1567. * ### Showing an alternative template using `else`
  1568. *
  1569. * To display a template when `expression` evaluates to false, use an `else` template
  1570. * binding as shown in the following example.
  1571. * The `else` binding points to an `<ng-template>` element labeled `#elseBlock`.
  1572. * The template can be defined anywhere in the component view, but is typically placed right after
  1573. * `ngIf` for readability.
  1574. *
  1575. * {@example common/ngIf/ts/module.ts region='NgIfElse'}
  1576. *
  1577. * ### Using an external `then` template
  1578. *
  1579. * In the previous example, the then-clause template is specified inline, as the content of the
  1580. * tag that contains the `ngIf` directive. You can also specify a template that is defined
  1581. * externally, by referencing a labeled `<ng-template>` element. When you do this, you can
  1582. * change which template to use at runtime, as shown in the following example.
  1583. *
  1584. * {@example common/ngIf/ts/module.ts region='NgIfThenElse'}
  1585. *
  1586. * ### Storing a conditional result in a variable
  1587. *
  1588. * You might want to show a set of properties from the same object. If you are waiting
  1589. * for asynchronous data, the object can be undefined.
  1590. * In this case, you can use `ngIf` and store the result of the condition in a local
  1591. * variable as shown in the following example.
  1592. *
  1593. * {@example common/ngIf/ts/module.ts region='NgIfAs'}
  1594. *
  1595. * This code uses only one `AsyncPipe`, so only one subscription is created.
  1596. * The conditional statement stores the result of `userStream|async` in the local variable `user`.
  1597. * You can then bind the local `user` repeatedly.
  1598. *
  1599. * The conditional displays the data only if `userStream` returns a value,
  1600. * so you don't need to use the
  1601. * safe-navigation-operator (`?.`)
  1602. * to guard against null values when accessing properties.
  1603. * You can display an alternative template while waiting for the data.
  1604. *
  1605. * ### Shorthand syntax
  1606. *
  1607. * The shorthand syntax `*ngIf` expands into two separate template specifications
  1608. * for the "then" and "else" clauses. For example, consider the following shorthand statement,
  1609. * that is meant to show a loading page while waiting for data to be loaded.
  1610. *
  1611. * ```html
  1612. * <div class="hero-list" *ngIf="heroes else loading">
  1613. * ...
  1614. * </div>
  1615. *
  1616. * <ng-template #loading>
  1617. * <div>Loading...</div>
  1618. * </ng-template>
  1619. * ```
  1620. *
  1621. * You can see that the "else" clause references the `<ng-template>`
  1622. * with the `#loading` label, and the template for the "then" clause
  1623. * is provided as the content of the anchor element.
  1624. *
  1625. * However, when Angular expands the shorthand syntax, it creates
  1626. * another `<ng-template>` tag, with `ngIf` and `ngIfElse` directives.
  1627. * The anchor element containing the template for the "then" clause becomes
  1628. * the content of this unlabeled `<ng-template>` tag.
  1629. *
  1630. * ```html
  1631. * <ng-template [ngIf]="heroes" [ngIfElse]="loading">
  1632. * <div class="hero-list">
  1633. * ...
  1634. * </div>
  1635. * </ng-template>
  1636. *
  1637. * <ng-template #loading>
  1638. * <div>Loading...</div>
  1639. * </ng-template>
  1640. * ```
  1641. *
  1642. * The presence of the implicit template object has implications for the nesting of
  1643. * structural directives. For more on this subject, see
  1644. * [Structural Directives](guide/directives/structural-directives#one-per-element).
  1645. *
  1646. * @ngModule CommonModule
  1647. * @publicApi
  1648. */
  1649. declare class NgIf<T = unknown> {
  1650. private _viewContainer;
  1651. private _context;
  1652. private _thenTemplateRef;
  1653. private _elseTemplateRef;
  1654. private _thenViewRef;
  1655. private _elseViewRef;
  1656. constructor(_viewContainer: ViewContainerRef, templateRef: TemplateRef<NgIfContext<T>>);
  1657. /**
  1658. * The Boolean expression to evaluate as the condition for showing a template.
  1659. */
  1660. set ngIf(condition: T);
  1661. /**
  1662. * A template to show if the condition expression evaluates to true.
  1663. */
  1664. set ngIfThen(templateRef: TemplateRef<NgIfContext<T>> | null);
  1665. /**
  1666. * A template to show if the condition expression evaluates to false.
  1667. */
  1668. set ngIfElse(templateRef: TemplateRef<NgIfContext<T>> | null);
  1669. private _updateView;
  1670. /**
  1671. * Assert the correct type of the expression bound to the `ngIf` input within the template.
  1672. *
  1673. * The presence of this static field is a signal to the Ivy template type check compiler that
  1674. * when the `NgIf` structural directive renders its template, the type of the expression bound
  1675. * to `ngIf` should be narrowed in some way. For `NgIf`, the binding expression itself is used to
  1676. * narrow its type, which allows the strictNullChecks feature of TypeScript to work with `NgIf`.
  1677. */
  1678. static ngTemplateGuard_ngIf: 'binding';
  1679. /**
  1680. * Asserts the correct type of the context for the template that `NgIf` will render.
  1681. *
  1682. * The presence of this method is a signal to the Ivy template type-check compiler that the
  1683. * `NgIf` structural directive renders its template with a specific context type.
  1684. */
  1685. static ngTemplateContextGuard<T>(dir: NgIf<T>, ctx: any): ctx is NgIfContext<Exclude<T, false | 0 | '' | null | undefined>>;
  1686. static ɵfac: i0.ɵɵFactoryDeclaration<NgIf<any>, never>;
  1687. static ɵdir: i0.ɵɵDirectiveDeclaration<NgIf<any>, "[ngIf]", never, { "ngIf": { "alias": "ngIf"; "required": false; }; "ngIfThen": { "alias": "ngIfThen"; "required": false; }; "ngIfElse": { "alias": "ngIfElse"; "required": false; }; }, {}, never, never, true, never>;
  1688. }
  1689. /**
  1690. * @publicApi
  1691. */
  1692. declare class NgIfContext<T = unknown> {
  1693. $implicit: T;
  1694. ngIf: T;
  1695. }
  1696. /**
  1697. * @ngModule CommonModule
  1698. *
  1699. * @description
  1700. *
  1701. * Inserts an embedded view from a prepared `TemplateRef`.
  1702. *
  1703. * You can attach a context object to the `EmbeddedViewRef` by setting `[ngTemplateOutletContext]`.
  1704. * `[ngTemplateOutletContext]` should be an object, the object's keys will be available for binding
  1705. * by the local template `let` declarations.
  1706. *
  1707. * @usageNotes
  1708. * ```html
  1709. * <ng-container *ngTemplateOutlet="templateRefExp; context: contextExp"></ng-container>
  1710. * ```
  1711. *
  1712. * Using the key `$implicit` in the context object will set its value as default.
  1713. *
  1714. * ### Example
  1715. *
  1716. * {@example common/ngTemplateOutlet/ts/module.ts region='NgTemplateOutlet'}
  1717. *
  1718. * @publicApi
  1719. */
  1720. declare class NgTemplateOutlet<C = unknown> implements OnChanges {
  1721. private _viewContainerRef;
  1722. private _viewRef;
  1723. /**
  1724. * A context object to attach to the {@link EmbeddedViewRef}. This should be an
  1725. * object, the object's keys will be available for binding by the local template `let`
  1726. * declarations.
  1727. * Using the key `$implicit` in the context object will set its value as default.
  1728. */
  1729. ngTemplateOutletContext: C | null;
  1730. /**
  1731. * A string defining the template reference and optionally the context object for the template.
  1732. */
  1733. ngTemplateOutlet: TemplateRef<C> | null;
  1734. /** Injector to be used within the embedded view. */
  1735. ngTemplateOutletInjector: Injector | null;
  1736. constructor(_viewContainerRef: ViewContainerRef);
  1737. ngOnChanges(changes: SimpleChanges): void;
  1738. /**
  1739. * We need to re-create existing embedded view if either is true:
  1740. * - the outlet changed.
  1741. * - the injector changed.
  1742. */
  1743. private _shouldRecreateView;
  1744. /**
  1745. * For a given outlet instance, we create a proxy object that delegates
  1746. * to the user-specified context. This allows changing, or swapping out
  1747. * the context object completely without having to destroy/re-create the view.
  1748. */
  1749. private _createContextForwardProxy;
  1750. static ɵfac: i0.ɵɵFactoryDeclaration<NgTemplateOutlet<any>, never>;
  1751. static ɵdir: i0.ɵɵDirectiveDeclaration<NgTemplateOutlet<any>, "[ngTemplateOutlet]", never, { "ngTemplateOutletContext": { "alias": "ngTemplateOutletContext"; "required": false; }; "ngTemplateOutlet": { "alias": "ngTemplateOutlet"; "required": false; }; "ngTemplateOutletInjector": { "alias": "ngTemplateOutletInjector"; "required": false; }; }, {}, never, never, true, never>;
  1752. }
  1753. /**
  1754. * @ngModule CommonModule
  1755. *
  1756. * @usageNotes
  1757. *
  1758. * Set the width of the containing element to a pixel value returned by an expression.
  1759. *
  1760. * ```html
  1761. * <some-element [ngStyle]="{'max-width.px': widthExp}">...</some-element>
  1762. * ```
  1763. *
  1764. * Set a collection of style values using an expression that returns key-value pairs.
  1765. *
  1766. * ```html
  1767. * <some-element [ngStyle]="objExp">...</some-element>
  1768. * ```
  1769. *
  1770. * For more simple use cases you can use the [style bindings](/guide/templates/binding#css-class-and-style-property-bindings) directly.
  1771. * It doesn't require importing a directive.
  1772. *
  1773. * Set the font of the containing element to the result of an expression.
  1774. *
  1775. * ```html
  1776. * <some-element [style]="{'font-style': styleExp}">...</some-element>
  1777. * ```
  1778. *
  1779. * @description
  1780. *
  1781. * An attribute directive that updates styles for the containing HTML element.
  1782. * Sets one or more style properties, specified as colon-separated key-value pairs.
  1783. * The key is a style name, with an optional `.<unit>` suffix
  1784. * (such as 'top.px', 'font-style.em').
  1785. * The value is an expression to be evaluated.
  1786. * The resulting non-null value, expressed in the given unit,
  1787. * is assigned to the given style property.
  1788. * If the result of evaluation is null, the corresponding style is removed.
  1789. *
  1790. * @see [Style bindings](/guide/templates/binding#css-class-and-style-property-bindings)
  1791. *
  1792. * @publicApi
  1793. */
  1794. declare class NgStyle implements DoCheck {
  1795. private _ngEl;
  1796. private _differs;
  1797. private _renderer;
  1798. private _ngStyle;
  1799. private _differ;
  1800. constructor(_ngEl: ElementRef, _differs: KeyValueDiffers, _renderer: Renderer2);
  1801. set ngStyle(values: {
  1802. [klass: string]: any;
  1803. } | null | undefined);
  1804. ngDoCheck(): void;
  1805. private _setStyle;
  1806. private _applyChanges;
  1807. static ɵfac: i0.ɵɵFactoryDeclaration<NgStyle, never>;
  1808. static ɵdir: i0.ɵɵDirectiveDeclaration<NgStyle, "[ngStyle]", never, { "ngStyle": { "alias": "ngStyle"; "required": false; }; }, {}, never, never, true, never>;
  1809. }
  1810. declare class SwitchView {
  1811. private _viewContainerRef;
  1812. private _templateRef;
  1813. private _created;
  1814. constructor(_viewContainerRef: ViewContainerRef, _templateRef: TemplateRef<Object>);
  1815. create(): void;
  1816. destroy(): void;
  1817. enforceState(created: boolean): void;
  1818. }
  1819. /**
  1820. * @ngModule CommonModule
  1821. *
  1822. * @description
  1823. * The `[ngSwitch]` directive on a container specifies an expression to match against.
  1824. * The expressions to match are provided by `ngSwitchCase` directives on views within the container.
  1825. * - Every view that matches is rendered.
  1826. * - If there are no matches, a view with the `ngSwitchDefault` directive is rendered.
  1827. * - Elements within the `[NgSwitch]` statement but outside of any `NgSwitchCase`
  1828. * or `ngSwitchDefault` directive are preserved at the location.
  1829. *
  1830. * @usageNotes
  1831. * Define a container element for the directive, and specify the switch expression
  1832. * to match against as an attribute:
  1833. *
  1834. * ```html
  1835. * <container-element [ngSwitch]="switch_expression">
  1836. * ```
  1837. *
  1838. * Within the container, `*ngSwitchCase` statements specify the match expressions
  1839. * as attributes. Include `*ngSwitchDefault` as the final case.
  1840. *
  1841. * ```html
  1842. * <container-element [ngSwitch]="switch_expression">
  1843. * <some-element *ngSwitchCase="match_expression_1">...</some-element>
  1844. * ...
  1845. * <some-element *ngSwitchDefault>...</some-element>
  1846. * </container-element>
  1847. * ```
  1848. *
  1849. * ### Usage Examples
  1850. *
  1851. * The following example shows how to use more than one case to display the same view:
  1852. *
  1853. * ```html
  1854. * <container-element [ngSwitch]="switch_expression">
  1855. * <!-- the same view can be shown in more than one case -->
  1856. * <some-element *ngSwitchCase="match_expression_1">...</some-element>
  1857. * <some-element *ngSwitchCase="match_expression_2">...</some-element>
  1858. * <some-other-element *ngSwitchCase="match_expression_3">...</some-other-element>
  1859. * <!--default case when there are no matches -->
  1860. * <some-element *ngSwitchDefault>...</some-element>
  1861. * </container-element>
  1862. * ```
  1863. *
  1864. * The following example shows how cases can be nested:
  1865. * ```html
  1866. * <container-element [ngSwitch]="switch_expression">
  1867. * <some-element *ngSwitchCase="match_expression_1">...</some-element>
  1868. * <some-element *ngSwitchCase="match_expression_2">...</some-element>
  1869. * <some-other-element *ngSwitchCase="match_expression_3">...</some-other-element>
  1870. * <ng-container *ngSwitchCase="match_expression_3">
  1871. * <!-- use a ng-container to group multiple root nodes -->
  1872. * <inner-element></inner-element>
  1873. * <inner-other-element></inner-other-element>
  1874. * </ng-container>
  1875. * <some-element *ngSwitchDefault>...</some-element>
  1876. * </container-element>
  1877. * ```
  1878. *
  1879. * @publicApi
  1880. * @see {@link NgSwitchCase}
  1881. * @see {@link NgSwitchDefault}
  1882. * @see [Structural Directives](guide/directives/structural-directives)
  1883. *
  1884. */
  1885. declare class NgSwitch {
  1886. private _defaultViews;
  1887. private _defaultUsed;
  1888. private _caseCount;
  1889. private _lastCaseCheckIndex;
  1890. private _lastCasesMatched;
  1891. private _ngSwitch;
  1892. set ngSwitch(newValue: any);
  1893. private _updateDefaultCases;
  1894. static ɵfac: i0.ɵɵFactoryDeclaration<NgSwitch, never>;
  1895. static ɵdir: i0.ɵɵDirectiveDeclaration<NgSwitch, "[ngSwitch]", never, { "ngSwitch": { "alias": "ngSwitch"; "required": false; }; }, {}, never, never, true, never>;
  1896. }
  1897. /**
  1898. * @ngModule CommonModule
  1899. *
  1900. * @description
  1901. * Provides a switch case expression to match against an enclosing `ngSwitch` expression.
  1902. * When the expressions match, the given `NgSwitchCase` template is rendered.
  1903. * If multiple match expressions match the switch expression value, all of them are displayed.
  1904. *
  1905. * @usageNotes
  1906. *
  1907. * Within a switch container, `*ngSwitchCase` statements specify the match expressions
  1908. * as attributes. Include `*ngSwitchDefault` as the final case.
  1909. *
  1910. * ```html
  1911. * <container-element [ngSwitch]="switch_expression">
  1912. * <some-element *ngSwitchCase="match_expression_1">...</some-element>
  1913. * ...
  1914. * <some-element *ngSwitchDefault>...</some-element>
  1915. * </container-element>
  1916. * ```
  1917. *
  1918. * Each switch-case statement contains an in-line HTML template or template reference
  1919. * that defines the subtree to be selected if the value of the match expression
  1920. * matches the value of the switch expression.
  1921. *
  1922. * As of Angular v17 the NgSwitch directive uses strict equality comparison (`===`) instead of
  1923. * loose equality (`==`) to match different cases.
  1924. *
  1925. * @publicApi
  1926. * @see {@link NgSwitch}
  1927. * @see {@link NgSwitchDefault}
  1928. *
  1929. */
  1930. declare class NgSwitchCase implements DoCheck {
  1931. private ngSwitch;
  1932. private _view;
  1933. /**
  1934. * Stores the HTML template to be selected on match.
  1935. */
  1936. ngSwitchCase: any;
  1937. constructor(viewContainer: ViewContainerRef, templateRef: TemplateRef<Object>, ngSwitch: NgSwitch);
  1938. /**
  1939. * Performs case matching. For internal use only.
  1940. * @nodoc
  1941. */
  1942. ngDoCheck(): void;
  1943. static ɵfac: i0.ɵɵFactoryDeclaration<NgSwitchCase, [null, null, { optional: true; host: true; }]>;
  1944. static ɵdir: i0.ɵɵDirectiveDeclaration<NgSwitchCase, "[ngSwitchCase]", never, { "ngSwitchCase": { "alias": "ngSwitchCase"; "required": false; }; }, {}, never, never, true, never>;
  1945. }
  1946. /**
  1947. * @ngModule CommonModule
  1948. *
  1949. * @description
  1950. *
  1951. * Creates a view that is rendered when no `NgSwitchCase` expressions
  1952. * match the `NgSwitch` expression.
  1953. * This statement should be the final case in an `NgSwitch`.
  1954. *
  1955. * @publicApi
  1956. * @see {@link NgSwitch}
  1957. * @see {@link NgSwitchCase}
  1958. *
  1959. */
  1960. declare class NgSwitchDefault {
  1961. constructor(viewContainer: ViewContainerRef, templateRef: TemplateRef<Object>, ngSwitch: NgSwitch);
  1962. static ɵfac: i0.ɵɵFactoryDeclaration<NgSwitchDefault, [null, null, { optional: true; host: true; }]>;
  1963. static ɵdir: i0.ɵɵDirectiveDeclaration<NgSwitchDefault, "[ngSwitchDefault]", never, {}, {}, never, never, true, never>;
  1964. }
  1965. /**
  1966. * @ngModule CommonModule
  1967. *
  1968. * @usageNotes
  1969. * ```html
  1970. * <some-element [ngPlural]="value">
  1971. * <ng-template ngPluralCase="=0">there is nothing</ng-template>
  1972. * <ng-template ngPluralCase="=1">there is one</ng-template>
  1973. * <ng-template ngPluralCase="few">there are a few</ng-template>
  1974. * </some-element>
  1975. * ```
  1976. *
  1977. * @description
  1978. *
  1979. * Adds / removes DOM sub-trees based on a numeric value. Tailored for pluralization.
  1980. *
  1981. * Displays DOM sub-trees that match the switch expression value, or failing that, DOM sub-trees
  1982. * that match the switch expression's pluralization category.
  1983. *
  1984. * To use this directive you must provide a container element that sets the `[ngPlural]` attribute
  1985. * to a switch expression. Inner elements with a `[ngPluralCase]` will display based on their
  1986. * expression:
  1987. * - if `[ngPluralCase]` is set to a value starting with `=`, it will only display if the value
  1988. * matches the switch expression exactly,
  1989. * - otherwise, the view will be treated as a "category match", and will only display if exact
  1990. * value matches aren't found and the value maps to its category for the defined locale.
  1991. *
  1992. * See http://cldr.unicode.org/index/cldr-spec/plural-rules
  1993. *
  1994. * @publicApi
  1995. */
  1996. declare class NgPlural {
  1997. private _localization;
  1998. private _activeView?;
  1999. private _caseViews;
  2000. constructor(_localization: NgLocalization);
  2001. set ngPlural(value: number);
  2002. addCase(value: string, switchView: SwitchView): void;
  2003. private _updateView;
  2004. private _clearViews;
  2005. private _activateView;
  2006. static ɵfac: i0.ɵɵFactoryDeclaration<NgPlural, never>;
  2007. static ɵdir: i0.ɵɵDirectiveDeclaration<NgPlural, "[ngPlural]", never, { "ngPlural": { "alias": "ngPlural"; "required": false; }; }, {}, never, never, true, never>;
  2008. }
  2009. /**
  2010. * @ngModule CommonModule
  2011. *
  2012. * @description
  2013. *
  2014. * Creates a view that will be added/removed from the parent {@link NgPlural} when the
  2015. * given expression matches the plural expression according to CLDR rules.
  2016. *
  2017. * @usageNotes
  2018. * ```html
  2019. * <some-element [ngPlural]="value">
  2020. * <ng-template ngPluralCase="=0">...</ng-template>
  2021. * <ng-template ngPluralCase="other">...</ng-template>
  2022. * </some-element>
  2023. *```
  2024. *
  2025. * See {@link NgPlural} for more details and example.
  2026. *
  2027. * @publicApi
  2028. */
  2029. declare class NgPluralCase {
  2030. value: string;
  2031. constructor(value: string, template: TemplateRef<Object>, viewContainer: ViewContainerRef, ngPlural: NgPlural);
  2032. static ɵfac: i0.ɵɵFactoryDeclaration<NgPluralCase, [{ attribute: "ngPluralCase"; }, null, null, { host: true; }]>;
  2033. static ɵdir: i0.ɵɵDirectiveDeclaration<NgPluralCase, "[ngPluralCase]", never, {}, {}, never, never, true, never>;
  2034. }
  2035. /**
  2036. * @ngModule CommonModule
  2037. * @description
  2038. *
  2039. * Unwraps a value from an asynchronous primitive.
  2040. *
  2041. * The `async` pipe subscribes to an `Observable` or `Promise` and returns the latest value it has
  2042. * emitted. When a new value is emitted, the `async` pipe marks the component to be checked for
  2043. * changes. When the component gets destroyed, the `async` pipe unsubscribes automatically to avoid
  2044. * potential memory leaks. When the reference of the expression changes, the `async` pipe
  2045. * automatically unsubscribes from the old `Observable` or `Promise` and subscribes to the new one.
  2046. *
  2047. * @usageNotes
  2048. *
  2049. * ### Examples
  2050. *
  2051. * This example binds a `Promise` to the view. Clicking the `Resolve` button resolves the
  2052. * promise.
  2053. *
  2054. * {@example common/pipes/ts/async_pipe.ts region='AsyncPipePromise'}
  2055. *
  2056. * It's also possible to use `async` with Observables. The example below binds the `time` Observable
  2057. * to the view. The Observable continuously updates the view with the current time.
  2058. *
  2059. * {@example common/pipes/ts/async_pipe.ts region='AsyncPipeObservable'}
  2060. *
  2061. * @publicApi
  2062. */
  2063. declare class AsyncPipe implements OnDestroy, PipeTransform {
  2064. private _ref;
  2065. private _latestValue;
  2066. private markForCheckOnValueUpdate;
  2067. private _subscription;
  2068. private _obj;
  2069. private _strategy;
  2070. constructor(ref: ChangeDetectorRef);
  2071. ngOnDestroy(): void;
  2072. transform<T>(obj: Observable<T> | Subscribable<T> | Promise<T>): T | null;
  2073. transform<T>(obj: null | undefined): null;
  2074. transform<T>(obj: Observable<T> | Subscribable<T> | Promise<T> | null | undefined): T | null;
  2075. private _subscribe;
  2076. private _selectStrategy;
  2077. private _dispose;
  2078. private _updateLatestValue;
  2079. static ɵfac: i0.ɵɵFactoryDeclaration<AsyncPipe, never>;
  2080. static ɵpipe: i0.ɵɵPipeDeclaration<AsyncPipe, "async", true>;
  2081. }
  2082. /**
  2083. * Transforms text to all lower case.
  2084. *
  2085. * @see {@link UpperCasePipe}
  2086. * @see {@link TitleCasePipe}
  2087. * @usageNotes
  2088. *
  2089. * The following example defines a view that allows the user to enter
  2090. * text, and then uses the pipe to convert the input text to all lower case.
  2091. *
  2092. * {@example common/pipes/ts/lowerupper_pipe.ts region='LowerUpperPipe'}
  2093. *
  2094. * @ngModule CommonModule
  2095. * @publicApi
  2096. */
  2097. declare class LowerCasePipe implements PipeTransform {
  2098. /**
  2099. * @param value The string to transform to lower case.
  2100. */
  2101. transform(value: string): string;
  2102. transform(value: null | undefined): null;
  2103. transform(value: string | null | undefined): string | null;
  2104. static ɵfac: i0.ɵɵFactoryDeclaration<LowerCasePipe, never>;
  2105. static ɵpipe: i0.ɵɵPipeDeclaration<LowerCasePipe, "lowercase", true>;
  2106. }
  2107. /**
  2108. * Transforms text to title case.
  2109. * Capitalizes the first letter of each word and transforms the
  2110. * rest of the word to lower case.
  2111. * Words are delimited by any whitespace character, such as a space, tab, or line-feed character.
  2112. *
  2113. * @see {@link LowerCasePipe}
  2114. * @see {@link UpperCasePipe}
  2115. *
  2116. * @usageNotes
  2117. * The following example shows the result of transforming various strings into title case.
  2118. *
  2119. * {@example common/pipes/ts/titlecase_pipe.ts region='TitleCasePipe'}
  2120. *
  2121. * @ngModule CommonModule
  2122. * @publicApi
  2123. */
  2124. declare class TitleCasePipe implements PipeTransform {
  2125. /**
  2126. * @param value The string to transform to title case.
  2127. */
  2128. transform(value: string): string;
  2129. transform(value: null | undefined): null;
  2130. transform(value: string | null | undefined): string | null;
  2131. static ɵfac: i0.ɵɵFactoryDeclaration<TitleCasePipe, never>;
  2132. static ɵpipe: i0.ɵɵPipeDeclaration<TitleCasePipe, "titlecase", true>;
  2133. }
  2134. /**
  2135. * Transforms text to all upper case.
  2136. * @see {@link LowerCasePipe}
  2137. * @see {@link TitleCasePipe}
  2138. *
  2139. * @ngModule CommonModule
  2140. * @publicApi
  2141. */
  2142. declare class UpperCasePipe implements PipeTransform {
  2143. /**
  2144. * @param value The string to transform to upper case.
  2145. */
  2146. transform(value: string): string;
  2147. transform(value: null | undefined): null;
  2148. transform(value: string | null | undefined): string | null;
  2149. static ɵfac: i0.ɵɵFactoryDeclaration<UpperCasePipe, never>;
  2150. static ɵpipe: i0.ɵɵPipeDeclaration<UpperCasePipe, "uppercase", true>;
  2151. }
  2152. /**
  2153. * @ngModule CommonModule
  2154. * @description
  2155. *
  2156. * Converts a value into its JSON-format representation. Useful for debugging.
  2157. *
  2158. * @usageNotes
  2159. *
  2160. * The following component uses a JSON pipe to convert an object
  2161. * to JSON format, and displays the string in both formats for comparison.
  2162. *
  2163. * {@example common/pipes/ts/json_pipe.ts region='JsonPipe'}
  2164. *
  2165. * @publicApi
  2166. */
  2167. declare class JsonPipe implements PipeTransform {
  2168. /**
  2169. * @param value A value of any type to convert into a JSON-format string.
  2170. */
  2171. transform(value: any): string;
  2172. static ɵfac: i0.ɵɵFactoryDeclaration<JsonPipe, never>;
  2173. static ɵpipe: i0.ɵɵPipeDeclaration<JsonPipe, "json", true>;
  2174. }
  2175. /**
  2176. * @ngModule CommonModule
  2177. * @description
  2178. *
  2179. * Creates a new `Array` or `String` containing a subset (slice) of the elements.
  2180. *
  2181. * @usageNotes
  2182. *
  2183. * All behavior is based on the expected behavior of the JavaScript API `Array.prototype.slice()`
  2184. * and `String.prototype.slice()`.
  2185. *
  2186. * When operating on an `Array`, the returned `Array` is always a copy even when all
  2187. * the elements are being returned.
  2188. *
  2189. * When operating on a blank value, the pipe returns the blank value.
  2190. *
  2191. * ### List Example
  2192. *
  2193. * This `ngFor` example:
  2194. *
  2195. * {@example common/pipes/ts/slice_pipe.ts region='SlicePipe_list'}
  2196. *
  2197. * produces the following:
  2198. *
  2199. * ```html
  2200. * <li>b</li>
  2201. * <li>c</li>
  2202. * ```
  2203. *
  2204. * ### String Examples
  2205. *
  2206. * {@example common/pipes/ts/slice_pipe.ts region='SlicePipe_string'}
  2207. *
  2208. * @publicApi
  2209. */
  2210. declare class SlicePipe implements PipeTransform {
  2211. /**
  2212. * @param value a list or a string to be sliced.
  2213. * @param start the starting index of the subset to return:
  2214. * - **a positive integer**: return the item at `start` index and all items after
  2215. * in the list or string expression.
  2216. * - **a negative integer**: return the item at `start` index from the end and all items after
  2217. * in the list or string expression.
  2218. * - **if positive and greater than the size of the expression**: return an empty list or
  2219. * string.
  2220. * - **if negative and greater than the size of the expression**: return entire list or string.
  2221. * @param end the ending index of the subset to return:
  2222. * - **omitted**: return all items until the end.
  2223. * - **if positive**: return all items before `end` index of the list or string.
  2224. * - **if negative**: return all items before `end` index from the end of the list or string.
  2225. */
  2226. transform<T>(value: ReadonlyArray<T>, start: number, end?: number): Array<T>;
  2227. transform(value: null | undefined, start: number, end?: number): null;
  2228. transform<T>(value: ReadonlyArray<T> | null | undefined, start: number, end?: number): Array<T> | null;
  2229. transform(value: string, start: number, end?: number): string;
  2230. transform(value: string | null | undefined, start: number, end?: number): string | null;
  2231. static ɵfac: i0.ɵɵFactoryDeclaration<SlicePipe, never>;
  2232. static ɵpipe: i0.ɵɵPipeDeclaration<SlicePipe, "slice", true>;
  2233. }
  2234. /**
  2235. * @ngModule CommonModule
  2236. * @description
  2237. *
  2238. * Formats a value according to digit options and locale rules.
  2239. * Locale determines group sizing and separator,
  2240. * decimal point character, and other locale-specific configurations.
  2241. *
  2242. * @see {@link formatNumber}
  2243. *
  2244. * @usageNotes
  2245. *
  2246. * ### digitsInfo
  2247. *
  2248. * The value's decimal representation is specified by the `digitsInfo`
  2249. * parameter, written in the following format:<br>
  2250. *
  2251. * ```
  2252. * {minIntegerDigits}.{minFractionDigits}-{maxFractionDigits}
  2253. * ```
  2254. *
  2255. * - `minIntegerDigits`:
  2256. * The minimum number of integer digits before the decimal point.
  2257. * Default is 1.
  2258. *
  2259. * - `minFractionDigits`:
  2260. * The minimum number of digits after the decimal point.
  2261. * Default is 0.
  2262. *
  2263. * - `maxFractionDigits`:
  2264. * The maximum number of digits after the decimal point.
  2265. * Default is 3.
  2266. *
  2267. * If the formatted value is truncated it will be rounded using the "to-nearest" method:
  2268. *
  2269. * ```
  2270. * {{3.6 | number: '1.0-0'}}
  2271. * <!--will output '4'-->
  2272. *
  2273. * {{-3.6 | number:'1.0-0'}}
  2274. * <!--will output '-4'-->
  2275. * ```
  2276. *
  2277. * ### locale
  2278. *
  2279. * `locale` will format a value according to locale rules.
  2280. * Locale determines group sizing and separator,
  2281. * decimal point character, and other locale-specific configurations.
  2282. *
  2283. * When not supplied, uses the value of `LOCALE_ID`, which is `en-US` by default.
  2284. *
  2285. * See [Setting your app locale](guide/i18n/locale-id).
  2286. *
  2287. * ### Example
  2288. *
  2289. * The following code shows how the pipe transforms values
  2290. * according to various format specifications,
  2291. * where the caller's default locale is `en-US`.
  2292. *
  2293. * {@example common/pipes/ts/number_pipe.ts region='NumberPipe'}
  2294. *
  2295. * @publicApi
  2296. */
  2297. declare class DecimalPipe implements PipeTransform {
  2298. private _locale;
  2299. constructor(_locale: string);
  2300. /**
  2301. * @param value The value to be formatted.
  2302. * @param digitsInfo Sets digit and decimal representation.
  2303. * [See more](#digitsinfo).
  2304. * @param locale Specifies what locale format rules to use.
  2305. * [See more](#locale).
  2306. */
  2307. transform(value: number | string, digitsInfo?: string, locale?: string): string | null;
  2308. transform(value: null | undefined, digitsInfo?: string, locale?: string): null;
  2309. transform(value: number | string | null | undefined, digitsInfo?: string, locale?: string): string | null;
  2310. static ɵfac: i0.ɵɵFactoryDeclaration<DecimalPipe, never>;
  2311. static ɵpipe: i0.ɵɵPipeDeclaration<DecimalPipe, "number", true>;
  2312. }
  2313. /**
  2314. * @ngModule CommonModule
  2315. * @description
  2316. *
  2317. * Transforms a number to a percentage
  2318. * string, formatted according to locale rules that determine group sizing and
  2319. * separator, decimal-point character, and other locale-specific
  2320. * configurations.
  2321. *
  2322. * @see {@link formatPercent}
  2323. *
  2324. * @usageNotes
  2325. * The following code shows how the pipe transforms numbers
  2326. * into text strings, according to various format specifications,
  2327. * where the caller's default locale is `en-US`.
  2328. *
  2329. * {@example common/pipes/ts/percent_pipe.ts region='PercentPipe'}
  2330. *
  2331. * @publicApi
  2332. */
  2333. declare class PercentPipe implements PipeTransform {
  2334. private _locale;
  2335. constructor(_locale: string);
  2336. transform(value: number | string, digitsInfo?: string, locale?: string): string | null;
  2337. transform(value: null | undefined, digitsInfo?: string, locale?: string): null;
  2338. transform(value: number | string | null | undefined, digitsInfo?: string, locale?: string): string | null;
  2339. static ɵfac: i0.ɵɵFactoryDeclaration<PercentPipe, never>;
  2340. static ɵpipe: i0.ɵɵPipeDeclaration<PercentPipe, "percent", true>;
  2341. }
  2342. /**
  2343. * @ngModule CommonModule
  2344. * @description
  2345. *
  2346. * Transforms a number to a currency string, formatted according to locale rules
  2347. * that determine group sizing and separator, decimal-point character,
  2348. * and other locale-specific configurations.
  2349. *
  2350. *
  2351. * @see {@link getCurrencySymbol}
  2352. * @see {@link formatCurrency}
  2353. *
  2354. * @usageNotes
  2355. * The following code shows how the pipe transforms numbers
  2356. * into text strings, according to various format specifications,
  2357. * where the caller's default locale is `en-US`.
  2358. *
  2359. * {@example common/pipes/ts/currency_pipe.ts region='CurrencyPipe'}
  2360. *
  2361. * @publicApi
  2362. */
  2363. declare class CurrencyPipe implements PipeTransform {
  2364. private _locale;
  2365. private _defaultCurrencyCode;
  2366. constructor(_locale: string, _defaultCurrencyCode?: string);
  2367. /**
  2368. *
  2369. * @param value The number to be formatted as currency.
  2370. * @param currencyCode The [ISO 4217](https://en.wikipedia.org/wiki/ISO_4217) currency code,
  2371. * such as `USD` for the US dollar and `EUR` for the euro. The default currency code can be
  2372. * configured using the `DEFAULT_CURRENCY_CODE` injection token.
  2373. * @param display The format for the currency indicator. One of the following:
  2374. * - `code`: Show the code (such as `USD`).
  2375. * - `symbol`(default): Show the symbol (such as `$`).
  2376. * - `symbol-narrow`: Use the narrow symbol for locales that have two symbols for their
  2377. * currency.
  2378. * For example, the Canadian dollar CAD has the symbol `CA$` and the symbol-narrow `$`. If the
  2379. * locale has no narrow symbol, uses the standard symbol for the locale.
  2380. * - String: Use the given string value instead of a code or a symbol.
  2381. * For example, an empty string will suppress the currency & symbol.
  2382. * - Boolean (marked deprecated in v5): `true` for symbol and false for `code`.
  2383. *
  2384. * @param digitsInfo Decimal representation options, specified by a string
  2385. * in the following format:<br>
  2386. * <code>{minIntegerDigits}.{minFractionDigits}-{maxFractionDigits}</code>.
  2387. * - `minIntegerDigits`: The minimum number of integer digits before the decimal point.
  2388. * Default is `1`.
  2389. * - `minFractionDigits`: The minimum number of digits after the decimal point.
  2390. * Default is `2`.
  2391. * - `maxFractionDigits`: The maximum number of digits after the decimal point.
  2392. * Default is `2`.
  2393. * If not provided, the number will be formatted with the proper amount of digits,
  2394. * depending on what the [ISO 4217](https://en.wikipedia.org/wiki/ISO_4217) specifies.
  2395. * For example, the Canadian dollar has 2 digits, whereas the Chilean peso has none.
  2396. * @param locale A locale code for the locale format rules to use.
  2397. * When not supplied, uses the value of `LOCALE_ID`, which is `en-US` by default.
  2398. * See [Setting your app locale](guide/i18n/locale-id).
  2399. */
  2400. transform(value: number | string, currencyCode?: string, display?: 'code' | 'symbol' | 'symbol-narrow' | string | boolean, digitsInfo?: string, locale?: string): string | null;
  2401. transform(value: null | undefined, currencyCode?: string, display?: 'code' | 'symbol' | 'symbol-narrow' | string | boolean, digitsInfo?: string, locale?: string): null;
  2402. transform(value: number | string | null | undefined, currencyCode?: string, display?: 'code' | 'symbol' | 'symbol-narrow' | string | boolean, digitsInfo?: string, locale?: string): string | null;
  2403. static ɵfac: i0.ɵɵFactoryDeclaration<CurrencyPipe, never>;
  2404. static ɵpipe: i0.ɵɵPipeDeclaration<CurrencyPipe, "currency", true>;
  2405. }
  2406. /**
  2407. * An interface that describes the date pipe configuration, which can be provided using the
  2408. * `DATE_PIPE_DEFAULT_OPTIONS` token.
  2409. *
  2410. * @see {@link DATE_PIPE_DEFAULT_OPTIONS}
  2411. *
  2412. * @publicApi
  2413. */
  2414. interface DatePipeConfig {
  2415. dateFormat?: string;
  2416. timezone?: string;
  2417. }
  2418. /**
  2419. * Optionally-provided default timezone to use for all instances of `DatePipe` (such as `'+0430'`).
  2420. * If the value isn't provided, the `DatePipe` will use the end-user's local system timezone.
  2421. *
  2422. * @deprecated use DATE_PIPE_DEFAULT_OPTIONS token to configure DatePipe
  2423. */
  2424. declare const DATE_PIPE_DEFAULT_TIMEZONE: InjectionToken<string>;
  2425. /**
  2426. * DI token that allows to provide default configuration for the `DatePipe` instances in an
  2427. * application. The value is an object which can include the following fields:
  2428. * - `dateFormat`: configures the default date format. If not provided, the `DatePipe`
  2429. * will use the 'mediumDate' as a value.
  2430. * - `timezone`: configures the default timezone. If not provided, the `DatePipe` will
  2431. * use the end-user's local system timezone.
  2432. *
  2433. * @see {@link DatePipeConfig}
  2434. *
  2435. * @usageNotes
  2436. *
  2437. * Various date pipe default values can be overwritten by providing this token with
  2438. * the value that has this interface.
  2439. *
  2440. * For example:
  2441. *
  2442. * Override the default date format by providing a value using the token:
  2443. * ```ts
  2444. * providers: [
  2445. * {provide: DATE_PIPE_DEFAULT_OPTIONS, useValue: {dateFormat: 'shortDate'}}
  2446. * ]
  2447. * ```
  2448. *
  2449. * Override the default timezone by providing a value using the token:
  2450. * ```ts
  2451. * providers: [
  2452. * {provide: DATE_PIPE_DEFAULT_OPTIONS, useValue: {timezone: '-1200'}}
  2453. * ]
  2454. * ```
  2455. */
  2456. declare const DATE_PIPE_DEFAULT_OPTIONS: InjectionToken<DatePipeConfig>;
  2457. /**
  2458. * @ngModule CommonModule
  2459. * @description
  2460. *
  2461. * Formats a date value according to locale rules.
  2462. *
  2463. * `DatePipe` is executed only when it detects a pure change to the input value.
  2464. * A pure change is either a change to a primitive input value
  2465. * (such as `String`, `Number`, `Boolean`, or `Symbol`),
  2466. * or a changed object reference (such as `Date`, `Array`, `Function`, or `Object`).
  2467. *
  2468. * Note that mutating a `Date` object does not cause the pipe to be rendered again.
  2469. * To ensure that the pipe is executed, you must create a new `Date` object.
  2470. *
  2471. * Only the `en-US` locale data comes with Angular. To localize dates
  2472. * in another language, you must import the corresponding locale data.
  2473. * See the [I18n guide](guide/i18n/format-data-locale) for more information.
  2474. *
  2475. * The time zone of the formatted value can be specified either by passing it in as the second
  2476. * parameter of the pipe, or by setting the default through the `DATE_PIPE_DEFAULT_OPTIONS`
  2477. * injection token. The value that is passed in as the second parameter takes precedence over
  2478. * the one defined using the injection token.
  2479. *
  2480. * @see {@link formatDate}
  2481. *
  2482. *
  2483. * @usageNotes
  2484. *
  2485. * The result of this pipe is not reevaluated when the input is mutated. To avoid the need to
  2486. * reformat the date on every change-detection cycle, treat the date as an immutable object
  2487. * and change the reference when the pipe needs to run again.
  2488. *
  2489. * ### Pre-defined format options
  2490. *
  2491. * | Option | Equivalent to | Examples (given in `en-US` locale) |
  2492. * |---------------|-------------------------------------|-------------------------------------------------|
  2493. * | `'short'` | `'M/d/yy, h:mm a'` | `6/15/15, 9:03 AM` |
  2494. * | `'medium'` | `'MMM d, y, h:mm:ss a'` | `Jun 15, 2015, 9:03:01 AM` |
  2495. * | `'long'` | `'MMMM d, y, h:mm:ss a z'` | `June 15, 2015 at 9:03:01 AM GMT+1` |
  2496. * | `'full'` | `'EEEE, MMMM d, y, h:mm:ss a zzzz'` | `Monday, June 15, 2015 at 9:03:01 AM GMT+01:00` |
  2497. * | `'shortDate'` | `'M/d/yy'` | `6/15/15` |
  2498. * | `'mediumDate'`| `'MMM d, y'` | `Jun 15, 2015` |
  2499. * | `'longDate'` | `'MMMM d, y'` | `June 15, 2015` |
  2500. * | `'fullDate'` | `'EEEE, MMMM d, y'` | `Monday, June 15, 2015` |
  2501. * | `'shortTime'` | `'h:mm a'` | `9:03 AM` |
  2502. * | `'mediumTime'`| `'h:mm:ss a'` | `9:03:01 AM` |
  2503. * | `'longTime'` | `'h:mm:ss a z'` | `9:03:01 AM GMT+1` |
  2504. * | `'fullTime'` | `'h:mm:ss a zzzz'` | `9:03:01 AM GMT+01:00` |
  2505. *
  2506. * ### Custom format options
  2507. *
  2508. * You can construct a format string using symbols to specify the components
  2509. * of a date-time value, as described in the following table.
  2510. * Format details depend on the locale.
  2511. * Fields marked with (*) are only available in the extra data set for the given locale.
  2512. *
  2513. * | Field type | Format | Description | Example Value |
  2514. * |-------------------------|-------------|---------------------------------------------------------------|------------------------------------------------------------|
  2515. * | Era | G, GG & GGG | Abbreviated | AD |
  2516. * | | GGGG | Wide | Anno Domini |
  2517. * | | GGGGG | Narrow | A |
  2518. * | Year | y | Numeric: minimum digits | 2, 20, 201, 2017, 20173 |
  2519. * | | yy | Numeric: 2 digits + zero padded | 02, 20, 01, 17, 73 |
  2520. * | | yyy | Numeric: 3 digits + zero padded | 002, 020, 201, 2017, 20173 |
  2521. * | | yyyy | Numeric: 4 digits or more + zero padded | 0002, 0020, 0201, 2017, 20173 |
  2522. * | ISO Week-numbering year | Y | Numeric: minimum digits | 2, 20, 201, 2017, 20173 |
  2523. * | | YY | Numeric: 2 digits + zero padded | 02, 20, 01, 17, 73 |
  2524. * | | YYY | Numeric: 3 digits + zero padded | 002, 020, 201, 2017, 20173 |
  2525. * | | YYYY | Numeric: 4 digits or more + zero padded | 0002, 0020, 0201, 2017, 20173 |
  2526. * | Month | M | Numeric: 1 digit | 9, 12 |
  2527. * | | MM | Numeric: 2 digits + zero padded | 09, 12 |
  2528. * | | MMM | Abbreviated | Sep |
  2529. * | | MMMM | Wide | September |
  2530. * | | MMMMM | Narrow | S |
  2531. * | Month standalone | L | Numeric: 1 digit | 9, 12 |
  2532. * | | LL | Numeric: 2 digits + zero padded | 09, 12 |
  2533. * | | LLL | Abbreviated | Sep |
  2534. * | | LLLL | Wide | September |
  2535. * | | LLLLL | Narrow | S |
  2536. * | ISO Week of year | w | Numeric: minimum digits | 1... 53 |
  2537. * | | ww | Numeric: 2 digits + zero padded | 01... 53 |
  2538. * | Week of month | W | Numeric: 1 digit | 1... 5 |
  2539. * | Day of month | d | Numeric: minimum digits | 1 |
  2540. * | | dd | Numeric: 2 digits + zero padded | 01 |
  2541. * | Week day | E, EE & EEE | Abbreviated | Tue |
  2542. * | | EEEE | Wide | Tuesday |
  2543. * | | EEEEE | Narrow | T |
  2544. * | | EEEEEE | Short | Tu |
  2545. * | Week day standalone | c, cc | Numeric: 1 digit | 2 |
  2546. * | | ccc | Abbreviated | Tue |
  2547. * | | cccc | Wide | Tuesday |
  2548. * | | ccccc | Narrow | T |
  2549. * | | cccccc | Short | Tu |
  2550. * | Period | a, aa & aaa | Abbreviated | am/pm or AM/PM |
  2551. * | | aaaa | Wide (fallback to `a` when missing) | ante meridiem/post meridiem |
  2552. * | | aaaaa | Narrow | a/p |
  2553. * | Period* | B, BB & BBB | Abbreviated | mid. |
  2554. * | | BBBB | Wide | am, pm, midnight, noon, morning, afternoon, evening, night |
  2555. * | | BBBBB | Narrow | md |
  2556. * | Period standalone* | b, bb & bbb | Abbreviated | mid. |
  2557. * | | bbbb | Wide | am, pm, midnight, noon, morning, afternoon, evening, night |
  2558. * | | bbbbb | Narrow | md |
  2559. * | Hour 1-12 | h | Numeric: minimum digits | 1, 12 |
  2560. * | | hh | Numeric: 2 digits + zero padded | 01, 12 |
  2561. * | Hour 0-23 | H | Numeric: minimum digits | 0, 23 |
  2562. * | | HH | Numeric: 2 digits + zero padded | 00, 23 |
  2563. * | Minute | m | Numeric: minimum digits | 8, 59 |
  2564. * | | mm | Numeric: 2 digits + zero padded | 08, 59 |
  2565. * | Second | s | Numeric: minimum digits | 0... 59 |
  2566. * | | ss | Numeric: 2 digits + zero padded | 00... 59 |
  2567. * | Fractional seconds | S | Numeric: 1 digit | 0... 9 |
  2568. * | | SS | Numeric: 2 digits + zero padded | 00... 99 |
  2569. * | | SSS | Numeric: 3 digits + zero padded (= milliseconds) | 000... 999 |
  2570. * | Zone | z, zz & zzz | Short specific non location format (fallback to O) | GMT-8 |
  2571. * | | zzzz | Long specific non location format (fallback to OOOO) | GMT-08:00 |
  2572. * | | Z, ZZ & ZZZ | ISO8601 basic format | -0800 |
  2573. * | | ZZZZ | Long localized GMT format | GMT-8:00 |
  2574. * | | ZZZZZ | ISO8601 extended format + Z indicator for offset 0 (= XXXXX) | -08:00 |
  2575. * | | O, OO & OOO | Short localized GMT format | GMT-8 |
  2576. * | | OOOO | Long localized GMT format | GMT-08:00 |
  2577. *
  2578. *
  2579. * ### Format examples
  2580. *
  2581. * These examples transform a date into various formats,
  2582. * assuming that `dateObj` is a JavaScript `Date` object for
  2583. * year: 2015, month: 6, day: 15, hour: 21, minute: 43, second: 11,
  2584. * given in the local time for the `en-US` locale.
  2585. *
  2586. * ```
  2587. * {{ dateObj | date }} // output is 'Jun 15, 2015'
  2588. * {{ dateObj | date:'medium' }} // output is 'Jun 15, 2015, 9:43:11 PM'
  2589. * {{ dateObj | date:'shortTime' }} // output is '9:43 PM'
  2590. * {{ dateObj | date:'mm:ss' }} // output is '43:11'
  2591. * {{ dateObj | date:"MMM dd, yyyy 'at' hh:mm a" }} // output is 'Jun 15, 2015 at 09:43 PM'
  2592. * ```
  2593. *
  2594. * ### Usage example
  2595. *
  2596. * The following component uses a date pipe to display the current date in different formats.
  2597. *
  2598. * ```angular-ts
  2599. * @Component({
  2600. * selector: 'date-pipe',
  2601. * template: `<div>
  2602. * <p>Today is {{today | date}}</p>
  2603. * <p>Or if you prefer, {{today | date:'fullDate'}}</p>
  2604. * <p>The time is {{today | date:'h:mm a z'}}</p>
  2605. * </div>`
  2606. * })
  2607. * // Get the current date and time as a date-time value.
  2608. * export class DatePipeComponent {
  2609. * today: number = Date.now();
  2610. * }
  2611. * ```
  2612. *
  2613. * @publicApi
  2614. */
  2615. declare class DatePipe implements PipeTransform {
  2616. private locale;
  2617. private defaultTimezone?;
  2618. private defaultOptions?;
  2619. constructor(locale: string, defaultTimezone?: string | null | undefined, defaultOptions?: (DatePipeConfig | null) | undefined);
  2620. /**
  2621. * @param value The date expression: a `Date` object, a number
  2622. * (milliseconds since UTC epoch), or an ISO string (https://www.w3.org/TR/NOTE-datetime).
  2623. * @param format The date/time components to include, using predefined options or a
  2624. * custom format string. When not provided, the `DatePipe` looks for the value using the
  2625. * `DATE_PIPE_DEFAULT_OPTIONS` injection token (and reads the `dateFormat` property).
  2626. * If the token is not configured, the `mediumDate` is used as a value.
  2627. * @param timezone A timezone offset (such as `'+0430'`). When not provided, the `DatePipe`
  2628. * looks for the value using the `DATE_PIPE_DEFAULT_OPTIONS` injection token (and reads
  2629. * the `timezone` property). If the token is not configured, the end-user's local system
  2630. * timezone is used as a value.
  2631. * @param locale A locale code for the locale format rules to use.
  2632. * When not supplied, uses the value of `LOCALE_ID`, which is `en-US` by default.
  2633. * See [Setting your app locale](guide/i18n/locale-id).
  2634. *
  2635. * @see {@link DATE_PIPE_DEFAULT_OPTIONS}
  2636. *
  2637. * @returns A date string in the desired format.
  2638. */
  2639. transform(value: Date | string | number, format?: string, timezone?: string, locale?: string): string | null;
  2640. transform(value: null | undefined, format?: string, timezone?: string, locale?: string): null;
  2641. transform(value: Date | string | number | null | undefined, format?: string, timezone?: string, locale?: string): string | null;
  2642. static ɵfac: i0.ɵɵFactoryDeclaration<DatePipe, [null, { optional: true; }, { optional: true; }]>;
  2643. static ɵpipe: i0.ɵɵPipeDeclaration<DatePipe, "date", true>;
  2644. }
  2645. /**
  2646. * @ngModule CommonModule
  2647. * @description
  2648. *
  2649. * Maps a value to a string that pluralizes the value according to locale rules.
  2650. *
  2651. * @usageNotes
  2652. *
  2653. * ### Example
  2654. *
  2655. * {@example common/pipes/ts/i18n_pipe.ts region='I18nPluralPipeComponent'}
  2656. *
  2657. * @publicApi
  2658. */
  2659. declare class I18nPluralPipe implements PipeTransform {
  2660. private _localization;
  2661. constructor(_localization: NgLocalization);
  2662. /**
  2663. * @param value the number to be formatted
  2664. * @param pluralMap an object that mimics the ICU format, see
  2665. * https://unicode-org.github.io/icu/userguide/format_parse/messages/.
  2666. * @param locale a `string` defining the locale to use (uses the current {@link LOCALE_ID} by
  2667. * default).
  2668. */
  2669. transform(value: number | null | undefined, pluralMap: {
  2670. [count: string]: string;
  2671. }, locale?: string): string;
  2672. static ɵfac: i0.ɵɵFactoryDeclaration<I18nPluralPipe, never>;
  2673. static ɵpipe: i0.ɵɵPipeDeclaration<I18nPluralPipe, "i18nPlural", true>;
  2674. }
  2675. /**
  2676. * @ngModule CommonModule
  2677. * @description
  2678. *
  2679. * Generic selector that displays the string that matches the current value.
  2680. *
  2681. * If none of the keys of the `mapping` match the `value`, then the content
  2682. * of the `other` key is returned when present, otherwise an empty string is returned.
  2683. *
  2684. * @usageNotes
  2685. *
  2686. * ### Example
  2687. *
  2688. * {@example common/pipes/ts/i18n_pipe.ts region='I18nSelectPipeComponent'}
  2689. *
  2690. * @publicApi
  2691. */
  2692. declare class I18nSelectPipe implements PipeTransform {
  2693. /**
  2694. * @param value a string to be internationalized.
  2695. * @param mapping an object that indicates the text that should be displayed
  2696. * for different values of the provided `value`.
  2697. */
  2698. transform(value: string | null | undefined, mapping: {
  2699. [key: string]: string;
  2700. }): string;
  2701. static ɵfac: i0.ɵɵFactoryDeclaration<I18nSelectPipe, never>;
  2702. static ɵpipe: i0.ɵɵPipeDeclaration<I18nSelectPipe, "i18nSelect", true>;
  2703. }
  2704. /**
  2705. * A key value pair.
  2706. * Usually used to represent the key value pairs from a Map or Object.
  2707. *
  2708. * @publicApi
  2709. */
  2710. interface KeyValue<K, V> {
  2711. key: K;
  2712. value: V;
  2713. }
  2714. /**
  2715. * @ngModule CommonModule
  2716. * @description
  2717. *
  2718. * Transforms Object or Map into an array of key value pairs.
  2719. *
  2720. * The output array will be ordered by keys.
  2721. * By default the comparator will be by Unicode point value.
  2722. * You can optionally pass a compareFn if your keys are complex types.
  2723. * Passing `null` as the compareFn will use natural ordering of the input.
  2724. *
  2725. * @usageNotes
  2726. * ### Examples
  2727. *
  2728. * This examples show how an Object or a Map can be iterated by ngFor with the use of this
  2729. * keyvalue pipe.
  2730. *
  2731. * {@example common/pipes/ts/keyvalue_pipe.ts region='KeyValuePipe'}
  2732. *
  2733. * @publicApi
  2734. */
  2735. declare class KeyValuePipe implements PipeTransform {
  2736. private readonly differs;
  2737. constructor(differs: KeyValueDiffers);
  2738. private differ;
  2739. private keyValues;
  2740. private compareFn;
  2741. transform<K, V>(input: ReadonlyMap<K, V>, compareFn?: ((a: KeyValue<K, V>, b: KeyValue<K, V>) => number) | null): Array<KeyValue<K, V>>;
  2742. transform<K extends number, V>(input: Record<K, V>, compareFn?: ((a: KeyValue<string, V>, b: KeyValue<string, V>) => number) | null): Array<KeyValue<string, V>>;
  2743. transform<K extends string, V>(input: Record<K, V> | ReadonlyMap<K, V>, compareFn?: ((a: KeyValue<K, V>, b: KeyValue<K, V>) => number) | null): Array<KeyValue<K, V>>;
  2744. transform(input: null | undefined, compareFn?: ((a: KeyValue<unknown, unknown>, b: KeyValue<unknown, unknown>) => number) | null): null;
  2745. transform<K, V>(input: ReadonlyMap<K, V> | null | undefined, compareFn?: ((a: KeyValue<K, V>, b: KeyValue<K, V>) => number) | null): Array<KeyValue<K, V>> | null;
  2746. transform<K extends number, V>(input: Record<K, V> | null | undefined, compareFn?: ((a: KeyValue<string, V>, b: KeyValue<string, V>) => number) | null): Array<KeyValue<string, V>> | null;
  2747. transform<K extends string, V>(input: Record<K, V> | ReadonlyMap<K, V> | null | undefined, compareFn?: ((a: KeyValue<K, V>, b: KeyValue<K, V>) => number) | null): Array<KeyValue<K, V>> | null;
  2748. static ɵfac: i0.ɵɵFactoryDeclaration<KeyValuePipe, never>;
  2749. static ɵpipe: i0.ɵɵPipeDeclaration<KeyValuePipe, "keyvalue", true>;
  2750. }
  2751. /**
  2752. * Exports all the basic Angular directives and pipes,
  2753. * such as `NgIf`, `NgForOf`, `DecimalPipe`, and so on.
  2754. * Re-exported by `BrowserModule`, which is included automatically in the root
  2755. * `AppModule` when you create a new app with the CLI `new` command.
  2756. *
  2757. * @publicApi
  2758. */
  2759. declare class CommonModule {
  2760. static ɵfac: i0.ɵɵFactoryDeclaration<CommonModule, never>;
  2761. static ɵmod: i0.ɵɵNgModuleDeclaration<CommonModule, never, [typeof NgClass, typeof NgComponentOutlet, typeof NgForOf, typeof NgIf, typeof NgTemplateOutlet, typeof NgStyle, typeof NgSwitch, typeof NgSwitchCase, typeof NgSwitchDefault, typeof NgPlural, typeof NgPluralCase, typeof AsyncPipe, typeof UpperCasePipe, typeof LowerCasePipe, typeof JsonPipe, typeof SlicePipe, typeof DecimalPipe, typeof PercentPipe, typeof TitleCasePipe, typeof CurrencyPipe, typeof DatePipe, typeof I18nPluralPipe, typeof I18nSelectPipe, typeof KeyValuePipe], [typeof NgClass, typeof NgComponentOutlet, typeof NgForOf, typeof NgIf, typeof NgTemplateOutlet, typeof NgStyle, typeof NgSwitch, typeof NgSwitchCase, typeof NgSwitchDefault, typeof NgPlural, typeof NgPluralCase, typeof AsyncPipe, typeof UpperCasePipe, typeof LowerCasePipe, typeof JsonPipe, typeof SlicePipe, typeof DecimalPipe, typeof PercentPipe, typeof TitleCasePipe, typeof CurrencyPipe, typeof DatePipe, typeof I18nPluralPipe, typeof I18nSelectPipe, typeof KeyValuePipe]>;
  2762. static ɵinj: i0.ɵɵInjectorDeclaration<CommonModule>;
  2763. }
  2764. /**
  2765. * A DI Token representing the main rendering context.
  2766. * In a browser and SSR this is the DOM Document.
  2767. * When using SSR, that document is created by [Domino](https://github.com/angular/domino).
  2768. *
  2769. * @publicApi
  2770. */
  2771. declare const DOCUMENT: InjectionToken<Document>;
  2772. declare const PLATFORM_BROWSER_ID = "browser";
  2773. declare const PLATFORM_SERVER_ID = "server";
  2774. /**
  2775. * Returns whether a platform id represents a browser platform.
  2776. * @publicApi
  2777. */
  2778. declare function isPlatformBrowser(platformId: Object): boolean;
  2779. /**
  2780. * Returns whether a platform id represents a server platform.
  2781. * @publicApi
  2782. */
  2783. declare function isPlatformServer(platformId: Object): boolean;
  2784. /**
  2785. * @module
  2786. * @description
  2787. * Entry point for all public APIs of the common package.
  2788. */
  2789. /**
  2790. * @publicApi
  2791. */
  2792. declare const VERSION: Version;
  2793. /**
  2794. * Defines a scroll position manager. Implemented by `BrowserViewportScroller`.
  2795. *
  2796. * @publicApi
  2797. */
  2798. declare abstract class ViewportScroller {
  2799. /** @nocollapse */
  2800. static ɵprov: unknown;
  2801. /**
  2802. * Configures the top offset used when scrolling to an anchor.
  2803. * @param offset A position in screen coordinates (a tuple with x and y values)
  2804. * or a function that returns the top offset position.
  2805. *
  2806. */
  2807. abstract setOffset(offset: [number, number] | (() => [number, number])): void;
  2808. /**
  2809. * Retrieves the current scroll position.
  2810. * @returns A position in screen coordinates (a tuple with x and y values).
  2811. */
  2812. abstract getScrollPosition(): [number, number];
  2813. /**
  2814. * Scrolls to a specified position.
  2815. * @param position A position in screen coordinates (a tuple with x and y values).
  2816. */
  2817. abstract scrollToPosition(position: [number, number]): void;
  2818. /**
  2819. * Scrolls to an anchor element.
  2820. * @param anchor The ID of the anchor element.
  2821. */
  2822. abstract scrollToAnchor(anchor: string): void;
  2823. /**
  2824. * Disables automatic scroll restoration provided by the browser.
  2825. * See also [window.history.scrollRestoration
  2826. * info](https://developers.google.com/web/updates/2015/09/history-api-scroll-restoration).
  2827. */
  2828. abstract setHistoryScrollRestoration(scrollRestoration: 'auto' | 'manual'): void;
  2829. }
  2830. /**
  2831. * Provides an empty implementation of the viewport scroller.
  2832. */
  2833. declare class NullViewportScroller implements ViewportScroller {
  2834. /**
  2835. * Empty implementation
  2836. */
  2837. setOffset(offset: [number, number] | (() => [number, number])): void;
  2838. /**
  2839. * Empty implementation
  2840. */
  2841. getScrollPosition(): [number, number];
  2842. /**
  2843. * Empty implementation
  2844. */
  2845. scrollToPosition(position: [number, number]): void;
  2846. /**
  2847. * Empty implementation
  2848. */
  2849. scrollToAnchor(anchor: string): void;
  2850. /**
  2851. * Empty implementation
  2852. */
  2853. setHistoryScrollRestoration(scrollRestoration: 'auto' | 'manual'): void;
  2854. }
  2855. /**
  2856. * A wrapper around the `XMLHttpRequest` constructor.
  2857. *
  2858. * @publicApi
  2859. */
  2860. declare abstract class XhrFactory {
  2861. abstract build(): XMLHttpRequest;
  2862. }
  2863. /**
  2864. * Function that generates an ImageLoader for [Cloudflare Image
  2865. * Resizing](https://developers.cloudflare.com/images/image-resizing/) and turns it into an Angular
  2866. * provider. Note: Cloudflare has multiple image products - this provider is specifically for
  2867. * Cloudflare Image Resizing; it will not work with Cloudflare Images or Cloudflare Polish.
  2868. *
  2869. * @param path Your domain name, e.g. https://mysite.com
  2870. * @returns Provider that provides an ImageLoader function
  2871. *
  2872. * @publicApi
  2873. */
  2874. declare const provideCloudflareLoader: (path: string) => i0.Provider[];
  2875. /**
  2876. * Config options recognized by the image loader function.
  2877. *
  2878. * @see {@link ImageLoader}
  2879. * @see {@link NgOptimizedImage}
  2880. * @publicApi
  2881. */
  2882. interface ImageLoaderConfig {
  2883. /**
  2884. * Image file name to be added to the image request URL.
  2885. */
  2886. src: string;
  2887. /**
  2888. * Width of the requested image (to be used when generating srcset).
  2889. */
  2890. width?: number;
  2891. /**
  2892. * Whether the loader should generate a URL for a small image placeholder instead of a full-sized
  2893. * image.
  2894. */
  2895. isPlaceholder?: boolean;
  2896. /**
  2897. * Additional user-provided parameters for use by the ImageLoader.
  2898. */
  2899. loaderParams?: {
  2900. [key: string]: any;
  2901. };
  2902. }
  2903. /**
  2904. * Represents an image loader function. Image loader functions are used by the
  2905. * NgOptimizedImage directive to produce full image URL based on the image name and its width.
  2906. *
  2907. * @publicApi
  2908. */
  2909. type ImageLoader = (config: ImageLoaderConfig) => string;
  2910. /**
  2911. * Injection token that configures the image loader function.
  2912. *
  2913. * @see {@link ImageLoader}
  2914. * @see {@link NgOptimizedImage}
  2915. * @publicApi
  2916. */
  2917. declare const IMAGE_LOADER: InjectionToken<ImageLoader>;
  2918. /**
  2919. * Function that generates an ImageLoader for Cloudinary and turns it into an Angular provider.
  2920. *
  2921. * @param path Base URL of your Cloudinary images
  2922. * This URL should match one of the following formats:
  2923. * https://res.cloudinary.com/mysite
  2924. * https://mysite.cloudinary.com
  2925. * https://subdomain.mysite.com
  2926. * @returns Set of providers to configure the Cloudinary loader.
  2927. *
  2928. * @publicApi
  2929. */
  2930. declare const provideCloudinaryLoader: (path: string) => i0.Provider[];
  2931. /**
  2932. * Function that generates an ImageLoader for ImageKit and turns it into an Angular provider.
  2933. *
  2934. * @param path Base URL of your ImageKit images
  2935. * This URL should match one of the following formats:
  2936. * https://ik.imagekit.io/myaccount
  2937. * https://subdomain.mysite.com
  2938. * @returns Set of providers to configure the ImageKit loader.
  2939. *
  2940. * @publicApi
  2941. */
  2942. declare const provideImageKitLoader: (path: string) => i0.Provider[];
  2943. /**
  2944. * Function that generates an ImageLoader for Imgix and turns it into an Angular provider.
  2945. *
  2946. * @param path path to the desired Imgix origin,
  2947. * e.g. https://somepath.imgix.net or https://images.mysite.com
  2948. * @returns Set of providers to configure the Imgix loader.
  2949. *
  2950. * @publicApi
  2951. */
  2952. declare const provideImgixLoader: (path: string) => i0.Provider[];
  2953. /**
  2954. * Function that generates an ImageLoader for Netlify and turns it into an Angular provider.
  2955. *
  2956. * @param path optional URL of the desired Netlify site. Defaults to the current site.
  2957. * @returns Set of providers to configure the Netlify loader.
  2958. *
  2959. * @publicApi
  2960. */
  2961. declare function provideNetlifyLoader(path?: string): Provider[];
  2962. /**
  2963. * Config options used in rendering placeholder images.
  2964. *
  2965. * @see {@link NgOptimizedImage}
  2966. * @publicApi
  2967. */
  2968. interface ImagePlaceholderConfig {
  2969. blur?: boolean;
  2970. }
  2971. /**
  2972. * Directive that improves image loading performance by enforcing best practices.
  2973. *
  2974. * `NgOptimizedImage` ensures that the loading of the Largest Contentful Paint (LCP) image is
  2975. * prioritized by:
  2976. * - Automatically setting the `fetchpriority` attribute on the `<img>` tag
  2977. * - Lazy loading non-priority images by default
  2978. * - Automatically generating a preconnect link tag in the document head
  2979. *
  2980. * In addition, the directive:
  2981. * - Generates appropriate asset URLs if a corresponding `ImageLoader` function is provided
  2982. * - Automatically generates a srcset
  2983. * - Requires that `width` and `height` are set
  2984. * - Warns if `width` or `height` have been set incorrectly
  2985. * - Warns if the image will be visually distorted when rendered
  2986. *
  2987. * @usageNotes
  2988. * The `NgOptimizedImage` directive is marked as [standalone](guide/components/importing) and can
  2989. * be imported directly.
  2990. *
  2991. * Follow the steps below to enable and use the directive:
  2992. * 1. Import it into the necessary NgModule or a standalone Component.
  2993. * 2. Optionally provide an `ImageLoader` if you use an image hosting service.
  2994. * 3. Update the necessary `<img>` tags in templates and replace `src` attributes with `ngSrc`.
  2995. * Using a `ngSrc` allows the directive to control when the `src` gets set, which triggers an image
  2996. * download.
  2997. *
  2998. * Step 1: import the `NgOptimizedImage` directive.
  2999. *
  3000. * ```ts
  3001. * import { NgOptimizedImage } from '@angular/common';
  3002. *
  3003. * // Include it into the necessary NgModule
  3004. * @NgModule({
  3005. * imports: [NgOptimizedImage],
  3006. * })
  3007. * class AppModule {}
  3008. *
  3009. * // ... or a standalone Component
  3010. * @Component({
  3011. * imports: [NgOptimizedImage],
  3012. * })
  3013. * class MyStandaloneComponent {}
  3014. * ```
  3015. *
  3016. * Step 2: configure a loader.
  3017. *
  3018. * To use the **default loader**: no additional code changes are necessary. The URL returned by the
  3019. * generic loader will always match the value of "src". In other words, this loader applies no
  3020. * transformations to the resource URL and the value of the `ngSrc` attribute will be used as is.
  3021. *
  3022. * To use an existing loader for a **third-party image service**: add the provider factory for your
  3023. * chosen service to the `providers` array. In the example below, the Imgix loader is used:
  3024. *
  3025. * ```ts
  3026. * import {provideImgixLoader} from '@angular/common';
  3027. *
  3028. * // Call the function and add the result to the `providers` array:
  3029. * providers: [
  3030. * provideImgixLoader("https://my.base.url/"),
  3031. * ],
  3032. * ```
  3033. *
  3034. * The `NgOptimizedImage` directive provides the following functions:
  3035. * - `provideCloudflareLoader`
  3036. * - `provideCloudinaryLoader`
  3037. * - `provideImageKitLoader`
  3038. * - `provideImgixLoader`
  3039. *
  3040. * If you use a different image provider, you can create a custom loader function as described
  3041. * below.
  3042. *
  3043. * To use a **custom loader**: provide your loader function as a value for the `IMAGE_LOADER` DI
  3044. * token.
  3045. *
  3046. * ```ts
  3047. * import {IMAGE_LOADER, ImageLoaderConfig} from '@angular/common';
  3048. *
  3049. * // Configure the loader using the `IMAGE_LOADER` token.
  3050. * providers: [
  3051. * {
  3052. * provide: IMAGE_LOADER,
  3053. * useValue: (config: ImageLoaderConfig) => {
  3054. * return `https://example.com/${config.src}-${config.width}.jpg`;
  3055. * }
  3056. * },
  3057. * ],
  3058. * ```
  3059. *
  3060. * Step 3: update `<img>` tags in templates to use `ngSrc` instead of `src`.
  3061. *
  3062. * ```html
  3063. * <img ngSrc="logo.png" width="200" height="100">
  3064. * ```
  3065. *
  3066. * @publicApi
  3067. */
  3068. declare class NgOptimizedImage implements OnInit, OnChanges {
  3069. private imageLoader;
  3070. private config;
  3071. private renderer;
  3072. private imgElement;
  3073. private injector;
  3074. private lcpObserver?;
  3075. /**
  3076. * Calculate the rewritten `src` once and store it.
  3077. * This is needed to avoid repetitive calculations and make sure the directive cleanup in the
  3078. * `ngOnDestroy` does not rely on the `IMAGE_LOADER` logic (which in turn can rely on some other
  3079. * instance that might be already destroyed).
  3080. */
  3081. private _renderedSrc;
  3082. /**
  3083. * Name of the source image.
  3084. * Image name will be processed by the image loader and the final URL will be applied as the `src`
  3085. * property of the image.
  3086. */
  3087. ngSrc: string;
  3088. /**
  3089. * A comma separated list of width or density descriptors.
  3090. * The image name will be taken from `ngSrc` and combined with the list of width or density
  3091. * descriptors to generate the final `srcset` property of the image.
  3092. *
  3093. * Example:
  3094. * ```html
  3095. * <img ngSrc="hello.jpg" ngSrcset="100w, 200w" /> =>
  3096. * <img src="path/hello.jpg" srcset="path/hello.jpg?w=100 100w, path/hello.jpg?w=200 200w" />
  3097. * ```
  3098. */
  3099. ngSrcset: string;
  3100. /**
  3101. * The base `sizes` attribute passed through to the `<img>` element.
  3102. * Providing sizes causes the image to create an automatic responsive srcset.
  3103. */
  3104. sizes?: string;
  3105. /**
  3106. * For responsive images: the intrinsic width of the image in pixels.
  3107. * For fixed size images: the desired rendered width of the image in pixels.
  3108. */
  3109. width: number | undefined;
  3110. /**
  3111. * For responsive images: the intrinsic height of the image in pixels.
  3112. * For fixed size images: the desired rendered height of the image in pixels.
  3113. */
  3114. height: number | undefined;
  3115. /**
  3116. * The desired loading behavior (lazy, eager, or auto). Defaults to `lazy`,
  3117. * which is recommended for most images.
  3118. *
  3119. * Warning: Setting images as loading="eager" or loading="auto" marks them
  3120. * as non-priority images and can hurt loading performance. For images which
  3121. * may be the LCP element, use the `priority` attribute instead of `loading`.
  3122. */
  3123. loading?: 'lazy' | 'eager' | 'auto';
  3124. /**
  3125. * Indicates whether this image should have a high priority.
  3126. */
  3127. priority: boolean;
  3128. /**
  3129. * Data to pass through to custom loaders.
  3130. */
  3131. loaderParams?: {
  3132. [key: string]: any;
  3133. };
  3134. /**
  3135. * Disables automatic srcset generation for this image.
  3136. */
  3137. disableOptimizedSrcset: boolean;
  3138. /**
  3139. * Sets the image to "fill mode", which eliminates the height/width requirement and adds
  3140. * styles such that the image fills its containing element.
  3141. */
  3142. fill: boolean;
  3143. /**
  3144. * A URL or data URL for an image to be used as a placeholder while this image loads.
  3145. */
  3146. placeholder?: string | boolean;
  3147. /**
  3148. * Configuration object for placeholder settings. Options:
  3149. * * blur: Setting this to false disables the automatic CSS blur.
  3150. */
  3151. placeholderConfig?: ImagePlaceholderConfig;
  3152. constructor();
  3153. /** @nodoc */
  3154. ngOnInit(): void;
  3155. private setHostAttributes;
  3156. /** @nodoc */
  3157. ngOnChanges(changes: SimpleChanges): void;
  3158. private callImageLoader;
  3159. private getLoadingBehavior;
  3160. private getFetchPriority;
  3161. private getRewrittenSrc;
  3162. private getRewrittenSrcset;
  3163. private getAutomaticSrcset;
  3164. private getResponsiveSrcset;
  3165. private updateSrcAndSrcset;
  3166. private getFixedSrcset;
  3167. private shouldGenerateAutomaticSrcset;
  3168. /**
  3169. * Returns an image url formatted for use with the CSS background-image property. Expects one of:
  3170. * * A base64 encoded image, which is wrapped and passed through.
  3171. * * A boolean. If true, calls the image loader to generate a small placeholder url.
  3172. */
  3173. private generatePlaceholder;
  3174. /**
  3175. * Determines if blur should be applied, based on an optional boolean
  3176. * property `blur` within the optional configuration object `placeholderConfig`.
  3177. */
  3178. private shouldBlurPlaceholder;
  3179. private removePlaceholderOnLoad;
  3180. private setHostAttribute;
  3181. static ɵfac: i0.ɵɵFactoryDeclaration<NgOptimizedImage, never>;
  3182. static ɵdir: i0.ɵɵDirectiveDeclaration<NgOptimizedImage, "img[ngSrc]", never, { "ngSrc": { "alias": "ngSrc"; "required": true; }; "ngSrcset": { "alias": "ngSrcset"; "required": false; }; "sizes": { "alias": "sizes"; "required": false; }; "width": { "alias": "width"; "required": false; }; "height": { "alias": "height"; "required": false; }; "loading": { "alias": "loading"; "required": false; }; "priority": { "alias": "priority"; "required": false; }; "loaderParams": { "alias": "loaderParams"; "required": false; }; "disableOptimizedSrcset": { "alias": "disableOptimizedSrcset"; "required": false; }; "fill": { "alias": "fill"; "required": false; }; "placeholder": { "alias": "placeholder"; "required": false; }; "placeholderConfig": { "alias": "placeholderConfig"; "required": false; }; "src": { "alias": "src"; "required": false; }; "srcset": { "alias": "srcset"; "required": false; }; }, {}, never, never, true, never>;
  3183. static ngAcceptInputType_ngSrc: string | i0.ɵSafeValue;
  3184. static ngAcceptInputType_width: unknown;
  3185. static ngAcceptInputType_height: unknown;
  3186. static ngAcceptInputType_priority: unknown;
  3187. static ngAcceptInputType_disableOptimizedSrcset: unknown;
  3188. static ngAcceptInputType_fill: unknown;
  3189. static ngAcceptInputType_placeholder: boolean | string;
  3190. }
  3191. /**
  3192. * Injection token to configure which origins should be excluded
  3193. * from the preconnect checks. It can either be a single string or an array of strings
  3194. * to represent a group of origins, for example:
  3195. *
  3196. * ```ts
  3197. * {provide: PRECONNECT_CHECK_BLOCKLIST, useValue: 'https://your-domain.com'}
  3198. * ```
  3199. *
  3200. * or:
  3201. *
  3202. * ```ts
  3203. * {provide: PRECONNECT_CHECK_BLOCKLIST,
  3204. * useValue: ['https://your-domain-1.com', 'https://your-domain-2.com']}
  3205. * ```
  3206. *
  3207. * @publicApi
  3208. */
  3209. declare const PRECONNECT_CHECK_BLOCKLIST: InjectionToken<(string | string[])[]>;
  3210. /**
  3211. * Normalizes URL parameters by prepending with `?` if needed.
  3212. *
  3213. * @param params String of URL parameters.
  3214. *
  3215. * @returns The normalized URL parameters string.
  3216. */
  3217. declare function normalizeQueryParams(params: string): string;
  3218. export { APP_BASE_HREF, AsyncPipe, BrowserPlatformLocation, CommonModule, CurrencyPipe, DATE_PIPE_DEFAULT_OPTIONS, DATE_PIPE_DEFAULT_TIMEZONE, DOCUMENT, DatePipe, type DatePipeConfig, DecimalPipe, FormStyle, FormatWidth, HashLocationStrategy, I18nPluralPipe, I18nSelectPipe, IMAGE_LOADER, type ImageLoader, type ImageLoaderConfig, type ImagePlaceholderConfig, JsonPipe, type KeyValue, KeyValuePipe, LOCATION_INITIALIZED, Location, type LocationChangeEvent, type LocationChangeListener, LocationStrategy, LowerCasePipe, NgClass, NgComponentOutlet, NgForOf as NgFor, NgForOf, NgForOfContext, NgIf, NgIfContext, NgLocaleLocalization, NgLocalization, NgOptimizedImage, NgPlural, NgPluralCase, NgStyle, NgSwitch, NgSwitchCase, NgSwitchDefault, NgTemplateOutlet, NumberFormatStyle, NumberSymbol, PRECONNECT_CHECK_BLOCKLIST, PathLocationStrategy, PercentPipe, PlatformLocation, Plural, type PopStateEvent, SlicePipe, type Time, TitleCasePipe, TranslationWidth, UpperCasePipe, VERSION, ViewportScroller, WeekDay, XhrFactory, formatCurrency, formatDate, formatNumber, formatPercent, getCurrencySymbol, getLocaleCurrencyCode, getLocaleCurrencyName, getLocaleCurrencySymbol, getLocaleDateFormat, getLocaleDateTimeFormat, getLocaleDayNames, getLocaleDayPeriods, getLocaleDirection, getLocaleEraNames, getLocaleExtraDayPeriodRules, getLocaleExtraDayPeriods, getLocaleFirstDayOfWeek, getLocaleId, getLocaleMonthNames, getLocaleNumberFormat, getLocaleNumberSymbol, getLocalePluralCase, getLocaleTimeFormat, getLocaleWeekEndRange, getNumberOfCurrencyDigits, isPlatformBrowser, isPlatformServer, provideCloudflareLoader, provideCloudinaryLoader, provideImageKitLoader, provideImgixLoader, provideNetlifyLoader, registerLocaleData, DomAdapter as ɵDomAdapter, NullViewportScroller as ɵNullViewportScroller, PLATFORM_BROWSER_ID as ɵPLATFORM_BROWSER_ID, PLATFORM_SERVER_ID as ɵPLATFORM_SERVER_ID, PlatformNavigation as ɵPlatformNavigation, getDOM as ɵgetDOM, normalizeQueryParams as ɵnormalizeQueryParams, parseCookieValue as ɵparseCookieValue, setRootDomAdapter as ɵsetRootDomAdapter };