{"version":3,"file":"lucca-front-ng-link.mjs","sources":["../../../packages/ng/link/translations.ts","../../../packages/ng/link/link.translate.ts","../../../packages/ng/link/lu-router-link.ts","../../../packages/ng/link/link.component.ts","../../../packages/ng/link/link.component.html","../../../packages/ng/link/lucca-front-ng-link.ts"],"sourcesContent":["export const Translations = {\n\ten: {\n\t\texternal: '(Open in a new window.)',\n\t},\n\tde: {\n\t\texternal: '(In einem neuen Fenster öffnen.)',\n\t},\n\tfr: {\n\t\texternal: '(Ouvrir dans une nouvelle fenêtre.)',\n\t},\n\tit: {\n\t\texternal: '(Aprire in una nuova finestra.)',\n\t},\n\tnl: {\n\t\texternal: '(Open in een nieuw venster.)',\n\t},\n\tes: {\n\t\texternal: '(Abrir en una nueva ventana.)',\n\t},\n\tpt: {\n\t\texternal: '(Abrir numa nova janela.)',\n\t},\n};\n","import { InjectionToken } from '@angular/core';\nimport { LuTranslation } from '@lucca-front/ng/core';\nimport { Translations } from './translations';\n\nexport const LU_LINK_TRANSLATIONS = new InjectionToken('luLinkTranslations', {\n\tfactory: () => luLinkTranslations,\n});\n\nexport interface LinkTranslate {\n\texternal: string;\n}\n\nexport const luLinkTranslations: LuTranslation<LinkTranslate> = Translations;\n","import { LocationStrategy } from '@angular/common';\nimport { Attribute, Directive, ElementRef, Renderer2, WritableSignal } from '@angular/core';\nimport { ActivatedRoute, Router, RouterLink } from '@angular/router';\n\n@Directive({\n\tselector: '[luRouterLink]',\n})\nexport class LuRouterLink extends RouterLink {\n\t// Workaround for a storybook bug = implement the constructor https://github.com/storybookjs/storybook/issues/23534#issuecomment-2042888436\n\tconstructor(router: Router, route: ActivatedRoute, @Attribute('tabindex') tabIndexAttribute: string | null | undefined, renderer: Renderer2, el: ElementRef, locationStrategy?: LocationStrategy) {\n\t\tsuper(router, route, tabIndexAttribute, renderer, el, locationStrategy);\n\t}\n\n\t// With angular 20, RouterLink changed to use an internal, protected, readonly signal that is directly bound to `attr.href`, breaking any possibility to override it\n\t// So we had to do this to expose it to our `luLink` component.\n\tget publicReactiveHref(): WritableSignal<string | null> {\n\t\treturn this.reactiveHref;\n\t}\n}\n","import { Location } from '@angular/common';\nimport { afterNextRender, booleanAttribute, ChangeDetectionStrategy, Component, effect, inject, Injector, input, ViewEncapsulation } from '@angular/core';\nimport { Router, UrlTree } from '@angular/router';\nimport { intlInputOptions } from '@lucca-front/ng/core';\nimport { LU_LINK_TRANSLATIONS } from './link.translate';\nimport { LuRouterLink } from './lu-router-link';\n\n@Component({\n\t// eslint-disable-next-line @angular-eslint/component-selector\n\tselector: 'a[luLink], button[luLink]',\n\tstandalone: true,\n\ttemplateUrl: './link.component.html',\n\tstyleUrl: './link.component.scss',\n\tencapsulation: ViewEncapsulation.None,\n\thost: {\n\t\tclass: 'link',\n\t\t'[attr.href]': 'routerLink.publicReactiveHref()',\n\t\t'[class.mod-decorationHover]': 'decorationHover()',\n\t\t'[class.mod-icon]': 'external()',\n\t\t'[class.is-disabled]': 'this.disabled()',\n\t\t'[attr.rel]': 'external() && !disabled() ? \"noopener noreferrer\" : null',\n\t\t'[attr.target]': 'external() && !disabled() ? \"_blank\" : null',\n\t\t'[attr.role]': 'disabled() ? \"presentation\" : null',\n\t\t'(click)': 'redirect()',\n\t},\n\thostDirectives: [\n\t\t{\n\t\t\tdirective: LuRouterLink,\n\t\t\tinputs: ['preserveFragment', 'skipLocationChange', 'replaceUrl', 'queryParams', 'fragment', 'queryParamsHandling', 'state', 'info', 'relativeTo'],\n\t\t},\n\t],\n\tchangeDetection: ChangeDetectionStrategy.OnPush,\n})\nexport class LinkComponent {\n\tintl = input(...intlInputOptions(LU_LINK_TRANSLATIONS));\n\trouterLink = inject(LuRouterLink);\n\t#injector = inject(Injector);\n\trouter = inject(Router);\n\tlocation = inject(Location);\n\n\t/**\n\t * Target page address. Use only for external links or pages not recognized by the router.\n\t */\n\treadonly luHref = input('', { alias: 'href' });\n\n\t/**\n\t * Target page address\n\t */\n\treadonly routerLinkCommands = input<LuRouterLink['routerLink'] | null>(null, { alias: 'luLink' });\n\n\t/**\n\t * Disables the link\n\t */\n\treadonly disabled = input(false, { transform: booleanAttribute });\n\n\t/**\n\t * Underlines the link only on hover\n\t */\n\treadonly decorationHover = input(false, { transform: booleanAttribute });\n\n\t/**\n\t * Indicates that the link will open in a new tab\n\t */\n\treadonly external = input(false, { transform: booleanAttribute });\n\n\threfBackup: string;\n\n\tconstructor() {\n\t\tconst href = this.luHref;\n\n\t\teffect(() => {\n\t\t\tif (href()) {\n\t\t\t\tthis.hrefBackup = href();\n\t\t\t\tthis.routerLink.publicReactiveHref.set(this.hrefBackup);\n\t\t\t}\n\t\t\tif (this.disabled()) {\n\t\t\t\tif (this.routerLinkCommands()) {\n\t\t\t\t\tthis.routerLink.routerLink = null;\n\t\t\t\t}\n\t\t\t\tthis.routerLink.publicReactiveHref.set(null);\n\t\t\t} else if (this.routerLinkCommands() && !this.external()) {\n\t\t\t\tthis.routerLink.routerLink = this.routerLinkCommands();\n\t\t\t\t// We need to do this in order to have `routerLink` update the value for `href`:\n\t\t\t\t// See https://github.com/angular/angular/blob/main/packages/router/src/directives/router_link.ts#L281\n\t\t\t\tthis.routerLink.ngOnChanges({});\n\t\t\t} else if (!href() && this.hrefBackup) {\n\t\t\t\tthis.routerLink.publicReactiveHref.set(this.hrefBackup);\n\t\t\t}\n\t\t});\n\t}\n\n\tredirect(): void {\n\t\tconst routerLinkCommands = this.routerLinkCommands();\n\t\tif (!this.disabled() && routerLinkCommands && this.external()) {\n\t\t\tconst urlTree =\n\t\t\t\trouterLinkCommands instanceof UrlTree\n\t\t\t\t\t? routerLinkCommands\n\t\t\t\t\t: this.router.createUrlTree(Array.isArray(routerLinkCommands) ? routerLinkCommands : [routerLinkCommands], {\n\t\t\t\t\t\t\tqueryParams: this.routerLink.queryParams,\n\t\t\t\t\t\t\tfragment: this.routerLink.fragment,\n\t\t\t\t\t\t\tqueryParamsHandling: this.routerLink.queryParamsHandling,\n\t\t\t\t\t\t\tpreserveFragment: this.routerLink.preserveFragment,\n\t\t\t\t\t\t});\n\t\t\tconst serializedUrl = this.router.serializeUrl(urlTree);\n\t\t\tconst externalUrl = Array.isArray(routerLinkCommands) ? this.location.prepareExternalUrl(serializedUrl) : serializedUrl;\n\t\t\tafterNextRender(() => window.open(externalUrl, '_blank'), { injector: this.#injector });\n\t\t}\n\t}\n}\n","<span class=\"link-text\"><ng-content /></span>\n@if (external()) {\n\t<span class=\"link-icon\">\n\t\t<span aria-hidden=\"true\" class=\"lucca-icon icon-arrowExternal\"></span>\n\t</span>\n\t<span class=\"pr-u-mask\">{{ intl().external }}</span>\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;;;;;;AAAO,MAAM,YAAY,GAAG;AAC3B,IAAA,EAAE,EAAE;AACH,QAAA,QAAQ,EAAE,yBAAyB;AACnC,KAAA;AACD,IAAA,EAAE,EAAE;AACH,QAAA,QAAQ,EAAE,kCAAkC;AAC5C,KAAA;AACD,IAAA,EAAE,EAAE;AACH,QAAA,QAAQ,EAAE,qCAAqC;AAC/C,KAAA;AACD,IAAA,EAAE,EAAE;AACH,QAAA,QAAQ,EAAE,iCAAiC;AAC3C,KAAA;AACD,IAAA,EAAE,EAAE;AACH,QAAA,QAAQ,EAAE,8BAA8B;AACxC,KAAA;AACD,IAAA,EAAE,EAAE;AACH,QAAA,QAAQ,EAAE,+BAA+B;AACzC,KAAA;AACD,IAAA,EAAE,EAAE;AACH,QAAA,QAAQ,EAAE,2BAA2B;AACrC,KAAA;CACD;;AClBM,MAAM,oBAAoB,GAAG,IAAI,cAAc,CAAC,oBAAoB,EAAE;AAC5E,IAAA,OAAO,EAAE,MAAM,kBAAkB;AACjC,CAAA,CAAC;AAMK,MAAM,kBAAkB,GAAiC,YAAY;;ACLtE,MAAO,YAAa,SAAQ,UAAU,CAAA;;IAE3C,WAAA,CAAY,MAAc,EAAE,KAAqB,EAAyB,iBAA4C,EAAE,QAAmB,EAAE,EAAc,EAAE,gBAAmC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