1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 | import { OnDestroy } from '@angular/core';
|
9 | import { MediaChange } from '../media-change';
|
10 | import { BreakPoint } from '../breakpoints/break-point';
|
11 | import { LayoutConfigOptions } from '../tokens/library-config';
|
12 | import { BreakPointRegistry, OptionalBreakPoint } from '../breakpoints/break-point-registry';
|
13 |
|
14 |
|
15 |
|
16 | export interface HookTarget {
|
17 | activatedBreakpoints: BreakPoint[];
|
18 | updateStyles(): void;
|
19 | }
|
20 | export declare const BREAKPOINT_PRINT: {
|
21 | alias: string;
|
22 | mediaQuery: string;
|
23 | priority: number;
|
24 | };
|
25 |
|
26 |
|
27 |
|
28 |
|
29 |
|
30 |
|
31 | export declare class PrintHook implements OnDestroy {
|
32 | protected breakpoints: BreakPointRegistry;
|
33 | protected layoutConfig: LayoutConfigOptions;
|
34 | protected _document: any;
|
35 | constructor(breakpoints: BreakPointRegistry, layoutConfig: LayoutConfigOptions, _document: any);
|
36 | /** Add 'print' mediaQuery: to listen for matchMedia activations */
|
37 | withPrintQuery(queries: string[]): string[];
|
38 | /** Is the MediaChange event for any 'print' @media */
|
39 | isPrintEvent(e: MediaChange): Boolean;
|
40 | /** What is the desired mqAlias to use while printing? */
|
41 | get printAlias(): string[];
|
42 | /** Lookup breakpoints associated with print aliases. */
|
43 | get printBreakPoints(): BreakPoint[];
|
44 | /** Lookup breakpoint associated with mediaQuery */
|
45 | getEventBreakpoints({ mediaQuery }: MediaChange): BreakPoint[];
|
46 | /** Update event with printAlias mediaQuery information */
|
47 | updateEvent(event: MediaChange): MediaChange;
|
48 | private registeredBeforeAfterPrintHooks;
|
49 | private isPrintingBeforeAfterEvent;
|
50 | private beforePrintEventListeners;
|
51 | private afterPrintEventListeners;
|
52 | private registerBeforeAfterPrintHooks;
|
53 | /**
|
54 | * Prepare RxJS filter operator with partial application
|
55 | * @return pipeable filter predicate
|
56 | */
|
57 | interceptEvents(target: HookTarget): (event: MediaChange) => void;
|
58 | /** Stop mediaChange event propagation in event streams */
|
59 | blockPropagation(): (event: MediaChange) => boolean;
|
60 | /**
|
61 | * Save current activateBreakpoints (for later restore)
|
62 | * and substitute only the printAlias breakpoint
|
63 | */
|
64 | protected startPrinting(target: HookTarget, bpList: OptionalBreakPoint[]): void;
|
65 | /** For any print de-activations, reset the entire print queue */
|
66 | protected stopPrinting(target: HookTarget): void;
|
67 | /**
|
68 | * To restore pre-Print Activations, we must capture the proper
|
69 | * list of breakpoint activations BEFORE print starts. OnBeforePrint()
|
70 | * is supported; so 'print' mediaQuery activations are used as a fallback
|
71 | * in browsers without `beforeprint` support.
|
72 | *
|
73 | * > But activated breakpoints are deactivated BEFORE 'print' activation.
|
74 | *
|
75 | * Let's capture all de-activations using the following logic:
|
76 | *
|
77 | * When not printing:
|
78 | * - clear cache when activating non-print breakpoint
|
79 | * - update cache (and sort) when deactivating
|
80 | *
|
81 | * When printing:
|
82 | * - sort and save when starting print
|
83 | * - restore as activatedTargets and clear when stop printing
|
84 | */
|
85 | collectActivations(event: MediaChange): void;
|
86 | /** Teardown logic for the service. */
|
87 | ngOnDestroy(): void;
|
88 | /** Is this service currently in Print-mode ? */
|
89 | private isPrinting;
|
90 | private queue;
|
91 | private deactivations;
|
92 | }
|