UNPKG

@ynmstudio/utils

Version:
67 lines (64 loc) 3.14 kB
import * as _angular_core from '@angular/core'; import { InjectionToken, Optional } from '@angular/core'; /** * Injection token to control the base heading level within components. * * This provider allows setting or resetting the heading level hierarchy within specific components. * This is useful when you want to start a new heading hierarchy from level 1, regardless of parent levels. * * Common use cases include: * - Reset to h1 at the start of a new <article> element to maintain proper document outline * - Start fresh heading hierarchy in <aside> elements or sidebars * - Modal dialogs or overlays that should have their own heading structure * - Independent widgets or components that can be placed anywhere but need consistent heading levels * - Blog post or article comments sections that should start their own hierarchy * * @example * ```typescript * @Component({ * providers: [ * { provide: DYNAMIC_HEADING_LEVEL, useValue: 1 } // Reset to h1 * ] * }) * ``` */ declare const DYNAMIC_HEADING_LEVEL: InjectionToken<number>; /** * Injection token to enable debug mode for dynamic headings. * * When set to true, a pseudo element will be rendered next to each heading element * showing its current heading level (e.g. "H2/Heading 2"). This provides visual feedback * about the computed heading levels during development. * * @default false */ declare const DYNAMIC_HEADING_DEBUG: InjectionToken<boolean>; /** * Factory function to increase the heading level relative to parent headings. * * This can be used in two ways: * 1. As a provider to automatically increment heading levels by X relative to parent headings * (e.g. h1 -> h2 -> h3) * 2. Alternatively, the level/offset inputs can be used directly on the dynamicHeading directive * to explicitly set the heading level, overriding the automatic increments * * @param offset Number of levels to increment from the parent heading level (defaults to 1) * @returns Provider configuration for DYNAMIC_HEADING_LEVEL */ declare function increaseDynamicHeadingLevel(): { provide: InjectionToken<number>; useFactory: (parentLevel: number | null) => number; deps: Optional[][]; }; declare class DynamicHeadingDirective { #private; debug: boolean; dynamicHeadingClass: _angular_core.InputSignal<string>; _level: _angular_core.InputSignalWithTransform<number, string | number>; offset: _angular_core.InputSignalWithTransform<number, string | number>; level: _angular_core.Signal<number>; constructor(); static ɵfac: _angular_core.ɵɵFactoryDeclaration<DynamicHeadingDirective, never>; static ɵdir: _angular_core.ɵɵDirectiveDeclaration<DynamicHeadingDirective, "[dynamicHeading]", never, { "dynamicHeadingClass": { "alias": "dynamicHeadingClass"; "required": false; "isSignal": true; }; "_level": { "alias": "level"; "required": false; "isSignal": true; }; "offset": { "alias": "offset"; "required": false; "isSignal": true; }; }, {}, never, never, true, never>; } export { DYNAMIC_HEADING_DEBUG, DYNAMIC_HEADING_LEVEL, DynamicHeadingDirective, increaseDynamicHeadingLevel };