{"version":3,"file":"seniorsistemas-angular-components-card.mjs","sources":["../../projects/angular-components/card/src/lib/card/card.component.ts","../../projects/angular-components/card/src/lib/card/card.component.html","../../projects/angular-components/card/src/lib/card/card.module.ts","../../projects/angular-components/card/src/seniorsistemas-angular-components-card.ts"],"sourcesContent":["import { AfterContentInit, Component, ContentChildren, Input, QueryList, TemplateRef } from '@angular/core';\n\nimport { TemplateDirective } from '@seniorsistemas/angular-components/template';\n\n/**\n * @description Componente de cartão com suporte a banner, cabeçalho (título, subtítulo e ícone)\n * e templates customizáveis para cabeçalho, corpo e rodapé via `TemplateDirective`.\n *\n * @example\n * ```html\n * <s-card title=\"Título\" subtitle=\"Subtítulo\">\n *   <ng-template sTemplate type=\"body\">Conteúdo</ng-template>\n * </s-card>\n * ```\n *\n * @category Structure\n */\n@Component({\n    selector: 's-card',\n    templateUrl: './card.component.html',\n    styleUrls: ['./card.component.scss'],\n})\nexport class CardComponent implements AfterContentInit {\n    /** @description URL da imagem exibida como banner no topo do card. */\n    @Input()\n    public bannerImage?: string;\n\n    /** @description Faz o card ocupar 100% da largura disponível. @default false */\n    @Input()\n    public fullWidth = false;\n\n    /** @description Título exibido no cabeçalho do card. @default '' */\n    @Input() title = '';\n\n    /** @description Subtítulo exibido abaixo do título. @default '' */\n    @Input() subtitle = '';\n\n    /** @description Classe do ícone exibido no cabeçalho. @default '' */\n    @Input() icon = '';\n\n    public showBanner = false;\n\n    @ContentChildren(TemplateDirective)\n    public templates?: QueryList<TemplateDirective>;\n\n    public hasCustomTemplates = false;\n    public headerTemplate?: TemplateRef<unknown>;\n    public bodyTemplate?: TemplateRef<unknown>;\n    public footerTemplate?: TemplateRef<unknown>;\n\n    public get hasHeader() {\n        const headerTemplate = !!this.headerTemplate;\n        const hasHeaderAttributes = this.title || this.subtitle || this.icon;\n        return headerTemplate || hasHeaderAttributes;\n    }\n\n    public async ngAfterContentInit(): Promise<void> {\n        await this._setShowBanner();\n        this._setTemplates();\n    }\n\n    private _getHeaderTemplate(): TemplateRef<unknown> | undefined {\n        return this._getCustomTemplate('header');\n    }\n\n    private _getBodyTemplate(): TemplateRef<unknown> | undefined {\n        return this._getCustomTemplate('body');\n    }\n\n    private _getFooterTemplate(): TemplateRef<unknown> | undefined {\n        return this._getCustomTemplate('footer');\n    }\n\n    private _getCustomTemplate(type: string): TemplateRef<unknown> | undefined {\n        return this.templates?.find((template: TemplateDirective) => template.type === type)?.template;\n    }\n\n    private _setTemplates(): void {\n        this.headerTemplate = this._getHeaderTemplate();\n        this.bodyTemplate = this._getBodyTemplate();\n        this.footerTemplate = this._getFooterTemplate();\n\n        this.hasCustomTemplates = !!(this.headerTemplate || this.bodyTemplate || this.footerTemplate);\n    }\n\n    private _setShowBanner() {\n        return new Promise<void>((resolve) => {\n            if (!this.bannerImage) {\n                resolve();\n                return;\n            }\n\n            const img = new Image();\n            img.src = this.bannerImage;\n            img.onload = () => {\n                this.showBanner = true;\n                resolve();\n            };\n\n            img.onerror = () => {\n                this.showBanner = false;\n                resolve();\n            };\n        });\n    }\n}\n\n","<div\n    class=\"card\"\n    [class.card--full-width]=\"fullWidth\"\n>\n    @if (showBanner) {\n        <div\n            class=\"banner\"\n            [ngStyle]=\"{ 'background-image': 'url(' + bannerImage + ')' }\"\n        ></div>\n    }\n\n    <!-- @if (hasCustomTemplates) {\n        @if (headerTemplate) {\n            <div class=\"header\">\n                <ng-container *ngTemplateOutlet=\"headerTemplate\"></ng-container>\n            </div>\n        }\n        @if (bodyTemplate) {\n            <div class=\"body\">\n                <ng-container *ngTemplateOutlet=\"bodyTemplate\"></ng-container>\n            </div>\n        }\n        @if (footerTemplate) {\n            <div class=\"footer\">\n                <ng-container *ngTemplateOutlet=\"footerTemplate\"></ng-container>\n            </div>\n        }\n    } @else {\n        <div class=\"body\">\n            <ng-content></ng-content>\n        </div>\n    } -->\n\n    @if(hasHeader) {\n        <div class=\"header\">\n            @if(headerTemplate) {\n                <ng-container *ngTemplateOutlet=\"headerTemplate\"></ng-container>\n            }\n            @if(!headerTemplate) {\n                <div class=\"header-content\">\n                    <div class=\"header-icon\" *ngIf=\"icon\">\n                        <i [class]=\"icon\"></i>\n                    </div>\n                    <div>\n                        <div class=\"header-title\" *ngIf=\"title\">\n                            {{ title }}\n                        </div>\n                        <div class=\"header-subtitle\" *ngIf=\"subtitle\">\n                            {{ subtitle }}\n                        </div>\n                    </div>\n                </div>\n            }\n        </div>\n    }\n    <div class=\"body\">\n        @if(bodyTemplate) {\n            <ng-container *ngTemplateOutlet=\"bodyTemplate\"></ng-container>\n        }@else {\n            <ng-content></ng-content>\n        }\n    </div>\n\n    @if(footerTemplate) {\n        <div class=\"footer\">\n            <ng-container *ngTemplateOutlet=\"footerTemplate\"></ng-container>\n        </div>\n    }\n</div>\n","import { NgModule } from '@angular/core';\nimport { CommonModule } from '@angular/common';\n\nimport { CardComponent } from './card.component';\n\nimport { TemplateModule } from '@seniorsistemas/angular-components/template'\n\n\n@NgModule({\n    imports: [CommonModule, TemplateModule],\n    declarations: [CardComponent],\n    exports: [CardComponent],\n})\nexport class CardModule {}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;;;;AAIA;;;;;;;;;;;;AAYG;MAMU,aAAa,CAAA;;AAGf,IAAA,WAAW,CAAU;;IAIrB,SAAS,GAAG,KAAK,CAAC;;IAGhB,KAAK,GAAG,EAAE,CAAC;;IAGX,QAAQ,GAAG,EAAE,CAAC;;IAGd,IAAI,GAAG,EAAE,CAAC;IAEZ,UAAU,GAAG,KAAK,CAAC;AAGnB,IAAA,SAAS,CAAgC;IAEzC,kBAAkB,GAAG,KAAK,CAAC;AAC3B,IAAA,cAAc,CAAwB;AACtC,IAAA,YAAY,CAAwB;AACpC,IAAA,cAAc,CAAwB;AAE7C,IAAA,IAAW,SAAS,GAAA;AAChB,QAAA,MAAM,cAAc,GAAG,CAAC,CAAC,IAAI,CAAC,cAAc,CAAC;AAC7C,QAAA,MAAM,mBAAmB,GAAG,IAAI,CA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