import * as _odx_angular_utils from '@odx/angular/utils'; import * as i0 from '@angular/core'; import { OnInit, TemplateRef } from '@angular/core'; import { Observable } from 'rxjs'; /** * Defines default responsive breakpoints for the application. These breakpoints are used to * apply responsive styles and behaviors across various device sizes. Each breakpoint is * configured with a name, a minimum width, and a maximum width, defining the range of device * sizes it targets. * * @constant * @type {Record} * * @example * ```ts * // Accessing a breakpoint value * console.log(DEFAULT_BREAKPOINTS['=phone']); // Outputs: "(min-width: 480px) and (max-width: 767px)" * ``` */ declare const DEFAULT_BREAKPOINTS: { readonly "desktop": string; readonly "desktop-s": string; readonly "tablet": string; readonly "phone": string; readonly "phone-s": string; }; interface BreakpointsConfig { breakpoints: Partial; } /** * Provides Angular dependency injection tokens for accessing and configuring breakpoints * within the application. This enables a type-safe and modular way to manage responsive * design breakpoints across the app. * * @example * ```ts * // Providing custom breakpoints in an Angular module * import { NgModule } from '@angular/core'; * import { provideBreakpointsConfig } from '@odx/angular/breakpoints'; * * @NgModule({ * providers: [ * provideBreakpointsConfig({ * breakpoints: { * ...configureBreakpoint('custom-tablet', 640, 1024), * }, * }), * ], * }) * export class CustomModule {} * ``` */ declare const BreakpointsConfig: i0.InjectionToken>; declare const BreakpointsDefaultConfig: BreakpointsConfig; declare const injectBreakpointsConfig: () => BreakpointsConfig; declare const provideBreakpointsConfig: >>(config: _odx_angular_utils.ConfigProvider, D>) => i0.FactoryProvider | i0.ValueProvider; type BreakpointName = keyof OdxAngular.Breakpoints; interface Breakpoint { min: number; max: number; } /** * A structural directive that conditionally includes an Angular template based on whether the viewport matches * specified breakpoints. It leverages the BreakpointsService to observe changes in viewport size and apply * the appropriate template. * * @Directive * @param {BreakpointsService} breakpointsService - Injects BreakpointsService to observe breakpoint changes. * @param {TemplateRef} template - Injects the Angular template to render when breakpoints match. * @param {ViewContainerRef} viewContainer - Injects the container where the template will be rendered. * * @example * ```html * // Usage in a component template to conditionally display content based on breakpoints * // Assume 'mobile' and 'tablet' are defined breakpoints * * Content to display on mobile and tablet sizes. * * * Content to display on desktop size. * * * Content to display when not on desktop size. * * ``` */ declare class MatchBreakpointsDirective implements OnInit { private readonly breakpoints$$; private readonly breakpointsService; private readonly takeUntilDestroyed; private readonly template; private readonly viewContainer; /** * Sets the breakpoints to observe. The directive's content is displayed if the current viewport matches * any of the specified breakpoints. * * @param {BreakpointName | BreakpointName[]} value - The breakpoint(s) to match against the current viewport size. */ set breakpoints(value: BreakpointName | BreakpointName[] | null | undefined); /** * Optionally specifies a template to render when the viewport does not match the specified breakpoints. * * @param {TemplateRef} elseTemplate - The template to render when the viewport does not match the breakpoints. */ elseTemplate?: TemplateRef | null; ngOnInit(): void; private render; static ɵfac: i0.ɵɵFactoryDeclaration; static ɵdir: i0.ɵɵDirectiveDeclaration; } declare class BreakpointsModule { static ɵfac: i0.ɵɵFactoryDeclaration; static ɵmod: i0.ɵɵNgModuleDeclaration; static ɵinj: i0.ɵɵInjectorDeclaration; } /** * Service to observe and react to changes in viewport size based on predefined breakpoints. * Utilizes Angular CDK's BreakpointObserver for listening to media query changes and integrates * it with the application's custom breakpoints configuration. * * @Injectable({ providedIn: 'root' }) */ declare class BreakpointsService { private readonly breakpointObserver; private readonly config; /** * Observes the specified breakpoints and returns an Observable that emits true if any * of the specified breakpoints match the current viewport size, and false otherwise. * * @param {BreakpointName[]} breakpoints - An array of breakpoints to observe. * @returns {Observable} - An Observable that emits true if the viewport matches the specified breakpoints. * * @example * ```ts * // Component that uses BreakpointsService to apply dynamic styles based on breakpoints * @Component({ * selector: 'app-responsive-component', * templateUrl: './responsive-component.component.html', * }) * export class ResponsiveComponent { * isMobile$: Observable; * * constructor(private breakpointsService: BreakpointsService) { * this.isMobile$ = this.breakpointsService.observe(['phone', 'tablet']); * } * } * ``` */ observe(breakpoints: BreakpointName[]): Observable; /** * Checks if any of the specified breakpoints match the current viewport size. * * @param {BreakpointName[]} breakpoints - An array of breakpoints to check. * @returns {boolean} - Returns true if the viewport matches the specified breakpoints, false otherwise. * * @example * ```ts * // Checking if the current viewport matches the 'desktop' breakpoint * const isDesktop = this.breakpointsService.matches(['desktop']); * console.log(`Is desktop view? ${isDesktop}`); * ``` */ matches(breakpoints: BreakpointName[]): boolean; private getMediaQueries; private createBreakpointObserver; static ɵfac: i0.ɵɵFactoryDeclaration; static ɵprov: i0.ɵɵInjectableDeclaration; } declare global { namespace OdxAngular { interface Breakpoints extends Record { } } } type BreakpointOperators = '<' | '=' | '>'; type BreakpointConfig = Record<`${BreakpointOperators}${T}`, string>; /** * Generates a configuration object containing CSS media query strings for a named breakpoint. * The function creates media queries for three scenarios: below (`<`), exactly (`=`), and above (`>`) the specified breakpoint. * * @template T - The string literal type representing the name of the breakpoint. * @param {T} name - The name of the breakpoint (e.g., 'md' for medium). * @param {number} min - The minimum width (inclusive) where the breakpoint starts. * @param {number} max - The maximum width (exclusive) where the breakpoint ends. * @returns {BreakpointConfig} An object containing media query strings for targeting screen sizes relative to the breakpoint. * * @example * ```ts * // Define a medium (md) breakpoint * const mdBreakpoint = configureBreakpoint('md', 768, 1024); * console.log(mdBreakpoint['md']); // Outputs: "(min-width: 768px)" * ``` */ declare function configureBreakpoint(name: T, min: number, max: number): BreakpointConfig; export { BreakpointsConfig, BreakpointsDefaultConfig, BreakpointsModule, BreakpointsService, DEFAULT_BREAKPOINTS, MatchBreakpointsDirective, configureBreakpoint, injectBreakpointsConfig, provideBreakpointsConfig }; export type { Breakpoint, BreakpointName };