{"version":3,"file":"lucca-front-ng-read-more.mjs","sources":["../../../packages/ng/read-more/translations.ts","../../../packages/ng/read-more/read-more.translate.ts","../../../packages/ng/read-more/read-more.component.ts","../../../packages/ng/read-more/read-more.component.html","../../../packages/ng/read-more/lucca-front-ng-read-more.ts"],"sourcesContent":["export const Translations = {\n\tfr: {\n\t\treadMore: 'Lire plus',\n\t\treadLess: 'Lire moins',\n\t},\n\tpt: {\n\t\treadMore: 'Ler mais',\n\t\treadLess: 'Ler menos',\n\t},\n\tes: {\n\t\treadMore: 'Leer más',\n\t\treadLess: 'Leer menos',\n\t},\n\t'nl-BE': {\n\t\treadMore: 'Meer lezen',\n\t\treadLess: 'Minder lezen',\n\t},\n\tnl: {\n\t\treadMore: 'Meer lezen',\n\t\treadLess: 'Minder lezen',\n\t},\n\tit: {\n\t\treadMore: 'Mostra di più',\n\t\treadLess: 'Mostra di meno',\n\t},\n\tde: {\n\t\treadMore: 'Mehr lesen',\n\t\treadLess: 'Weniger lesen',\n\t},\n\ten: {\n\t\treadMore: 'Read more',\n\t\treadLess: 'Read less',\n\t},\n};\n","import { InjectionToken } from '@angular/core';\nimport { LuTranslation } from '@lucca-front/ng/core';\nimport { Translations } from './translations';\n\nexport const LU_READMORE_TRANSLATIONS = new InjectionToken('luReadMoreTranslations', {\n\tfactory: () => luReadMoreTranslations,\n});\n\nexport interface ReadMoreTranslate {\n\treadMore: string;\n\treadLess: string;\n}\n\nexport const luReadMoreTranslations: LuTranslation<ReadMoreTranslate> = Translations;\n","import { afterNextRender, booleanAttribute, ChangeDetectionStrategy, Component, computed, DestroyRef, ElementRef, inject, input, signal, viewChild, ViewEncapsulation } from '@angular/core';\nimport { intlInputOptions, isNil } from '@lucca-front/ng/core';\nimport { LU_READMORE_TRANSLATIONS } from './read-more.translate';\n\n@Component({\n\tselector: 'lu-read-more',\n\ttemplateUrl: './read-more.component.html',\n\tstyleUrl: './read-more.component.scss',\n\tencapsulation: ViewEncapsulation.None,\n\tchangeDetection: ChangeDetectionStrategy.OnPush,\n\thost: {\n\t\tclass: 'readMore',\n\t\t'[style.--components-readMore-lineClamp]': 'lineClamp()',\n\t\t'[style.--components-readMore-content-lastChild-content]': '`\"${labelReadLess()}\"`',\n\t\t'[class.is-disabled]': '!expanded() && !isClamped()',\n\t\t'[class.mod-openOnly]': 'openOnly()',\n\t\t'[class.mod-sunken]': 'surface() === `sunken`',\n\t\t'[class.mod-default]': 'surface() === `default`',\n\t\t'[style.--components-readMore-link-backgroudColor]': 'backgroundColor()',\n\t},\n})\nexport class ReadMoreComponent {\n\tintl = input(...intlInputOptions(LU_READMORE_TRANSLATIONS));\n\n\t/**\n\t * Change the number of lines displayed when collapsed\n\t */\n\treadonly lineClamp = input<number>(5);\n\n\t/**\n\t * Prevent the component from closing by hiding the \"Read less\" button\n\t */\n\treadonly openOnly = input(false, { transform: booleanAttribute });\n\n\t/**\n\t * Change the background color under the \"Read more / less\" button\n\t */\n\treadonly textFlow = input(false, { transform: booleanAttribute });\n\n\t/**\n\t * Apply the spacing of the Text Flow component\n\t */\n\treadonly surface = input<null | 'sunken' | 'default' | string>(null);\n\n\t/**\n\t * Allow content to be passed via innerHTML\n\t */\n\treadonly innerContent = input<null | string>(null);\n\n\tlabelReadMore = computed(() => this.intl().readMore);\n\tlabelReadLess = computed(() => this.intl().readLess);\n\n\tlabel = computed(() => (this.expanded() ? this.labelReadLess() : this.labelReadMore()));\n\n\treadonly contentRef = viewChild<ElementRef<HTMLDivElement>>('content');\n\n\texpanded = signal(false);\n\tisClamped = signal(false);\n\n\treadonly backgroundColor = computed(() => {\n\t\tif (this.surface() === 'sunken' || this.surface() === 'default' || this.surface() === null) {\n\t\t\treturn null;\n\t\t}\n\t\treturn `${this.surface()}`;\n\t});\n\n\treadonly isInnerContentNil = computed(() => isNil(this.innerContent()));\n\n\tconstructor() {\n\t\tconst destroyRef = inject(DestroyRef);\n\n\t\tafterNextRender(() => {\n\t\t\tconst content = this.contentRef();\n\n\t\t\tif (!content) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tconst observer = new ResizeObserver(() => {\n\t\t\t\tconst contentElement = this.contentRef()?.nativeElement;\n\n\t\t\t\tif (!contentElement) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tconst lineHeight = parseFloat(window.getComputedStyle(contentElement).lineHeight);\n\t\t\t\tconst totalLines = Math.round(contentElement.scrollHeight / lineHeight);\n\n\t\t\t\tthis.isClamped.set(contentElement.scrollHeight > contentElement.clientHeight);\n\n\t\t\t\tif (!this.isClamped() && totalLines <= this.lineClamp()) {\n\t\t\t\t\tthis.expanded.set(false);\n\t\t\t\t}\n\t\t\t});\n\n\t\t\tobserver.observe(content.nativeElement);\n\t\t\tdestroyRef.onDestroy(() => observer.disconnect());\n\t\t});\n\t}\n\n\ttoggleExpanded() {\n\t\tthis.expanded.set(!this.expanded());\n\t}\n}\n","<button\n\ttype=\"button\"\n\taria-hidden=\"true\"\n\t[attr.tabindex]=\"isClamped() ? null : '-1'\"\n\t[attr.aria-expanded]=\"expanded()\"\n\tclass=\"readMore-link link\"\n\t(click)=\"toggleExpanded()\"\n>\n\t{{ label() }}\n</button>\n@if (isInnerContentNil()) {\n\t<div class=\"readMore-content\" [class.textFlow]=\"textFlow()\" #content>\n\t\t<ng-content />\n\t</div>\n} @else {\n\t<div class=\"readMore-content\" [class.textFlow]=\"textFlow()\" [innerHTML]=\"innerContent()\" #content></div>\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,WAAW;AACrB,QAAA,QAAQ,EAAE,YAAY;AACtB,KAAA;AACD,IAAA,EAAE,EAAE;AACH,QAAA,QAAQ,EAAE,UAAU;AACpB,QAAA,QAAQ,EAAE,WAAW;AACrB,KAAA;AACD,IAAA,EAAE,EAAE;AACH,QAAA,QAAQ,EAAE,UAAU;AACpB,QAAA,QA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