{"version":3,"file":"talenra-ngx-base-infotip.mjs","sources":["../../../projects/ngx-base/infotip/src/directives/infotip.directive.ts","../../../projects/ngx-base/infotip/src/services/infotip.service.ts","../../../projects/ngx-base/infotip/src/directives/infotip-anchor.directive.ts","../../../projects/ngx-base/infotip/src/infotip-layout/infotip-layout.component.ts","../../../projects/ngx-base/infotip/src/infotip-layout/infotip-layout.component.html","../../../projects/ngx-base/infotip/talenra-ngx-base-infotip.ts"],"sourcesContent":["import { Directive } from '@angular/core';\nimport { CdkMenu } from '@angular/cdk/menu';\n\n/**\n * Directive to add infotip behavior to a host element (e.g. close the infotip on escape key press).\n *\n * ### Usage\n *\n * ```html\n * <h1 class=\"title\">Infotip title</h1>\n * <p class=\"description\">Infotip content with custom layout</p>\n * ```\n *\n * ```typescript\n * import { Component } from '@angular/core';\n * import { InfotipDirective } from '@talenra/ngx-base/infotip';\n *\n * @Component({\n *   ...\n *   hostDirectives: [InfotipDirective],\n * })\n * export class CustomInfotipComponent {}\n * ```\n *\n * <example-url>../../#/infotip</example-url>\n */\n\n@Directive({\n  selector: '[talenraInfotip]',\n  hostDirectives: [CdkMenu],\n})\nexport class InfotipDirective {}\n","import { Injectable } from '@angular/core';\nimport { BehaviorSubject } from 'rxjs';\n\n/** @internal */\n@Injectable({\n  providedIn: 'root',\n})\nexport class InfotipService {\n  /** @internal */\n  private counter = 0;\n  /** @internal */\n  public closeListener$: BehaviorSubject<number> = new BehaviorSubject(0);\n\n  /** @internal */\n  register(): number {\n    return this.counter++;\n  }\n\n  /** @internal */\n  closeAllExcept(id: number) {\n    this.closeListener$.next(id);\n  }\n}\n","import { AfterViewInit, DestroyRef, Directive, inject, OnInit } from '@angular/core';\nimport { CdkMenuItem, CdkMenuTrigger } from '@angular/cdk/menu';\nimport { takeUntilDestroyed } from '@angular/core/rxjs-interop';\nimport { InfotipService } from '../services/infotip.service';\n\n/**\n * Assigned to an element, InfotipAnchor triggers the associated Infotip. InfotipAnchor provides `triggerFor` input\n * property. It will trigger the template with a matching id.\n *\n * ```html\n * <span talenraInfotipAnchor [triggerFor]=\"myinfotip\">Infotip</span>\n * <ng-template #myinfotip>\n *   <talenra-infotip-layout title=\"Short message\" description=\"A long, really, really long message\" />\n * </ng-template>\n * ```\n *\n * Important: If you use a custom layout component instead of the library's infotip layout, you need to import\n * the CdkMenu directive and add it to the hostDirectives array of the custom layout component.\n * This will make sure that the infotip is closed when clicked outside.\n *\n * ### Import\n *\n * ```typescript\n * import { InfotipAnchorDirective } from '@talenra/ngx-base/infotip';\n * ````\n *\n * @see {@link InfotipLayoutComponent}\n *\n * <example-url>../../#/infotip</example-url>\n */\n@Directive({\n  selector: '[talenraInfotipAnchor]',\n  hostDirectives: [\n    CdkMenuItem,\n    {\n      directive: CdkMenuTrigger,\n      inputs: ['cdkMenuTriggerFor: triggerFor'],\n    },\n  ],\n})\nexport class InfotipAnchorDirective implements OnInit, AfterViewInit {\n  /** @internal */\n  private destroyRef = inject(DestroyRef);\n  /** @internal */\n  private cdkMenuTrigger = inject(CdkMenuTrigger);\n  /** @internal */\n  private infotipService = inject(InfotipService);\n\n  /** @internal */\n  infotipId: number | undefined;\n\n  /** @internal */\n  ngOnInit() {\n    this.infotipId = this.infotipService.register();\n    this.infotipService.closeListener$.pipe(takeUntilDestroyed(this.destroyRef)).subscribe((id) => {\n      if (id !== this.infotipId) {\n        this.cdkMenuTrigger.close();\n      }\n    });\n    this.cdkMenuTrigger.opened.pipe(takeUntilDestroyed(this.destroyRef)).subscribe(() => {\n      this.infotipService.closeAllExcept(this.infotipId!);\n    });\n  }\n\n  private handleScroll = () => {\n    if (this.cdkMenuTrigger.isOpen()) {\n      this.cdkMenuTrigger.close();\n    }\n  };\n\n  /**\n   * @internal\n   */\n  ngAfterViewInit() {\n    this.cdkMenuTrigger.opened.pipe(takeUntilDestroyed(this.destroyRef)).subscribe(() => {\n      window.addEventListener('scroll', this.handleScroll, true);\n    });\n    this.cdkMenuTrigger.closed.pipe(takeUntilDestroyed(this.destroyRef)).subscribe(() => {\n      window.removeEventListener('scroll', this.handleScroll, true);\n    });\n  }\n}\n","import { Component, computed, input } from '@angular/core';\nimport { CdkMenu } from '@angular/cdk/menu';\nimport { CopyContentButtonComponent } from '@talenra/ngx-base/copy-content';\n\n/**\n * InfotipLayout provides the default layout used for Infotip content.\n *\n * InfotipLayout is used to display additional information related to a content (e.g. an icon or a term). It consists of\n * a title and a description, which can be used to set the content of the infotip.\n *\n * The title is used to display a short message to the user while the description typically contains a more detailed\n * explanation. InfotipLayout includes a CopyContent button which allows the user to copy the message for further\n * processing.\n *\n * ```html\n * <span talenraInfotipAnchor [triggerFor]=\"infotip\">Infotip</span>\n * <ng-template #infotip>\n *   <talenra-infotip-layout title=\"My Title\" description=\"My description text\"></talenra-infotip-layout>\n * </ng-template>\n * ```\n *\n * **Important:** If you use a custom layout component instead of InfotipLayout, you need to import `InfotipDirective`\n * and add it to the `hostDirectives` array of the custom layout component. This will make sure that the custom infotip\n * is closed when clicked outside.\n *\n * ### Import\n *\n * ```typescript\n * import { InfotipLayoutComponent } from '@talenra/ngx-base/infotip';\n * ````\n *\n * @see {@link InfoTipAnchorDirective}\n * @see {@link InfoTipDirective}\n *\n * <example-url>../../../#/infotip</example-url>\n */\n@Component({\n  selector: 'talenra-infotip-layout',\n  imports: [CdkMenu, CopyContentButtonComponent],\n  templateUrl: './infotip-layout.component.html',\n  styleUrl: './infotip-layout.component.scss',\n  hostDirectives: [CdkMenu],\n})\nexport class InfotipLayoutComponent {\n  /**\n   * The title string to be displayed\n   */\n  title = input.required<string>();\n\n  /**\n   * The description string to be displayed\n   */\n  description = input<string>();\n\n  protected toCopy = computed(() => {\n    return `${this.title()}\\r\\n\\r\\n${this.description()}`;\n  });\n}\n","<div class=\"title\">\n  {{ title() }}\n  <talenra-copy-content-button [toCopy]=\"toCopy()\" />\n</div>\n<div class=\"description\">\n  {{ description() }}\n</div>\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;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