{ "version": 3, "sources": ["src/app/settings/_components/setting-item/setting-item.component.ts", "src/app/settings/_components/setting-item/setting-item.component.html"], "sourcesContent": ["import {\n ChangeDetectionStrategy,\n ChangeDetectorRef,\n Component,\n ContentChild, ElementRef, EventEmitter, HostListener,\n inject,\n Input, OnChanges, Output, SimpleChange, SimpleChanges,\n TemplateRef\n} from '@angular/core';\nimport {TranslocoDirective} from \"@jsverse/transloco\";\nimport {NgTemplateOutlet} from \"@angular/common\";\nimport {SafeHtmlPipe} from \"../../../_pipes/safe-html.pipe\";\nimport {filter, fromEvent, tap} from \"rxjs\";\nimport {AbstractControl} from \"@angular/forms\";\n\n@Component({\n selector: 'app-setting-item',\n standalone: true,\n imports: [\n TranslocoDirective,\n NgTemplateOutlet,\n SafeHtmlPipe\n ],\n templateUrl: './setting-item.component.html',\n styleUrl: './setting-item.component.scss',\n changeDetection: ChangeDetectionStrategy.OnPush\n})\nexport class SettingItemComponent implements OnChanges {\n\n private readonly cdRef = inject(ChangeDetectorRef);\n\n @Input({required:true}) title: string = '';\n @Input() editLabel: string | undefined = undefined;\n @Input() canEdit: boolean = true;\n @Input() showEdit: boolean = true;\n @Input() isEditMode: boolean = false;\n @Input() subtitle: string | undefined = undefined;\n @Input() labelId: string | undefined = undefined;\n @Input() toggleOnViewClick: boolean = true;\n /**\n * When true, the hover animation will not be present and the titleExtras will be always visible\n */\n @Input() fixedExtras: boolean = false;\n @Input() control: AbstractControl | null = null;\n @Output() editMode = new EventEmitter();\n\n /**\n * Extra information to show next to the title\n */\n @ContentChild('titleExtra') titleExtraRef!: TemplateRef;\n /**\n * View in View mode\n */\n @ContentChild('view') valueViewRef!: TemplateRef;\n /**\n * View in Edit mode\n */\n @ContentChild('edit') valueEditRef!: TemplateRef;\n /**\n * Extra button controls to show instead of Edit\n */\n @ContentChild('titleActions') titleActionsRef!: TemplateRef;\n\n @HostListener('click', ['$event'])\n onClickInside(event: MouseEvent) {\n event.stopPropagation(); // Prevent the click from bubbling up\n }\n\n constructor(elementRef: ElementRef) {\n if (!this.toggleOnViewClick) return;\n\n fromEvent(window, 'click')\n .pipe(\n filter((event: Event) => {\n if (!this.toggleOnViewClick) return false;\n if (this.control != null && this.control.invalid) return false;\n\n const mouseEvent = event as MouseEvent;\n const selection = window.getSelection();\n const hasSelection = selection !== null && selection.toString().trim() === '';\n return !elementRef.nativeElement.contains(mouseEvent.target) && hasSelection;\n }),\n tap(() => {\n this.isEditMode = false;\n this.editMode.emit(this.isEditMode);\n this.cdRef.markForCheck();\n })\n )\n .subscribe();\n }\n\n ngOnChanges(changes: SimpleChanges) {\n if (changes.hasOwnProperty('isEditMode')) {\n const change = changes.isEditMode as SimpleChange;\n if (change.isFirstChange()) return;\n\n if (!this.toggleOnViewClick) return;\n if (!this.canEdit) return;\n if (this.control != null && this.control.invalid) return;\n\n console.log('isEditMode', this.isEditMode, 'currentValue', change.currentValue);\n this.isEditMode = change.currentValue;\n //this.editMode.emit(this.isEditMode);\n this.cdRef.markForCheck();\n\n }\n }\n\n toggleEditMode() {\n\n if (!this.toggleOnViewClick) return;\n if (!this.canEdit) return;\n if (this.control != null && this.control.invalid) return;\n\n this.isEditMode = !this.isEditMode;\n this.editMode.emit(this.isEditMode);\n this.cdRef.markForCheck();\n }\n\n}\n", "\n
\n
\n
\n
\n @if (labelId) {\n \n } @else {\n {{title}}\n }\n @if (titleExtraRef) {\n \n }\n
\n
\n
\n @if (showEdit) {\n \n }\n @if (titleActionsRef) {\n \n }\n
\n
\n\n @if (isEditMode) {\n \n } @else {\n \n \n \n }\n\n @if (subtitle) {\n
\n }\n
\n
\n"], "mappings": "8cCMYA,EAAA,EAAA,QAAA,CAAA,EAA2CC,EAAA,CAAA,EAASC,EAAA,mBAAzBC,EAAA,MAAAC,EAAAC,OAAA,EAAgBC,EAAA,EAAAC,EAAAH,EAAAI,KAAA,2BAE3CP,EAAA,CAAA,kBAAAQ,EAAA,IAAAL,EAAAI,MAAA,GAAA,2BAGAE,EAAA,EAAA,CAAA,kBAA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AAA,SAMHrD,CAAoB,GAAA", "names": ["\u0275\u0275elementStart", "\u0275\u0275text", "\u0275\u0275elementEnd", "\u0275\u0275property", "ctx_r0", "labelId", "\u0275\u0275advance", "\u0275\u0275textInterpolate", "title", "\u0275\u0275textInterpolate1", "\u0275\u0275elementContainer", "titleExtraRef", "\u0275\u0275listener", "\u0275\u0275restoreView", "_r2", "\u0275\u0275nextContext", "\u0275\u0275resetView", "toggleEditMode", "canEdit", "isEditMode", "t_r3", "editLabel", "titleActionsRef", "valueEditRef", "_r4", "valueViewRef", "\u0275\u0275element", "\u0275\u0275pipeBind1", "subtitle", "\u0275\u0275sanitizeHtml", "\u0275\u0275elementContainerStart", "\u0275\u0275template", "SettingItemComponent_ng_container_0_Conditional_5_Template", "SettingItemComponent_ng_container_0_Conditional_6_Template", "SettingItemComponent_ng_container_0_Conditional_7_Template", "SettingItemComponent_ng_container_0_Conditional_9_Template", "SettingItemComponent_ng_container_0_Conditional_10_Template", "SettingItemComponent_ng_container_0_Conditional_11_Template", "SettingItemComponent_ng_container_0_Conditional_12_Template", "SettingItemComponent_ng_container_0_Conditional_13_Template", "\u0275\u0275classMapInterpolate1", "fixedExtras", "\u0275\u0275conditional", "showEdit", "SettingItemComponent", "onClickInside", "event", "stopPropagation", "constructor", "elementRef", "cdRef", "inject", "ChangeDetectorRef", "undefined", "toggleOnViewClick", "control", "editMode", "EventEmitter", "fromEvent", "window", "pipe", "filter", "invalid", "mouseEvent", "selection", "getSelection", "hasSelection", "toString", "trim", "nativeElement", "contains", "target", "tap", "emit", "markForCheck", "subscribe", "ngOnChanges", "changes", "hasOwnProperty", "change", "isFirstChange", "console", "log", "currentValue", "\u0275\u0275directiveInject", "ElementRef", "selectors", "contentQueries", "rf", "ctx", "dirIndex", "$event", "SettingItemComponent_ng_container_0_Template", "TranslocoDirective", "NgTemplateOutlet", "SafeHtmlPipe", "styles", "changeDetection"] }