@masterteam/components 0.0.129 → 0.0.130
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.
|
@@ -62,7 +62,7 @@ class TruncateTooltip {
|
|
|
62
62
|
attributeFilter: ['class', 'style'],
|
|
63
63
|
});
|
|
64
64
|
}
|
|
65
|
-
this.
|
|
65
|
+
this.syncTooltip();
|
|
66
66
|
});
|
|
67
67
|
this.destroyRef.onDestroy(() => {
|
|
68
68
|
this.resizeObserver?.disconnect();
|
|
@@ -73,7 +73,7 @@ class TruncateTooltip {
|
|
|
73
73
|
});
|
|
74
74
|
}
|
|
75
75
|
syncTooltipState() {
|
|
76
|
-
this.
|
|
76
|
+
this.syncTooltip();
|
|
77
77
|
}
|
|
78
78
|
queueSync() {
|
|
79
79
|
if (this.syncTimeout !== null) {
|
|
@@ -89,12 +89,16 @@ class TruncateTooltip {
|
|
|
89
89
|
const text = element.textContent?.replace(/\s+/g, ' ').trim() ?? '';
|
|
90
90
|
const isTruncated = element.scrollWidth > element.clientWidth ||
|
|
91
91
|
element.scrollHeight > element.clientHeight;
|
|
92
|
+
const tooltipDisabled = !text || !isTruncated;
|
|
92
93
|
this.tooltip.content = text || undefined;
|
|
93
|
-
this.tooltip.
|
|
94
|
+
this.tooltip.setOption({
|
|
95
|
+
tooltipLabel: text || null,
|
|
96
|
+
disabled: tooltipDisabled,
|
|
97
|
+
});
|
|
94
98
|
if (!this.tooltip.active) {
|
|
95
99
|
return;
|
|
96
100
|
}
|
|
97
|
-
if (
|
|
101
|
+
if (tooltipDisabled) {
|
|
98
102
|
this.tooltip.hide();
|
|
99
103
|
return;
|
|
100
104
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"masterteam-components-tooltip.mjs","sources":["../../../../packages/masterteam/components/tooltip/tooltip.ts","../../../../packages/masterteam/components/tooltip/truncate-tooltip.ts","../../../../packages/masterteam/components/tooltip/masterteam-components-tooltip.ts"],"sourcesContent":["import { Directive } from '@angular/core';\r\nimport { Tooltip as PrimeTooltip } from 'primeng/tooltip';\r\n\r\n@Directive({\r\n selector: '[mtTooltip]',\r\n standalone: true,\r\n hostDirectives: [\r\n {\r\n directive: PrimeTooltip,\r\n inputs: [\r\n 'pTooltip: mtTooltip',\r\n 'tooltipPosition',\r\n 'tooltipEvent',\r\n 'appendTo',\r\n 'tooltipStyleClass',\r\n 'escape',\r\n 'showDelay',\r\n 'hideDelay',\r\n 'life',\r\n 'positionTop',\r\n 'positionLeft',\r\n 'autoHide',\r\n 'fitContent',\r\n 'hideOnEscape',\r\n 'tooltipDisabled',\r\n ],\r\n },\r\n ],\r\n})\r\nexport class Tooltip {}\r\n","import {\n AfterViewInit,\n DestroyRef,\n Directive,\n ElementRef,\n NgZone,\n inject,\n} from '@angular/core';\nimport { Tooltip as PrimeTooltip } from 'primeng/tooltip';\n\n@Directive({\n selector: '[mtTruncateTooltip]',\n host: {\n '(mouseenter)': 'syncTooltipState()',\n '(focusin)': 'syncTooltipState()',\n },\n hostDirectives: [\n {\n directive: PrimeTooltip,\n inputs: [\n 'tooltipPosition',\n 'tooltipEvent',\n 'appendTo',\n 'tooltipStyleClass',\n 'escape',\n 'showDelay',\n 'hideDelay',\n 'life',\n 'positionTop',\n 'positionLeft',\n 'autoHide',\n 'fitContent',\n 'hideOnEscape',\n ],\n },\n ],\n})\nexport class TruncateTooltip implements AfterViewInit {\n private readonly elementRef = inject<ElementRef<HTMLElement>>(ElementRef);\n private readonly zone = inject(NgZone);\n private readonly destroyRef = inject(DestroyRef);\n private readonly tooltip = inject(PrimeTooltip);\n\n private resizeObserver?: ResizeObserver;\n private mutationObserver?: MutationObserver;\n private syncTimeout: ReturnType<typeof setTimeout> | null = null;\n\n ngAfterViewInit(): void {\n this.zone.runOutsideAngular(() => {\n const element = this.elementRef.nativeElement;\n\n if (typeof ResizeObserver !== 'undefined') {\n this.resizeObserver = new ResizeObserver(() => this.queueSync());\n this.resizeObserver.observe(element);\n }\n\n if (typeof MutationObserver !== 'undefined') {\n this.mutationObserver = new MutationObserver(() => this.queueSync());\n this.mutationObserver.observe(element, {\n childList: true,\n characterData: true,\n subtree: true,\n attributes: true,\n attributeFilter: ['class', 'style'],\n });\n }\n\n this.
|
|
1
|
+
{"version":3,"file":"masterteam-components-tooltip.mjs","sources":["../../../../packages/masterteam/components/tooltip/tooltip.ts","../../../../packages/masterteam/components/tooltip/truncate-tooltip.ts","../../../../packages/masterteam/components/tooltip/masterteam-components-tooltip.ts"],"sourcesContent":["import { Directive } from '@angular/core';\r\nimport { Tooltip as PrimeTooltip } from 'primeng/tooltip';\r\n\r\n@Directive({\r\n selector: '[mtTooltip]',\r\n standalone: true,\r\n hostDirectives: [\r\n {\r\n directive: PrimeTooltip,\r\n inputs: [\r\n 'pTooltip: mtTooltip',\r\n 'tooltipPosition',\r\n 'tooltipEvent',\r\n 'appendTo',\r\n 'tooltipStyleClass',\r\n 'escape',\r\n 'showDelay',\r\n 'hideDelay',\r\n 'life',\r\n 'positionTop',\r\n 'positionLeft',\r\n 'autoHide',\r\n 'fitContent',\r\n 'hideOnEscape',\r\n 'tooltipDisabled',\r\n ],\r\n },\r\n ],\r\n})\r\nexport class Tooltip {}\r\n","import {\n AfterViewInit,\n DestroyRef,\n Directive,\n ElementRef,\n NgZone,\n inject,\n} from '@angular/core';\nimport { Tooltip as PrimeTooltip } from 'primeng/tooltip';\n\n@Directive({\n selector: '[mtTruncateTooltip]',\n host: {\n '(mouseenter)': 'syncTooltipState()',\n '(focusin)': 'syncTooltipState()',\n },\n hostDirectives: [\n {\n directive: PrimeTooltip,\n inputs: [\n 'tooltipPosition',\n 'tooltipEvent',\n 'appendTo',\n 'tooltipStyleClass',\n 'escape',\n 'showDelay',\n 'hideDelay',\n 'life',\n 'positionTop',\n 'positionLeft',\n 'autoHide',\n 'fitContent',\n 'hideOnEscape',\n ],\n },\n ],\n})\nexport class TruncateTooltip implements AfterViewInit {\n private readonly elementRef = inject<ElementRef<HTMLElement>>(ElementRef);\n private readonly zone = inject(NgZone);\n private readonly destroyRef = inject(DestroyRef);\n private readonly tooltip = inject(PrimeTooltip);\n\n private resizeObserver?: ResizeObserver;\n private mutationObserver?: MutationObserver;\n private syncTimeout: ReturnType<typeof setTimeout> | null = null;\n\n ngAfterViewInit(): void {\n this.zone.runOutsideAngular(() => {\n const element = this.elementRef.nativeElement;\n\n if (typeof ResizeObserver !== 'undefined') {\n this.resizeObserver = new ResizeObserver(() => this.queueSync());\n this.resizeObserver.observe(element);\n }\n\n if (typeof MutationObserver !== 'undefined') {\n this.mutationObserver = new MutationObserver(() => this.queueSync());\n this.mutationObserver.observe(element, {\n childList: true,\n characterData: true,\n subtree: true,\n attributes: true,\n attributeFilter: ['class', 'style'],\n });\n }\n\n this.syncTooltip();\n });\n\n this.destroyRef.onDestroy(() => {\n this.resizeObserver?.disconnect();\n this.mutationObserver?.disconnect();\n\n if (this.syncTimeout !== null) {\n clearTimeout(this.syncTimeout);\n }\n });\n }\n\n syncTooltipState(): void {\n this.syncTooltip();\n }\n\n private queueSync(): void {\n if (this.syncTimeout !== null) {\n return;\n }\n\n this.syncTimeout = setTimeout(() => {\n this.syncTimeout = null;\n this.syncTooltip();\n });\n }\n\n private syncTooltip(): void {\n const element = this.elementRef.nativeElement;\n const text = element.textContent?.replace(/\\s+/g, ' ').trim() ?? '';\n const isTruncated =\n element.scrollWidth > element.clientWidth ||\n element.scrollHeight > element.clientHeight;\n const tooltipDisabled = !text || !isTruncated;\n\n this.tooltip.content = text || undefined;\n this.tooltip.setOption({\n tooltipLabel: text || null,\n disabled: tooltipDisabled,\n });\n\n if (!this.tooltip.active) {\n return;\n }\n\n if (tooltipDisabled) {\n this.tooltip.hide();\n return;\n }\n\n this.tooltip.updateText();\n this.tooltip.align();\n }\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":["PrimeTooltip"],"mappings":";;;;;MA6Ba,OAAO,CAAA;uGAAP,OAAO,EAAA,IAAA,EAAA,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