@dev-tcloud/tcloud-ui 0.0.97 → 0.0.99
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/esm2020/lib/_directives/tooltip/tooltip.directive.mjs +74 -82
- package/fesm2015/dev-tcloud-tcloud-ui.mjs +76 -83
- package/fesm2015/dev-tcloud-tcloud-ui.mjs.map +1 -1
- package/fesm2020/dev-tcloud-tcloud-ui.mjs +75 -83
- package/fesm2020/dev-tcloud-tcloud-ui.mjs.map +1 -1
- package/lib/_directives/tooltip/tooltip.directive.d.ts +7 -23
- package/package.json +1 -1
- package/scss/components/custom/tooltip.scss +63 -74
- package/scss/tcloud/custom/buttons.scss +5 -2
|
@@ -4358,52 +4358,46 @@ class TCloudUiTooltipDirective {
|
|
|
4358
4358
|
constructor(el, renderer) {
|
|
4359
4359
|
this.el = el;
|
|
4360
4360
|
this.renderer = renderer;
|
|
4361
|
-
this._direction = 'top';
|
|
4362
|
-
// main
|
|
4363
|
-
this.el_height = 0;
|
|
4364
|
-
this.el_width = 0;
|
|
4365
|
-
this.el_center = 0;
|
|
4366
|
-
this.el_position = 0;
|
|
4367
|
-
// tooltip
|
|
4368
|
-
this.target_height = 0;
|
|
4369
|
-
this.target_width = 0;
|
|
4370
|
-
this.target_center = 0;
|
|
4371
|
-
this.ID = '';
|
|
4372
4361
|
this.info_text = '';
|
|
4362
|
+
this._direction = 'top';
|
|
4373
4363
|
}
|
|
4374
|
-
onMouseOver() {
|
|
4375
|
-
|
|
4376
|
-
|
|
4377
|
-
|
|
4378
|
-
|
|
4379
|
-
|
|
4380
|
-
|
|
4381
|
-
|
|
4382
|
-
|
|
4383
|
-
|
|
4384
|
-
|
|
4385
|
-
|
|
4386
|
-
|
|
4387
|
-
|
|
4388
|
-
|
|
4389
|
-
|
|
4390
|
-
|
|
4391
|
-
|
|
4392
|
-
|
|
4393
|
-
|
|
4394
|
-
|
|
4395
|
-
|
|
4396
|
-
|
|
4397
|
-
|
|
4398
|
-
|
|
4399
|
-
|
|
4400
|
-
|
|
4401
|
-
|
|
4364
|
+
onMouseOver(event) {
|
|
4365
|
+
const scrollTop = window.scrollY || window.pageYOffset;
|
|
4366
|
+
const tooltip = this.renderer.createElement('div');
|
|
4367
|
+
const rect = this.el.nativeElement?.getBoundingClientRect();
|
|
4368
|
+
const direction = this.el.nativeElement?.attributes['ng-reflect--t-cdirection']?.value || 'top';
|
|
4369
|
+
const el_position_x = (rect?.left) ? parseInt(rect?.left) : 0;
|
|
4370
|
+
const el_position_y = (rect?.top) ? parseInt(rect?.top + scrollTop) : 0;
|
|
4371
|
+
let width = 0;
|
|
4372
|
+
let height = 0;
|
|
4373
|
+
if (event && event.target) {
|
|
4374
|
+
const _event = event.target;
|
|
4375
|
+
height = _event.offsetHeight;
|
|
4376
|
+
width = _event.offsetWidth;
|
|
4377
|
+
}
|
|
4378
|
+
const top = `${(el_position_y - ((height / 2) + 10))}px`;
|
|
4379
|
+
const left = `${el_position_x + (width / 2)}px`;
|
|
4380
|
+
this.renderer.setStyle(tooltip, 'top', '0px');
|
|
4381
|
+
this.renderer.setStyle(tooltip, 'left', '0px');
|
|
4382
|
+
this.renderer.setStyle(tooltip, 'opacity', '0');
|
|
4383
|
+
this.renderer.addClass(tooltip, 'tc-directive-tooltip');
|
|
4384
|
+
this.renderer.addClass(tooltip, `tc-directive-tooltip-${direction}`);
|
|
4385
|
+
const id = this.generateID();
|
|
4386
|
+
this.renderer.setAttribute(tooltip, 'id', id);
|
|
4387
|
+
const textNode = this.renderer.createText(`${this.info_text}`);
|
|
4388
|
+
this.renderer.appendChild(tooltip, textNode);
|
|
4389
|
+
this.renderer.appendChild(document.body, tooltip);
|
|
4390
|
+
this.start_tooltip(id, height, width, el_position_x, el_position_y, direction);
|
|
4391
|
+
}
|
|
4392
|
+
onMouseOut(event) {
|
|
4393
|
+
const customDiv = document.querySelector('.tc-directive-tooltip');
|
|
4394
|
+
if (customDiv) {
|
|
4395
|
+
customDiv.remove();
|
|
4402
4396
|
}
|
|
4403
4397
|
}
|
|
4404
4398
|
set TCtooltip(tooltip) {
|
|
4405
4399
|
if (tooltip) {
|
|
4406
|
-
this.
|
|
4400
|
+
this.info_text = tooltip;
|
|
4407
4401
|
}
|
|
4408
4402
|
}
|
|
4409
4403
|
set TCdirection(direction) {
|
|
@@ -4411,51 +4405,49 @@ class TCloudUiTooltipDirective {
|
|
|
4411
4405
|
this._direction = direction;
|
|
4412
4406
|
}
|
|
4413
4407
|
}
|
|
4414
|
-
|
|
4415
|
-
|
|
4416
|
-
|
|
4417
|
-
return `tc-tooltip-${Math.floor(Math.random() * Math.floor(Math.random() * Date.now()))}`;
|
|
4418
|
-
}
|
|
4419
|
-
getElement() {
|
|
4420
|
-
return document.getElementById(this.ID) || undefined;
|
|
4421
|
-
}
|
|
4422
|
-
check(tooltip) {
|
|
4423
|
-
this.ID = this.generateID();
|
|
4424
|
-
this.info_text = tooltip;
|
|
4425
|
-
let el = this.el.nativeElement;
|
|
4426
|
-
this.main_el = el;
|
|
4427
|
-
if (el) {
|
|
4428
|
-
this.create_tooltip(tooltip, el);
|
|
4429
|
-
}
|
|
4430
|
-
else {
|
|
4431
|
-
console.log("TCL: tooltip -> el", this.el.nativeElement);
|
|
4432
|
-
}
|
|
4433
|
-
}
|
|
4434
|
-
create_tooltip(tip, el) {
|
|
4435
|
-
const tooltip = document.createElement("div");
|
|
4436
|
-
tooltip.setAttribute('id', this.ID);
|
|
4437
|
-
tooltip.innerHTML = tip;
|
|
4438
|
-
el.insertBefore(tooltip, null);
|
|
4439
|
-
}
|
|
4440
|
-
to_top(el) {
|
|
4441
|
-
const pos = this.el_center - (this.target_center);
|
|
4442
|
-
el.setAttribute('class', 'tc-directive-tooltip tc-directive-tooltip-top');
|
|
4408
|
+
generateID(target) {
|
|
4409
|
+
const ref = (target) ? `-${target}` : '';
|
|
4410
|
+
return `tc-tooltip-${Math.floor(Math.random() * Math.floor(Math.random() * Date.now()))}${ref}`;
|
|
4443
4411
|
}
|
|
4444
|
-
|
|
4445
|
-
|
|
4446
|
-
|
|
4447
|
-
|
|
4448
|
-
|
|
4449
|
-
|
|
4450
|
-
|
|
4451
|
-
|
|
4452
|
-
|
|
4453
|
-
|
|
4454
|
-
|
|
4412
|
+
start_tooltip(id, height, width, el_position_x, el_position_y, direction) {
|
|
4413
|
+
setTimeout(() => {
|
|
4414
|
+
const tooltip = document.getElementById(id);
|
|
4415
|
+
const tooltip_height = tooltip.clientHeight;
|
|
4416
|
+
const tooltip_width = tooltip.clientWidth;
|
|
4417
|
+
/*
|
|
4418
|
+
console.log('altura do target: ', height);
|
|
4419
|
+
console.log('largura do target: ', width);
|
|
4420
|
+
console.log('el_position_x do target: ', el_position_x);
|
|
4421
|
+
console.log('el_position_y do target: ', el_position_y);
|
|
4422
|
+
console.log('direction do tooltip: ', direction);
|
|
4423
|
+
*/
|
|
4424
|
+
let p_y = 0;
|
|
4425
|
+
let p_x = 0;
|
|
4426
|
+
const center_position = (el_position_x + (width / 2)) - (tooltip_width / 2);
|
|
4427
|
+
if (direction === 'top') {
|
|
4428
|
+
p_y = (el_position_y - tooltip_height) - 15;
|
|
4429
|
+
p_x = center_position;
|
|
4430
|
+
}
|
|
4431
|
+
if (direction === 'bottom') {
|
|
4432
|
+
p_y = (el_position_y + height) + 15;
|
|
4433
|
+
p_x = center_position;
|
|
4434
|
+
}
|
|
4435
|
+
if (direction === 'left') {
|
|
4436
|
+
p_y = el_position_y - (tooltip_height / 2) + (height / 2);
|
|
4437
|
+
p_x = center_position - tooltip_width / 2 - width / 2 - 15;
|
|
4438
|
+
}
|
|
4439
|
+
if (direction === 'right') {
|
|
4440
|
+
p_y = el_position_y - (tooltip_height / 2) + (height / 2);
|
|
4441
|
+
p_x = center_position + tooltip_width / 2 + width / 2 + 15;
|
|
4442
|
+
}
|
|
4443
|
+
this.renderer.setStyle(tooltip, 'top', `${p_y}px`);
|
|
4444
|
+
this.renderer.setStyle(tooltip, 'left', `${p_x}px`);
|
|
4445
|
+
this.renderer.addClass(tooltip, 'tc-tooltip-fade-in');
|
|
4446
|
+
});
|
|
4455
4447
|
}
|
|
4456
4448
|
}
|
|
4457
4449
|
TCloudUiTooltipDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: TCloudUiTooltipDirective, deps: [{ token: i0.ElementRef }, { token: i0.Renderer2 }], target: i0.ɵɵFactoryTarget.Directive });
|
|
4458
|
-
TCloudUiTooltipDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "14.2.12", type: TCloudUiTooltipDirective, selector: "[TCtooltip]", inputs: { TCtooltip: "TCtooltip", TCdirection: "TCdirection" }, host: { listeners: { "mouseover": "onMouseOver()", "mouseout": "onMouseOut()" } }, ngImport: i0 });
|
|
4450
|
+
TCloudUiTooltipDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "14.2.12", type: TCloudUiTooltipDirective, selector: "[TCtooltip]", inputs: { TCtooltip: "TCtooltip", TCdirection: "TCdirection" }, host: { listeners: { "mouseover": "onMouseOver($event)", "mouseout": "onMouseOut($event)" } }, ngImport: i0 });
|
|
4459
4451
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: TCloudUiTooltipDirective, decorators: [{
|
|
4460
4452
|
type: Directive,
|
|
4461
4453
|
args: [{
|
|
@@ -4463,10 +4455,10 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.12", ngImpo
|
|
|
4463
4455
|
}]
|
|
4464
4456
|
}], ctorParameters: function () { return [{ type: i0.ElementRef }, { type: i0.Renderer2 }]; }, propDecorators: { onMouseOver: [{
|
|
4465
4457
|
type: HostListener,
|
|
4466
|
-
args: ['mouseover']
|
|
4458
|
+
args: ['mouseover', ['$event']]
|
|
4467
4459
|
}], onMouseOut: [{
|
|
4468
4460
|
type: HostListener,
|
|
4469
|
-
args: ['mouseout']
|
|
4461
|
+
args: ['mouseout', ['$event']]
|
|
4470
4462
|
}], TCtooltip: [{
|
|
4471
4463
|
type: Input
|
|
4472
4464
|
}], TCdirection: [{
|