Skip to content

Commit

Permalink
fix(plex): fixes en componentes para version 8.0.5 (#346)
Browse files Browse the repository at this point in the history
  • Loading branch information
ma7payne authored Oct 18, 2024
1 parent 330eead commit 6a8f9f5
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 5 deletions.
3 changes: 2 additions & 1 deletion src/demo/app/home/home.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ export class HomeDemoComponent implements OnInit {
public data = [];
documento = '45979360';

public modelSelector;

constructor(
public plex: Plex,
private ref: ChangeDetectorRef,
Expand All @@ -23,7 +25,6 @@ export class HomeDemoComponent implements OnInit {

ngOnInit() {
this.ref.detectChanges();

}

openVisualizador() {
Expand Down
34 changes: 30 additions & 4 deletions src/lib/hint/hint.component.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { MatTooltip } from '@angular/material/tooltip';
import { Component, OnInit, Input, HostListener, ViewChild, ElementRef } from '@angular/core';
import { Component, OnInit, Input, HostListener, ViewChild, ElementRef, AfterViewInit } from '@angular/core';
import { PlexType } from '../core/plex-type.type';

@Component({
Expand All @@ -11,7 +11,7 @@ import { PlexType } from '../core/plex-type.type';
</span>
`
})
export class HintComponent implements OnInit {
export class HintComponent implements OnInit, AfterViewInit {

@Input()
hostElement: HTMLElement;
Expand All @@ -31,14 +31,40 @@ export class HintComponent implements OnInit {
@Input()
detach: '' | 'both' | 'right' | 'top';

constructor() { }

@ViewChild('matTooltip', { static: false }) matTooltip: MatTooltip;

constructor() { }

ngOnInit() {
this.position = 'above';
}

ngAfterViewInit() {
this.adjustIfLabel();
}

adjustIfLabel() {
setTimeout(() => {
const labelElement = this.hostElement.querySelector('label');

if (labelElement !== null) {
labelElement.style.display = 'inline';

const label = labelElement.getBoundingClientRect();

const hintElement = this.hostElement.nextElementSibling as HTMLElement;
const hint = hintElement.getBoundingClientRect();

hintElement.style.position = 'relative';
hintElement.style.top = -label.height - 2 * hint.height + 'px';

const adjustX = this.hostElement.getAttribute('required') === 'true' ? 10 : 0;

hintElement.style.left = label.width + hint.width + adjustX + 'px';
}
}, 100);
}

showTooltip() {
this.matTooltip.show(0);
}
Expand Down

0 comments on commit 6a8f9f5

Please sign in to comment.