import * as _angular_core from '@angular/core'; import { Provider, Signal } from '@angular/core'; export { injectPrefersReducedMotion } from 'forty-cdk/core'; /** * A breakpoint map: each named breakpoint paired with its `min-width` * threshold in CSS pixels. Names are arbitrary — `injectBreakpoints` derives * its query methods (`up`, `down`, `between`, `only`) from whatever keys this * map declares, sorted ascending by threshold. */ type BreakpointMap = Record; /** * The default breakpoint map, mirroring Tailwind CSS's `sm`–`2xl` scale. Used * as the library fallback when no `provideForBreakpointsDefaults` is in scope, * and the source of the typed breakpoint names when the consumer has not * augmented {@link BreakpointRegistry}. */ declare const forBreakpointsTailwind: { readonly sm: 640; readonly md: 768; readonly lg: 1024; readonly xl: 1280; readonly '2xl': 1536; }; /** The breakpoint names from the default Tailwind scale. */ type TailwindBreakpointName = keyof typeof forBreakpointsTailwind; /** Resolved shape stored against {@link FOR_BREAKPOINTS_DEFAULTS}. */ interface ForBreakpointsDefaults { /** The active breakpoint map for the current injector scope. */ breakpoints: BreakpointMap; } /** * Token holding the resolved breakpoint map for the current injector scope. * The library always provides a fully-populated value (the Tailwind fallback * at the root, or the map from the nearest `provideForBreakpointsDefaults`). */ declare const FOR_BREAKPOINTS_DEFAULTS: _angular_core.InjectionToken; /** * Configures the breakpoint map for this injector scope so `injectBreakpoints` * can be called with no arguments. Provide it once in your application config: * * ```ts * providers: [ * provideForBreakpointsDefaults({ mobile: 0, tablet: 640, laptop: 1024, desktop: 1280 }), * ] * ``` * * Providing it again on a component injector replaces the map for that subtree * only (the nearest scope wins; the map is replaced wholesale, never merged * key-by-key). Omit it entirely to use {@link forBreakpointsTailwind}. */ declare function provideForBreakpointsDefaults(breakpoints: BreakpointMap): Provider[]; /** * Extension point for typing custom breakpoint names. Augment it via module * declaration merging so `injectBreakpoints` autocompletes your own names * instead of the default Tailwind scale: * * ```ts * import type { appBreakpoints } from './breakpoints'; * * declare module 'forty-cdk' { * interface BreakpointRegistry extends Record {} * } * ``` * * When left empty (no augmentation), {@link BreakpointName} falls back to the * keys of {@link forBreakpointsTailwind}. */ interface BreakpointRegistry { } /** * The set of valid breakpoint names. Resolves to the augmented * {@link BreakpointRegistry} keys when present, otherwise the Tailwind scale * (`'sm' | 'md' | 'lg' | 'xl' | '2xl'`). */ type BreakpointName = [keyof BreakpointRegistry] extends [never] ? TailwindBreakpointName : keyof BreakpointRegistry & string; /** Reactive handle returned by {@link injectBreakpoints}. */ interface ForBreakpoints { /** * Matches the named breakpoint and wider — `(min-width: px)`. * @param name A breakpoint declared in the active map. */ up(name: K): Signal; /** * Matches narrower than the named breakpoint — * `(max-width: px)`. The 0.02px back-off keeps `up(name)` * and `down(name)` from both matching at the exact threshold. * @param name A breakpoint declared in the active map. */ down(name: K): Signal; /** * Matches from `min` (inclusive) up to but not including `max`. * @param min Lower breakpoint, inclusive. * @param max Upper breakpoint, exclusive. */ between(min: K, max: K): Signal; /** * Matches only the named breakpoint's own band — from its threshold up to * but not including the next-larger breakpoint (open-ended for the largest). * @param name A breakpoint declared in the active map. */ only(name: K): Signal; /** * The largest breakpoint whose `min-width` currently matches, or `null` when * the viewport is narrower than the smallest breakpoint (and on the server). */ readonly active: Signal; /** * Escape hatch for an arbitrary media query string (orientation, pointer, * `prefers-color-scheme`, …) that the named helpers don't cover. * @param query Any valid media query. */ matches(query: string): Signal; } /** * A signal-first, zoneless, SSR-safe viewport breakpoint observer. Reads the * breakpoint map from the ambient {@link FOR_BREAKPOINTS_DEFAULTS} token * (configured with `provideForBreakpointsDefaults`, or the Tailwind fallback), * so call sites never repeat the breakpoint set: * * ```ts * private bp = injectBreakpoints(); * protected isDesktop = this.bp.up('desktop'); * protected active = this.bp.active; * ``` * * Each query method returns a `Signal` backed by a cached * `MediaQueryList`. The returned handle captures the calling injection * context, so its methods can be invoked lazily from `computed()` or a * template — not only during construction. Listeners are torn down with the * injector. `active`'s per-breakpoint queries are materialized eagerly at call * time, so reading `active` never attaches a listener from inside a reactive * computation or after teardown. On the server (or where `matchMedia` is * unavailable) every signal reads `false` and `active` reads `null`. * * Must be called from an injection context. * * @returns A {@link ForBreakpoints} handle of reactive query methods. */ declare function injectBreakpoints(): ForBreakpoints; export { FOR_BREAKPOINTS_DEFAULTS, forBreakpointsTailwind, injectBreakpoints, provideForBreakpointsDefaults }; export type { BreakpointMap, BreakpointName, BreakpointRegistry, ForBreakpoints, ForBreakpointsDefaults, TailwindBreakpointName };