@ngbracket/ngx-layout
Version:
ngbracket/ngx-layout =======
114 lines (109 loc) • 4.95 kB
TypeScript
import * as i0 from '@angular/core';
import { NgZone, Optional } from '@angular/core';
import { ɵMatchMedia as _MatchMedia, BreakPoint, LayoutConfigOptions, StylesheetMap, MediaMarshaller } from '@ngbracket/ngx-layout/core';
declare class FlexLayoutServerModule {
static ɵfac: i0.ɵɵFactoryDeclaration<FlexLayoutServerModule, never>;
static ɵmod: i0.ɵɵNgModuleDeclaration<FlexLayoutServerModule, never, never, never>;
static ɵinj: i0.ɵɵInjectorDeclaration<FlexLayoutServerModule>;
}
/**
* Special server-only class to simulate a MediaQueryList and
* - supports manual activation to simulate mediaQuery matching
* - manages listeners
*/
declare class ServerMediaQueryList extends EventTarget implements MediaQueryList {
private _mediaQuery;
private _isActive;
private _listeners;
get matches(): boolean;
get media(): string;
constructor(_mediaQuery: string, _isActive?: boolean);
/**
* Destroy the current list by deactivating the
* listeners and clearing the internal list
*/
destroy(): void;
/** Notify all listeners that 'matches === TRUE' */
activate(): ServerMediaQueryList;
/** Notify all listeners that 'matches === false' */
deactivate(): ServerMediaQueryList;
/** Add a listener to our internal list to activate later */
addListener(listener: MediaQueryListListener): void;
/** Don't need to remove listeners in the server environment */
removeListener(): void;
addEventListener(): void;
removeEventListener(): void;
dispatchEvent(_: Event): boolean;
onchange: MediaQueryListListener;
}
/**
* Special server-only implementation of MatchMedia that uses the above
* ServerMediaQueryList as its internal representation
*
* Also contains methods to activate and deactivate breakpoints
*/
declare class ServerMatchMedia extends _MatchMedia {
protected _zone: NgZone;
protected _platformId: Object;
protected _document: any;
protected breakpoints: BreakPoint[];
protected layoutConfig: LayoutConfigOptions;
private _activeBreakpoints;
constructor(_zone: NgZone, _platformId: Object, _document: any, breakpoints: BreakPoint[], layoutConfig: LayoutConfigOptions);
/** Activate the specified breakpoint if we're on the server, no-op otherwise */
activateBreakpoint(bp: BreakPoint): void;
/** Deactivate the specified breakpoint if we're on the server, no-op otherwise */
deactivateBreakpoint(bp: BreakPoint): void;
/**
* Call window.matchMedia() to build a MediaQueryList; which
* supports 0..n listeners for activation/deactivation
*/
protected buildMQL(query: string): ServerMediaQueryList;
static ɵfac: i0.ɵɵFactoryDeclaration<ServerMatchMedia, never>;
static ɵprov: i0.ɵɵInjectableDeclaration<ServerMatchMedia>;
}
type MediaQueryListListener = ((this: MediaQueryList, ev: MediaQueryListEvent) => any) | null;
/**
* Activate all the registered breakpoints in sequence, and then
* retrieve the associated stylings from the virtual stylesheet
* @param serverSheet the virtual stylesheet that stores styles for each
* element
* @param mediaController the MatchMedia service to activate/deactivate breakpoints
* @param breakpoints the registered breakpoints to activate/deactivate
* @param mediaMarshaller the MediaMarshaller service to disable fallback styles dynamically
*/
declare function generateStaticFlexLayoutStyles(serverSheet: StylesheetMap, mediaController: ServerMatchMedia, breakpoints: BreakPoint[], mediaMarshaller: MediaMarshaller): string;
/**
* Create a style tag populated with the dynamic stylings from Flex
* components and attach it to the head of the DOM
*/
declare function FLEX_SSR_SERIALIZER_FACTORY(serverSheet: StylesheetMap, mediaController: ServerMatchMedia, _document: Document, breakpoints: BreakPoint[], mediaMarshaller: MediaMarshaller, _nonce?: string): () => void;
/**
* Provider to set static styles on the server
*/
declare const SERVER_PROVIDERS: ({
provide: i0.InjectionToken<readonly (() => void | Promise<void>)[]>;
useFactory: typeof FLEX_SSR_SERIALIZER_FACTORY;
deps: (typeof _MatchMedia | i0.InjectionToken<Document> | typeof StylesheetMap | typeof MediaMarshaller | Optional[])[];
multi: boolean;
useValue?: undefined;
useClass?: undefined;
} | {
provide: i0.InjectionToken<boolean>;
useValue: boolean;
useFactory?: undefined;
deps?: undefined;
multi?: undefined;
useClass?: undefined;
} | {
provide: typeof _MatchMedia;
useClass: typeof ServerMatchMedia;
useFactory?: undefined;
deps?: undefined;
multi?: undefined;
useValue?: undefined;
})[];
type StyleSheet = Map<HTMLElement, Map<string, string | number>>;
type ClassMap = Map<HTMLElement, string>;
export { FLEX_SSR_SERIALIZER_FACTORY, FlexLayoutServerModule, SERVER_PROVIDERS, generateStaticFlexLayoutStyles };
export type { ClassMap, StyleSheet };