{"version":3,"file":"talenra-ngx-base-workspace-header.mjs","sources":["../../../projects/ngx-base/workspace-header/src/workspace-header/workspace-header.component.ts","../../../projects/ngx-base/workspace-header/src/workspace-header/workspace-header.component.html","../../../projects/ngx-base/workspace-header/talenra-ngx-base-workspace-header.ts"],"sourcesContent":["import {\n  ChangeDetectionStrategy,\n  Component,\n  ElementRef,\n  OnDestroy,\n  OnInit,\n  input,\n  numberAttribute,\n  inject,\n  output,\n} from '@angular/core';\nimport { RouterLink } from '@angular/router';\nimport { BadgeComponent } from '@talenra/ngx-base/badge';\nimport { deprecationWarning } from '@talenra/ngx-base/dev-kit';\nimport { BreadcrumbFragment } from './workspace-header.types';\n\n/**\n * The component displays a breadcrumb and a title. It is typically used with a\n * workspace-layout and placed on top of the content section.\n *\n * ### Import\n *\n * ```typescript\n * import { WorkspaceHeaderModule } from '@talenra/ngx-base/workspace-header';\n * ```\n *\n * <example-url>../../#/workspace-layout/workspace-simple</example-url>\n */\n@Component({\n  selector: 'talenra-workspace-header',\n  templateUrl: './workspace-header.component.html',\n  styleUrls: ['./workspace-header.component.scss'],\n  changeDetection: ChangeDetectionStrategy.OnPush,\n  imports: [RouterLink, BadgeComponent],\n  host: {\n    '[attr.title]': 'null', // Prevents the browser from showing the title attribute on hover\n  },\n})\nexport class WorkspaceHeaderComponent implements OnInit, OnDestroy {\n  /**\n   * The title displayed to the user\n   */\n  public title = input<string>('');\n\n  /**\n   * The subtitle displayed to the user\n   */\n  public subtitle = input<string>('');\n\n  /**\n   * The content displayed in the breadcrumb navigation\n   */\n  public path = input<BreadcrumbFragment[]>([]);\n\n  /**\n   * A numeric counter value attached to the title (visually represented as badge/call-out). Typically a number that\n   * represents the number of items contained in this section.\n   *\n   * ```html\n   * <talenra-workspace-header title=\"My Workspace\" counter=\"42\"></talenra-workspace-header>\n   * ```\n   */\n  public counter = input<number, unknown>(0, { transform: numberAttribute });\n\n  /**\n   * The maximum value of the counter. If the counter value exceeds this limit, \"<counterMax>+\" will be displayed (e.g.\n   * \"99+\").\n   *\n   * ```html\n   * <talenra-workspace-header ... counterMax=\"99\"></talenra-workspace-header>\n   * ```\n   */\n  public counterMax = input<number, undefined | unknown>(undefined, {\n    transform: (value: unknown): number | undefined => {\n      const numeric: number = numberAttribute(value);\n      return isNaN(numeric) ? undefined : numeric;\n    },\n  });\n\n  private hostObserver?: ResizeObserver;\n  private hostHeight: number = 0;\n\n  /**\n   * heightUpdate is emitted whenever the host element's height changes. The\n   * new height is passed. This is useful for cases where the layout depends\n   * on the header height and cannot be handled using CSS.\n   */\n  public readonly heightUpdate = output<number>();\n\n  private elementRef = inject(ElementRef);\n\n  /** @internal */\n  constructor() {\n    setTimeout(() => {\n      // Shaky workaround to throw a warning if deprecated `heightUpdate` has subscribers. Better ideas welcome!\n      if (this.heightUpdate['listeners']?.length >= 1)\n        deprecationWarning({\n          submodule: 'workspace-header',\n          className: this.constructor.name,\n          member: 'Event `heightUpdate`',\n          instructions: 'Please get in touch with us if you think we should keep support for `heightUpdate` event.',\n        });\n    }, 100);\n  }\n\n  /** @internal */\n  ngOnInit(): void {\n    // Observe host resizes\n    this.hostObserver = new ResizeObserver((entries) => {\n      this.updateHostHeight(entries[0].contentRect.height);\n    });\n    this.hostObserver.observe(this.elementRef.nativeElement);\n  }\n\n  /** @internal */\n  ngOnDestroy(): void {\n    // Unobserve host resizes\n    this.hostObserver?.unobserve(this.elementRef.nativeElement);\n  }\n\n  /**\n   * Trigger heightUpdate event whenever the host element's height changes.\n   */\n  private updateHostHeight(hostHeight: number): void {\n    if (hostHeight === this.hostHeight) return;\n    this.hostHeight = hostHeight;\n    this.heightUpdate.emit(hostHeight);\n  }\n}\n","<header class=\"header\" [class.has-title]=\"!!title()\" [class.has-subtitle]=\"!!subtitle()\">\n  <nav class=\"breadcrumb\">\n    @for (fragment of path(); track fragment.label) {\n      <span\n        class=\"breadcrumb-item\"\n        [class.has-link]=\"!!fragment.link\"\n        [routerLink]=\"fragment.link ? [fragment.link] : []\"\n        >{{ fragment.label }}</span\n      >\n    }\n    @if (path().length < 1) {\n      <span class=\"breadcrumb-item\">&nbsp;</span>\n    }\n  </nav>\n  @if (title()) {\n    <h1 class=\"title\">\n      {{ title() }}\n      @if (counter()) {\n        <span class=\"counter\"><talenra-badge [counter]=\"counter()\" [maxVal]=\"counterMax()\" /></span>\n      }\n    </h1>\n  }\n  @if (subtitle()) {\n    <h2 class=\"subtitle\">{{ subtitle() }}</h2>\n  }\n</header>\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;;;;AAgBA;;;;;;;;;;;AAWG;MAWU,wBAAwB,CAAA;;AAsDnC,IAAA,WAAA,GAAA;AArDA;;AAEG;AACI,QAAA,IAAA,CAAA,KAAK,GAAG,KAAK,CAAS,EAAE,CAAC;AAEhC;;AAEG;AACI,QAAA,IAAA,CAAA,QAAQ,GAAG,KAAK,CAAS,EAAE,CAAC;AAEnC;;AAEG;AACI,QAAA,IAAA,CAAA,IAAI,GAAG,KAAK,CAAuB,EAAE,CAAC;AAE7C;;;;;;;AAOG;QACI,IAAO,CAAA,OAAA,GAAG,KAAK,CAAkB,CAAC,EAAE,EAAE,SAAS,EAAE,eAAe,EAAE,CAAC;AAE1E;;;;;;;AAOG;AACI,QAAA,IAAA,CAAA,UAAU,GAAG,KAAK,CAA8B,SAAS,EAAE;AAChE,YAAA,SAAS,EAAE,CAAC,KAAc,KAAwB;AAChD,gBAAA,MAAM,OAAO,GAAW,eAAe,CAAC,KAAK,CAAC;AAC9C,gBAAA,OAAO,KAAK,CAAC,OAAO,CAAC,GAAG,SAAS,GAAG,OAAO;aAC5C;AACF,SAAA,CAAC;QAGM,IAAU,CAAA,UAAA,GAAW,CAAC;AAE9B;;;;AAIG;QACa,IAAY,CAAA,YAAA,GAAG,MAAM,EAAU;AAEvC,QAAA,IAAA,CAAA,UAAU,GAAG,MAAM,CAAC,UAAU,CAAC;QAIrC,UAAU,CAAC,MAAK;;YAEd,IAAI,IAAI,CA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