{"version":3,"file":"fundamental-ngx-core-title.mjs","sources":["../../../../libs/core/title/title.component.ts","../../../../libs/core/title/title.module.ts","../../../../libs/core/title/fundamental-ngx-core-title.ts"],"sourcesContent":["import {\n    ChangeDetectionStrategy,\n    Component,\n    ElementRef,\n    InjectionToken,\n    ViewEncapsulation,\n    booleanAttribute,\n    effect,\n    inject,\n    input\n} from '@angular/core';\n\n/**\n * Valid HTML heading sizes for the title component.\n * Corresponds to h1 through h6 HTML elements.\n */\nexport type HeaderSizes = 1 | 2 | 3 | 4 | 5 | 6;\n\n/**\n * Injection token for providing a default header size to title components.\n *\n * **How it works:**\n * 1. A parent component (like dialog-header) provides this token with a value (e.g., 5)\n * 2. Child title components automatically receive that value through dependency injection\n * 3. The title uses this default only if no explicit `headerSize` input is provided\n *\n * **Example:**\n * ```typescript\n * // Parent provides the default\n * @Component({\n *   providers: [{ provide: DEFAULT_TITLE_SIZE, useValue: 5 }]\n * })\n * export class DialogHeaderComponent { }\n *\n * // Child receives the default automatically\n * <fd-dialog-header>\n *   <h1 fd-title>Title</h1>  <!-- Will be size 5 -->\n * </fd-dialog-header>\n * ```\n */\nexport const DEFAULT_TITLE_SIZE = new InjectionToken<HeaderSizes>('DEFAULT_TITLE_SIZE');\n\n/**\n * Abstract token for providing access to the title component's element reference.\n * Used for dependency injection when components need to access the title element.\n */\nexport abstract class TitleToken {\n    abstract elementRef: ElementRef;\n}\n\n/**\n * Title component for rendering semantic headings with Fundamental styles.\n *\n * Applied as an attribute directive to heading elements (h1-h6).\n * Automatically detects heading level from the tag name or can be explicitly set via `headerSize`.\n */\n@Component({\n    // eslint-disable-next-line\n    selector: '[fd-title], [fdTitle]',\n    exportAs: 'fd-title',\n    template: '<ng-content></ng-content>',\n    host: {\n        class: 'fd-title',\n        '[class.fd-title--wrap]': 'wrap()',\n        '[class.fd-title--two-line-clamp]': 'twoLineClamp()'\n    },\n    styleUrl: './title.component.scss',\n    changeDetection: ChangeDetectionStrategy.OnPush,\n    encapsulation: ViewEncapsulation.None,\n    providers: [{ provide: TitleToken, useExisting: TitleComponent }]\n})\nexport class TitleComponent extends TitleToken {\n    /** Whether this title should clamp at two lines of text. */\n    readonly twoLineClamp = input(false, { transform: booleanAttribute });\n\n    /**\n     * Explicit header size (1-6) for the title styling.\n     * If not provided, uses the injected DEFAULT_TITLE_SIZE or automatically detected from the host element's tag name.\n     * @default null\n     */\n    readonly headerSize = input<HeaderSizes | null>(null);\n\n    /**\n     * Enables text wrapping. When `false`, text truncates with ellipsis.\n     * @default false\n     */\n    readonly wrap = input(false);\n\n    /**\n     * Default header size provided by parent component via DI.\n     * Will be `null` if no parent provides DEFAULT_TITLE_SIZE.\n     * @hidden\n     */\n    private readonly _defaultHeaderSize = inject(DEFAULT_TITLE_SIZE, { optional: true });\n\n    /**\n     * Element reference to the host element.\n     * @hidden\n     */\n    private readonly _elementRef = inject(ElementRef<HTMLElement>);\n\n    /**\n     * Tracks the currently applied header size to avoid unnecessary DOM updates.\n     * @hidden\n     */\n    private _appliedHeaderSize: number | undefined;\n\n    /**\n     * Returns the element reference for external access via TitleToken.\n     */\n    get elementRef(): ElementRef {\n        return this._elementRef;\n    }\n\n    /**\n     * @hidden\n     * Effect that reactively updates the header size class when headerSize input changes.\n     * Runs on initialization and whenever the headerSize signal updates.\n     */\n    constructor() {\n        super();\n        effect(() => {\n            this._setHeaderSize();\n        });\n    }\n\n    /**\n     * Applies the appropriate header size class to the host element.\n     * Priority: explicit headerSize > injected default > element tag name.\n     * @hidden\n     */\n    private _setHeaderSize(): void {\n        let headerSize: HeaderSizes | string | null = this.headerSize() ?? this._defaultHeaderSize ?? null;\n\n        // If no explicit size provided, try to extract from element tag name\n        if (headerSize === null) {\n            const tagName = this._elementRef.nativeElement.tagName;\n            // Only extract from valid heading tags (H1-H6)\n            if (/^H[1-6]$/i.test(tagName)) {\n                headerSize = tagName.charAt(1);\n            } else {\n                // Default to h5 for non-heading elements (like div with role=\"heading\")\n                headerSize = 5;\n            }\n        }\n\n        if (this._appliedHeaderSize !== undefined) {\n            this._elementRef.nativeElement.classList.remove(`fd-title--h${this._appliedHeaderSize}`);\n        }\n        this._elementRef.nativeElement.classList.add(`fd-title--h${headerSize}`);\n        this._appliedHeaderSize = Number(headerSize);\n    }\n}\n","import { NgModule } from '@angular/core';\nimport { TitleComponent } from './title.component';\n\n/**\n * @deprecated Use the standalone `TitleComponent` directly instead. Import `TitleComponent` in your component's imports array.\n * This module will be removed in a future version.\n */\n@NgModule({\n    imports: [TitleComponent],\n    exports: [TitleComponent]\n})\nexport class TitleModule {}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;AAkBA;;;;;;;;;;;;;;;;;;;;;AAqBG;MACU,kBAAkB,GAAG,IAAI,cAAc,CAAc,oBAAoB;AAEtF;;;AAGG;MACmB,UAAU,CAAA;AAE/B;AAED;;;;;AAKG;AAgBG,MAAO,cAAe,SAAQ,UAAU,CAAA;AAoC1C;;AAEG;AACH,IAAA,IAAI,UAAU,GAAA;QACV,OAAO,IAAI,CAAC,WAAW;IAC3B;AAEA;;;;AAIG;AACH,IAAA,WAAA,GAAA;AACI,QAAA,KAAK,EAAE;;QA/CF,IAAA,CAAA,YAAY,GAAG,KAAK,CAAC,KAAK,yDAAI,SAAS,EAAE,gBAAgB,EAAA,CAAG;AAErE;;;;AAIG;AACM,QAAA,IAAA,CAAA,UAAU,GAAG,KAAK,CAAqB,IAAI,sDAAC;AAErD;;;AAGG;AACM,QAAA,IAAA,CAAA,IAAI,GAAG,KAAK,CAAC,KAAK,gDAAC;AAE5B;;;;AAIG;QACc,IAAA,CAAA,kBAAkB,GAAG,MAAM,CAAC,kBAAkB,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;AAEpF;;;AAGG;AACc,QAAA,IAAA,CAAA,WAAW,GAAG,MAAM,EAAC,UAAuB,EAAC;QAsB1D,MAAM,CAAC,MAAK;YACR,IAAI,CAAC,cAAc,EAAE;AACzB,QAAA,CAAC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