@nanahoshi/mona-ui 0.1.0
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/README.md +25 -0
- package/fesm2022/nanahoshi-mona-ui-auto-complete.mjs +590 -0
- package/fesm2022/nanahoshi-mona-ui-avatar.mjs +168 -0
- package/fesm2022/nanahoshi-mona-ui-breadcrumb.mjs +220 -0
- package/fesm2022/nanahoshi-mona-ui-button-group.mjs +225 -0
- package/fesm2022/nanahoshi-mona-ui-button.mjs +497 -0
- package/fesm2022/nanahoshi-mona-ui-calendar.mjs +1569 -0
- package/fesm2022/nanahoshi-mona-ui-check-box.mjs +339 -0
- package/fesm2022/nanahoshi-mona-ui-chip.mjs +453 -0
- package/fesm2022/nanahoshi-mona-ui-circular-progress-bar.mjs +200 -0
- package/fesm2022/nanahoshi-mona-ui-color-gradient.mjs +853 -0
- package/fesm2022/nanahoshi-mona-ui-color-palette.mjs +923 -0
- package/fesm2022/nanahoshi-mona-ui-color-picker.mjs +495 -0
- package/fesm2022/nanahoshi-mona-ui-combo-box.mjs +686 -0
- package/fesm2022/nanahoshi-mona-ui-common.mjs +642 -0
- package/fesm2022/nanahoshi-mona-ui-contextmenu.mjs +485 -0
- package/fesm2022/nanahoshi-mona-ui-date-input.mjs +132 -0
- package/fesm2022/nanahoshi-mona-ui-date-picker.mjs +460 -0
- package/fesm2022/nanahoshi-mona-ui-datetime-picker.mjs +659 -0
- package/fesm2022/nanahoshi-mona-ui-dialog.mjs +828 -0
- package/fesm2022/nanahoshi-mona-ui-dropdown-button.mjs +523 -0
- package/fesm2022/nanahoshi-mona-ui-dropdown-list.mjs +615 -0
- package/fesm2022/nanahoshi-mona-ui-dropdowns.mjs +701 -0
- package/fesm2022/nanahoshi-mona-ui-editor.mjs +1400 -0
- package/fesm2022/nanahoshi-mona-ui-expansion-panel.mjs +245 -0
- package/fesm2022/nanahoshi-mona-ui-fieldset.mjs +170 -0
- package/fesm2022/nanahoshi-mona-ui-filter.mjs +680 -0
- package/fesm2022/nanahoshi-mona-ui-grid-grid-footer-cell.component-B9SQH5N-.mjs +105 -0
- package/fesm2022/nanahoshi-mona-ui-grid-grid-footer-table-cell.directive-DlLwcCFT.mjs +42 -0
- package/fesm2022/nanahoshi-mona-ui-grid-grid-list.component-Dgea-O0X.mjs +130 -0
- package/fesm2022/nanahoshi-mona-ui-grid-grid-toggle.component-DIUutx9s.mjs +773 -0
- package/fesm2022/nanahoshi-mona-ui-grid-grid-virtual-list.component-DRHycGIh.mjs +240 -0
- package/fesm2022/nanahoshi-mona-ui-grid-nanahoshi-mona-ui-grid-C3eZIaJK.mjs +5374 -0
- package/fesm2022/nanahoshi-mona-ui-grid.mjs +2 -0
- package/fesm2022/nanahoshi-mona-ui-internal-filter-input.mjs +87 -0
- package/fesm2022/nanahoshi-mona-ui-internal-indicator-icon.mjs +154 -0
- package/fesm2022/nanahoshi-mona-ui-internal-list.mjs +1356 -0
- package/fesm2022/nanahoshi-mona-ui-internal-tree.mjs +2263 -0
- package/fesm2022/nanahoshi-mona-ui-internal.mjs +379 -0
- package/fesm2022/nanahoshi-mona-ui-list-box.mjs +630 -0
- package/fesm2022/nanahoshi-mona-ui-list-view.mjs +527 -0
- package/fesm2022/nanahoshi-mona-ui-list.mjs +4 -0
- package/fesm2022/nanahoshi-mona-ui-menubar.mjs +966 -0
- package/fesm2022/nanahoshi-mona-ui-multi-select.mjs +641 -0
- package/fesm2022/nanahoshi-mona-ui-notification.mjs +536 -0
- package/fesm2022/nanahoshi-mona-ui-numeric-text-box.mjs +597 -0
- package/fesm2022/nanahoshi-mona-ui-pager.mjs +790 -0
- package/fesm2022/nanahoshi-mona-ui-placeholder.mjs +83 -0
- package/fesm2022/nanahoshi-mona-ui-popover.mjs +325 -0
- package/fesm2022/nanahoshi-mona-ui-popup-menu.mjs +1559 -0
- package/fesm2022/nanahoshi-mona-ui-popup.mjs +1321 -0
- package/fesm2022/nanahoshi-mona-ui-progress-bar.mjs +294 -0
- package/fesm2022/nanahoshi-mona-ui-query.mjs +175 -0
- package/fesm2022/nanahoshi-mona-ui-radio-button.mjs +339 -0
- package/fesm2022/nanahoshi-mona-ui-scroll-view.mjs +565 -0
- package/fesm2022/nanahoshi-mona-ui-slider.mjs +1049 -0
- package/fesm2022/nanahoshi-mona-ui-split-button.mjs +636 -0
- package/fesm2022/nanahoshi-mona-ui-splitter.mjs +843 -0
- package/fesm2022/nanahoshi-mona-ui-stepper.mjs +537 -0
- package/fesm2022/nanahoshi-mona-ui-switch.mjs +308 -0
- package/fesm2022/nanahoshi-mona-ui-tabs.mjs +664 -0
- package/fesm2022/nanahoshi-mona-ui-text-area.mjs +111 -0
- package/fesm2022/nanahoshi-mona-ui-text-box.mjs +369 -0
- package/fesm2022/nanahoshi-mona-ui-theme.mjs +314 -0
- package/fesm2022/nanahoshi-mona-ui-time-picker.mjs +450 -0
- package/fesm2022/nanahoshi-mona-ui-time-selector.mjs +723 -0
- package/fesm2022/nanahoshi-mona-ui-tooltip.mjs +716 -0
- package/fesm2022/nanahoshi-mona-ui-tree-view.mjs +733 -0
- package/fesm2022/nanahoshi-mona-ui-window.mjs +1329 -0
- package/fesm2022/nanahoshi-mona-ui.mjs +9 -0
- package/package.json +289 -0
- package/types/nanahoshi-mona-ui-auto-complete.d.ts +223 -0
- package/types/nanahoshi-mona-ui-avatar.d.ts +642 -0
- package/types/nanahoshi-mona-ui-breadcrumb.d.ts +70 -0
- package/types/nanahoshi-mona-ui-button-group.d.ts +77 -0
- package/types/nanahoshi-mona-ui-button.d.ts +111 -0
- package/types/nanahoshi-mona-ui-calendar.d.ts +262 -0
- package/types/nanahoshi-mona-ui-check-box.d.ts +133 -0
- package/types/nanahoshi-mona-ui-chip.d.ts +130 -0
- package/types/nanahoshi-mona-ui-circular-progress-bar.d.ts +113 -0
- package/types/nanahoshi-mona-ui-color-gradient.d.ts +201 -0
- package/types/nanahoshi-mona-ui-color-palette.d.ts +102 -0
- package/types/nanahoshi-mona-ui-color-picker.d.ts +156 -0
- package/types/nanahoshi-mona-ui-combo-box.d.ts +232 -0
- package/types/nanahoshi-mona-ui-common.d.ts +386 -0
- package/types/nanahoshi-mona-ui-contextmenu.d.ts +129 -0
- package/types/nanahoshi-mona-ui-date-input.d.ts +60 -0
- package/types/nanahoshi-mona-ui-date-picker.d.ts +177 -0
- package/types/nanahoshi-mona-ui-datetime-picker.d.ts +199 -0
- package/types/nanahoshi-mona-ui-dialog.d.ts +261 -0
- package/types/nanahoshi-mona-ui-dropdown-button.d.ts +159 -0
- package/types/nanahoshi-mona-ui-dropdown-list.d.ts +219 -0
- package/types/nanahoshi-mona-ui-dropdowns.d.ts +176 -0
- package/types/nanahoshi-mona-ui-editor.d.ts +113 -0
- package/types/nanahoshi-mona-ui-expansion-panel.d.ts +87 -0
- package/types/nanahoshi-mona-ui-fieldset.d.ts +68 -0
- package/types/nanahoshi-mona-ui-filter.d.ts +115 -0
- package/types/nanahoshi-mona-ui-grid.d.ts +1114 -0
- package/types/nanahoshi-mona-ui-internal-filter-input.d.ts +25 -0
- package/types/nanahoshi-mona-ui-internal-indicator-icon.d.ts +28 -0
- package/types/nanahoshi-mona-ui-internal-list.d.ts +269 -0
- package/types/nanahoshi-mona-ui-internal-tree.d.ts +391 -0
- package/types/nanahoshi-mona-ui-internal.d.ts +136 -0
- package/types/nanahoshi-mona-ui-list-box.d.ts +225 -0
- package/types/nanahoshi-mona-ui-list-view.d.ts +188 -0
- package/types/nanahoshi-mona-ui-list.d.ts +1 -0
- package/types/nanahoshi-mona-ui-menubar.d.ts +198 -0
- package/types/nanahoshi-mona-ui-multi-select.d.ts +247 -0
- package/types/nanahoshi-mona-ui-notification.d.ts +106 -0
- package/types/nanahoshi-mona-ui-numeric-text-box.d.ts +161 -0
- package/types/nanahoshi-mona-ui-pager.d.ts +238 -0
- package/types/nanahoshi-mona-ui-placeholder.d.ts +35 -0
- package/types/nanahoshi-mona-ui-popover.d.ts +130 -0
- package/types/nanahoshi-mona-ui-popup-menu.d.ts +412 -0
- package/types/nanahoshi-mona-ui-popup.d.ts +485 -0
- package/types/nanahoshi-mona-ui-progress-bar.d.ts +139 -0
- package/types/nanahoshi-mona-ui-query.d.ts +89 -0
- package/types/nanahoshi-mona-ui-radio-button.d.ts +128 -0
- package/types/nanahoshi-mona-ui-scroll-view.d.ts +166 -0
- package/types/nanahoshi-mona-ui-slider.d.ts +305 -0
- package/types/nanahoshi-mona-ui-split-button.d.ts +182 -0
- package/types/nanahoshi-mona-ui-splitter.d.ts +70 -0
- package/types/nanahoshi-mona-ui-stepper.d.ts +173 -0
- package/types/nanahoshi-mona-ui-switch.d.ts +125 -0
- package/types/nanahoshi-mona-ui-tabs.d.ts +158 -0
- package/types/nanahoshi-mona-ui-text-area.d.ts +42 -0
- package/types/nanahoshi-mona-ui-text-box.d.ts +164 -0
- package/types/nanahoshi-mona-ui-theme.d.ts +23 -0
- package/types/nanahoshi-mona-ui-time-picker.d.ts +184 -0
- package/types/nanahoshi-mona-ui-time-selector.d.ts +143 -0
- package/types/nanahoshi-mona-ui-tooltip.d.ts +130 -0
- package/types/nanahoshi-mona-ui-tree-view.d.ts +274 -0
- package/types/nanahoshi-mona-ui-window.d.ts +295 -0
- package/types/nanahoshi-mona-ui.d.ts +2 -0
|
@@ -0,0 +1,716 @@
|
|
|
1
|
+
import { DOCUMENT } from '@angular/common';
|
|
2
|
+
import * as i0 from '@angular/core';
|
|
3
|
+
import { inject, DestroyRef, Renderer2, computed, linkedSignal, viewChild, TemplateRef, input, output, afterRenderEffect, Component, ElementRef, EnvironmentInjector, signal, createComponent, Directive, ChangeDetectionStrategy } from '@angular/core';
|
|
4
|
+
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
|
|
5
|
+
import { createElementControlId } from '@nanahoshi/mona-ui/internal';
|
|
6
|
+
import { PopupService, fadePopupAnimation } from '@nanahoshi/mona-ui/popup';
|
|
7
|
+
import { ThemeService } from '@nanahoshi/mona-ui/theme';
|
|
8
|
+
import { take, takeUntil, Subscription, fromEvent, tap } from 'rxjs';
|
|
9
|
+
import { cva } from 'class-variance-authority';
|
|
10
|
+
import { twMerge } from 'tailwind-merge';
|
|
11
|
+
|
|
12
|
+
const tooltipBaseVariants = cva(`
|
|
13
|
+
flex items-center justify-center relative
|
|
14
|
+
bg-background border border-border
|
|
15
|
+
shadow-[0_2px_8px_rgba(0,0,0,0.12)] z-1
|
|
16
|
+
`, {
|
|
17
|
+
variants: {
|
|
18
|
+
rounded: {
|
|
19
|
+
full: "rounded-full",
|
|
20
|
+
large: "rounded-lg",
|
|
21
|
+
medium: "rounded-md",
|
|
22
|
+
none: "rounded-none",
|
|
23
|
+
small: "rounded-sm"
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
const tooltipArrowVariants = cva(`
|
|
28
|
+
absolute w-3 h-3 box-border
|
|
29
|
+
pointer-events-none
|
|
30
|
+
transform-center rotate-45
|
|
31
|
+
z-0 bg-background
|
|
32
|
+
|
|
33
|
+
border border-border
|
|
34
|
+
|
|
35
|
+
data-[position="top"]:-bottom-1.5
|
|
36
|
+
data-[position="top"]:border-t-0
|
|
37
|
+
data-[position="top"]:border-l-0
|
|
38
|
+
data-[position="top"]:[clip-path:inset(1px_0_0_1px)]
|
|
39
|
+
|
|
40
|
+
data-[position="bottom"]:-top-1.5
|
|
41
|
+
data-[position="bottom"]:border-b-0
|
|
42
|
+
data-[position="bottom"]:border-r-0
|
|
43
|
+
data-[position="bottom"]:[clip-path:inset(0_1px_1px_0)]
|
|
44
|
+
|
|
45
|
+
data-[position="left"]:-right-1.5
|
|
46
|
+
data-[position="left"]:border-l-0
|
|
47
|
+
data-[position="left"]:border-b-0
|
|
48
|
+
data-[position="left"]:[clip-path:inset(0_0_1px_1px)]
|
|
49
|
+
|
|
50
|
+
data-[position="right"]:-left-1.5
|
|
51
|
+
data-[position="right"]:border-r-0
|
|
52
|
+
data-[position="right"]:border-t-0
|
|
53
|
+
data-[position="right"]:[clip-path:inset(1px_1px_0_0)]
|
|
54
|
+
`);
|
|
55
|
+
|
|
56
|
+
const tooltipBaseThemeVariants = (theme) => {
|
|
57
|
+
switch (theme) {
|
|
58
|
+
case "mona":
|
|
59
|
+
return tooltipBaseVariants;
|
|
60
|
+
default:
|
|
61
|
+
return tooltipBaseVariants;
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
const tooltipArrowThemeVariants = (theme) => {
|
|
65
|
+
switch (theme) {
|
|
66
|
+
case "mona":
|
|
67
|
+
return tooltipArrowVariants;
|
|
68
|
+
default:
|
|
69
|
+
return tooltipArrowVariants;
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Derives the tooltip arrow position from a ConnectionPositionPair.
|
|
75
|
+
* This function determines where the arrow should be positioned based on
|
|
76
|
+
* how the popup is actually positioned relative to its anchor.
|
|
77
|
+
*/
|
|
78
|
+
function getArrowPositionFromConnectionPair(connectionPair) {
|
|
79
|
+
const { originX, originY, overlayX, overlayY } = connectionPair;
|
|
80
|
+
// Tooltip is above the anchor (arrow points down)
|
|
81
|
+
if (originY === "top" && overlayY === "bottom") {
|
|
82
|
+
return "top";
|
|
83
|
+
}
|
|
84
|
+
// Tooltip is below the anchor (arrow points up)
|
|
85
|
+
if (originY === "bottom" && overlayY === "top") {
|
|
86
|
+
return "bottom";
|
|
87
|
+
}
|
|
88
|
+
// Tooltip is to the left of the anchor (arrow points right)
|
|
89
|
+
if (originX === "start" && overlayX === "end") {
|
|
90
|
+
return "left";
|
|
91
|
+
}
|
|
92
|
+
// Tooltip is to the right of the anchor (arrow points left)
|
|
93
|
+
if (originX === "end" && overlayX === "start") {
|
|
94
|
+
return "right";
|
|
95
|
+
}
|
|
96
|
+
// For center-aligned tooltips, prioritize vertical positioning
|
|
97
|
+
if (overlayY === "bottom") {
|
|
98
|
+
return "top";
|
|
99
|
+
}
|
|
100
|
+
if (overlayY === "top") {
|
|
101
|
+
return "bottom";
|
|
102
|
+
}
|
|
103
|
+
if (overlayX === "end") {
|
|
104
|
+
return "left";
|
|
105
|
+
}
|
|
106
|
+
if (overlayX === "start") {
|
|
107
|
+
return "right";
|
|
108
|
+
}
|
|
109
|
+
return "top";
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* Gets the appropriate offset for a tooltip based on its position.
|
|
113
|
+
* The offset ensures proper spacing between the tooltip and its anchor element.
|
|
114
|
+
*/
|
|
115
|
+
function getOffsetForPosition(position, arrowVisible) {
|
|
116
|
+
const arrowOffset = arrowVisible ? 12 : 4;
|
|
117
|
+
switch (position) {
|
|
118
|
+
case "top":
|
|
119
|
+
return { horizontal: 0, vertical: -arrowOffset };
|
|
120
|
+
case "bottom":
|
|
121
|
+
return { horizontal: 0, vertical: arrowOffset };
|
|
122
|
+
case "right":
|
|
123
|
+
return { horizontal: arrowOffset, vertical: 0 };
|
|
124
|
+
case "left":
|
|
125
|
+
return { horizontal: -arrowOffset, vertical: 0 };
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
function getPositionConnectionPoints(position) {
|
|
129
|
+
switch (position) {
|
|
130
|
+
case "top":
|
|
131
|
+
return { anchor: "topcenter", popup: "bottomcenter" };
|
|
132
|
+
case "bottom":
|
|
133
|
+
return { anchor: "bottomcenter", popup: "topcenter" };
|
|
134
|
+
case "right":
|
|
135
|
+
return { anchor: "centerright", popup: "centerleft" };
|
|
136
|
+
case "left":
|
|
137
|
+
return { anchor: "centerleft", popup: "centerright" };
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
class TooltipComponent {
|
|
142
|
+
#destroyRef;
|
|
143
|
+
#document;
|
|
144
|
+
#popupService;
|
|
145
|
+
#renderer;
|
|
146
|
+
#themeService;
|
|
147
|
+
#currentAnchor;
|
|
148
|
+
#eventSubscription;
|
|
149
|
+
#hideTimeoutId;
|
|
150
|
+
#mutationObserver;
|
|
151
|
+
#popupRef;
|
|
152
|
+
#showTimeoutId;
|
|
153
|
+
constructor() {
|
|
154
|
+
this.#destroyRef = inject(DestroyRef);
|
|
155
|
+
this.#document = inject(DOCUMENT);
|
|
156
|
+
this.#popupService = inject(PopupService);
|
|
157
|
+
this.#renderer = inject(Renderer2);
|
|
158
|
+
this.#themeService = inject(ThemeService);
|
|
159
|
+
this.#currentAnchor = null;
|
|
160
|
+
this.#eventSubscription = null;
|
|
161
|
+
this.#hideTimeoutId = null;
|
|
162
|
+
this.#mutationObserver = null;
|
|
163
|
+
this.#popupRef = null;
|
|
164
|
+
this.#showTimeoutId = null;
|
|
165
|
+
this.arrowClasses = computed(() => {
|
|
166
|
+
const theme = this.#themeService.theme();
|
|
167
|
+
return tooltipArrowThemeVariants(theme)();
|
|
168
|
+
}, /* @ts-ignore */
|
|
169
|
+
...(ngDevMode ? [{ debugName: "arrowClasses" }] : /* istanbul ignore next */ []));
|
|
170
|
+
this.baseClasses = computed(() => {
|
|
171
|
+
const theme = this.#themeService.theme();
|
|
172
|
+
const rounded = this.rounded();
|
|
173
|
+
return tooltipBaseThemeVariants(theme)({ rounded });
|
|
174
|
+
}, /* @ts-ignore */
|
|
175
|
+
...(ngDevMode ? [{ debugName: "baseClasses" }] : /* istanbul ignore next */ []));
|
|
176
|
+
this.currentArrowPosition = linkedSignal(() => this.position(), /* @ts-ignore */
|
|
177
|
+
...(ngDevMode ? [{ debugName: "currentArrowPosition" }] : /* istanbul ignore next */ []));
|
|
178
|
+
this.templateRef = viewChild.required(TemplateRef, /* @ts-ignore */
|
|
179
|
+
...(ngDevMode ? [{ debugName: "templateRef" }] : /* istanbul ignore next */ []));
|
|
180
|
+
this.tooltipId = createElementControlId();
|
|
181
|
+
/**
|
|
182
|
+
* @description Whether the tooltip is disabled. When disabled, the tooltip will not be shown.
|
|
183
|
+
*/
|
|
184
|
+
this.disabled = input(false, /* @ts-ignore */
|
|
185
|
+
...(ngDevMode ? [{ debugName: "disabled" }] : /* istanbul ignore next */ []));
|
|
186
|
+
/**
|
|
187
|
+
* @description Emitted when the tooltip popup is hidden.
|
|
188
|
+
*/
|
|
189
|
+
this.hidden = output();
|
|
190
|
+
/**
|
|
191
|
+
* @description The delay in milliseconds before hiding the tooltip after the trigger event ends.
|
|
192
|
+
*/
|
|
193
|
+
this.hideDelay = input(0, /* @ts-ignore */
|
|
194
|
+
...(ngDevMode ? [{ debugName: "hideDelay" }] : /* istanbul ignore next */ []));
|
|
195
|
+
/**
|
|
196
|
+
* @description The position of the tooltip relative to the target element.
|
|
197
|
+
*/
|
|
198
|
+
this.position = input("top", /* @ts-ignore */
|
|
199
|
+
...(ngDevMode ? [{ debugName: "position" }] : /* istanbul ignore next */ []));
|
|
200
|
+
/**
|
|
201
|
+
* @description The border radius of the tooltip.
|
|
202
|
+
*/
|
|
203
|
+
this.rounded = input("medium", /* @ts-ignore */
|
|
204
|
+
...(ngDevMode ? [{ debugName: "rounded" }] : /* istanbul ignore next */ []));
|
|
205
|
+
/**
|
|
206
|
+
* @description The delay in milliseconds before showing the tooltip after the trigger event.
|
|
207
|
+
*/
|
|
208
|
+
this.showDelay = input(0, /* @ts-ignore */
|
|
209
|
+
...(ngDevMode ? [{ debugName: "showDelay" }] : /* istanbul ignore next */ []));
|
|
210
|
+
/**
|
|
211
|
+
* @description Emitted when the tooltip popup is shown.
|
|
212
|
+
*/
|
|
213
|
+
this.shown = output();
|
|
214
|
+
/**
|
|
215
|
+
* @description The target element(s) to which the tooltip is attached.
|
|
216
|
+
* Can be an Element, ElementRef, or CSS selector string.
|
|
217
|
+
*/
|
|
218
|
+
this.target = input.required(/* @ts-ignore */
|
|
219
|
+
...(ngDevMode ? [{ debugName: "target" }] : /* istanbul ignore next */ []));
|
|
220
|
+
afterRenderEffect({
|
|
221
|
+
read: () => {
|
|
222
|
+
this.target();
|
|
223
|
+
this.position(); // reactive dependency: re-run when position changes
|
|
224
|
+
this.#currentAnchor = null;
|
|
225
|
+
this.#popupRef?.close();
|
|
226
|
+
this.#refreshSubscription();
|
|
227
|
+
this.#mutationObserver?.disconnect();
|
|
228
|
+
this.#mutationObserver = null;
|
|
229
|
+
if (typeof this.target() === "string") {
|
|
230
|
+
this.#mutationObserver = new MutationObserver(() => this.#refreshSubscription());
|
|
231
|
+
this.#mutationObserver.observe(this.#document.body, { childList: true, subtree: true });
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
});
|
|
235
|
+
this.#destroyRef.onDestroy(() => {
|
|
236
|
+
if (this.#showTimeoutId != null) {
|
|
237
|
+
clearTimeout(this.#showTimeoutId);
|
|
238
|
+
this.#showTimeoutId = null;
|
|
239
|
+
}
|
|
240
|
+
if (this.#hideTimeoutId != null) {
|
|
241
|
+
clearTimeout(this.#hideTimeoutId);
|
|
242
|
+
this.#hideTimeoutId = null;
|
|
243
|
+
}
|
|
244
|
+
this.#mutationObserver?.disconnect();
|
|
245
|
+
this.#mutationObserver = null;
|
|
246
|
+
this.#popupRef?.close();
|
|
247
|
+
});
|
|
248
|
+
}
|
|
249
|
+
#createTooltip(anchor) {
|
|
250
|
+
this.#currentAnchor = anchor;
|
|
251
|
+
this.currentArrowPosition.set(this.position());
|
|
252
|
+
const connectionPoints = getPositionConnectionPoints(this.position());
|
|
253
|
+
const offset = getOffsetForPosition(this.position(), true);
|
|
254
|
+
const popupRef = this.#popupService.create({
|
|
255
|
+
anchor,
|
|
256
|
+
anchorConnectionPoint: connectionPoints.anchor,
|
|
257
|
+
animation: fadePopupAnimation,
|
|
258
|
+
closeOnEscape: true,
|
|
259
|
+
closeOnMouseLeave: false,
|
|
260
|
+
closeOnOutsideClick: true,
|
|
261
|
+
content: this.templateRef(),
|
|
262
|
+
hasBackdrop: false,
|
|
263
|
+
offset,
|
|
264
|
+
popupConnectionPoint: connectionPoints.popup,
|
|
265
|
+
restoreFocus: false,
|
|
266
|
+
withPush: false
|
|
267
|
+
});
|
|
268
|
+
this.#popupRef = popupRef;
|
|
269
|
+
this.#renderer.setAttribute(anchor, "aria-describedby", this.tooltipId);
|
|
270
|
+
popupRef.opened.pipe(take(1)).subscribe(() => this.shown.emit());
|
|
271
|
+
popupRef.closed.pipe(take(1)).subscribe(() => {
|
|
272
|
+
if (this.#popupRef === popupRef) {
|
|
273
|
+
this.#popupRef = null;
|
|
274
|
+
this.#currentAnchor = null;
|
|
275
|
+
}
|
|
276
|
+
this.#renderer.removeAttribute(anchor, "aria-describedby");
|
|
277
|
+
this.hidden.emit();
|
|
278
|
+
});
|
|
279
|
+
popupRef.positionChanges
|
|
280
|
+
.pipe(takeUntil(popupRef.closed), takeUntilDestroyed(this.#destroyRef))
|
|
281
|
+
.subscribe(connectionPair => {
|
|
282
|
+
const newArrowPosition = getArrowPositionFromConnectionPair(connectionPair);
|
|
283
|
+
this.currentArrowPosition.set(newArrowPosition);
|
|
284
|
+
});
|
|
285
|
+
}
|
|
286
|
+
#getAnchorElement(anchor) {
|
|
287
|
+
if (anchor instanceof HTMLElement) {
|
|
288
|
+
return anchor;
|
|
289
|
+
}
|
|
290
|
+
if (typeof anchor === "object" && "nativeElement" in anchor && anchor.nativeElement instanceof HTMLElement) {
|
|
291
|
+
return anchor.nativeElement;
|
|
292
|
+
}
|
|
293
|
+
return null;
|
|
294
|
+
}
|
|
295
|
+
#handleHide() {
|
|
296
|
+
if (!this.#popupRef) {
|
|
297
|
+
return;
|
|
298
|
+
}
|
|
299
|
+
const hideDelay = this.hideDelay();
|
|
300
|
+
if (hideDelay > 0) {
|
|
301
|
+
const popupRef = this.#popupRef;
|
|
302
|
+
this.#hideTimeoutId = setTimeout(() => {
|
|
303
|
+
this.#hideTimeoutId = null;
|
|
304
|
+
if (this.#popupRef === popupRef) {
|
|
305
|
+
popupRef.close();
|
|
306
|
+
}
|
|
307
|
+
}, hideDelay);
|
|
308
|
+
}
|
|
309
|
+
else {
|
|
310
|
+
this.#popupRef.close();
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
#handleShow(element) {
|
|
314
|
+
if (this.disabled()) {
|
|
315
|
+
return;
|
|
316
|
+
}
|
|
317
|
+
if (this.#popupRef && this.#currentAnchor === element) {
|
|
318
|
+
return;
|
|
319
|
+
}
|
|
320
|
+
this.#popupRef?.close();
|
|
321
|
+
const showDelay = this.showDelay();
|
|
322
|
+
if (showDelay > 0) {
|
|
323
|
+
this.#showTimeoutId = setTimeout(() => {
|
|
324
|
+
this.#showTimeoutId = null;
|
|
325
|
+
if (!this.#popupRef || this.#currentAnchor !== element) {
|
|
326
|
+
this.#createTooltip(element);
|
|
327
|
+
}
|
|
328
|
+
}, showDelay);
|
|
329
|
+
}
|
|
330
|
+
else {
|
|
331
|
+
this.#createTooltip(element);
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
#refreshSubscription() {
|
|
335
|
+
this.#eventSubscription?.unsubscribe();
|
|
336
|
+
this.#eventSubscription = null;
|
|
337
|
+
const target = this.target();
|
|
338
|
+
if (typeof target === "string") {
|
|
339
|
+
const elements = Array.from(this.#document.querySelectorAll(target));
|
|
340
|
+
const composite = new Subscription();
|
|
341
|
+
for (const element of elements) {
|
|
342
|
+
composite.add(this.#subscribeToElement(element));
|
|
343
|
+
}
|
|
344
|
+
this.#eventSubscription = composite;
|
|
345
|
+
}
|
|
346
|
+
else {
|
|
347
|
+
const element = this.#getAnchorElement(target);
|
|
348
|
+
if (element) {
|
|
349
|
+
this.#eventSubscription = this.#subscribeToElement(element);
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
}
|
|
353
|
+
#subscribeToElement(element) {
|
|
354
|
+
const composite = new Subscription();
|
|
355
|
+
composite.add(fromEvent(element, "pointerenter")
|
|
356
|
+
.pipe(takeUntilDestroyed(this.#destroyRef))
|
|
357
|
+
.subscribe(() => this.#handleShow(element)));
|
|
358
|
+
composite.add(fromEvent(element, "pointerleave")
|
|
359
|
+
.pipe(takeUntilDestroyed(this.#destroyRef))
|
|
360
|
+
.subscribe(() => this.#handleHide()));
|
|
361
|
+
composite.add(fromEvent(element, "focusin")
|
|
362
|
+
.pipe(takeUntilDestroyed(this.#destroyRef))
|
|
363
|
+
.subscribe(() => this.#handleShow(element)));
|
|
364
|
+
composite.add(fromEvent(element, "focusout")
|
|
365
|
+
.pipe(takeUntilDestroyed(this.#destroyRef))
|
|
366
|
+
.subscribe(() => this.#handleHide()));
|
|
367
|
+
return composite;
|
|
368
|
+
}
|
|
369
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: TooltipComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
|
370
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.2.0", version: "22.0.6", type: TooltipComponent, isStandalone: true, selector: "mona-tooltip", inputs: { disabled: { classPropertyName: "disabled", publicName: "disabled", isSignal: true, isRequired: false, transformFunction: null }, hideDelay: { classPropertyName: "hideDelay", publicName: "hideDelay", isSignal: true, isRequired: false, transformFunction: null }, position: { classPropertyName: "position", publicName: "position", isSignal: true, isRequired: false, transformFunction: null }, rounded: { classPropertyName: "rounded", publicName: "rounded", isSignal: true, isRequired: false, transformFunction: null }, showDelay: { classPropertyName: "showDelay", publicName: "showDelay", isSignal: true, isRequired: false, transformFunction: null }, target: { classPropertyName: "target", publicName: "target", isSignal: true, isRequired: true, transformFunction: null } }, outputs: { hidden: "hidden", shown: "shown" }, viewQueries: [{ propertyName: "templateRef", first: true, predicate: TemplateRef, descendants: true, isSignal: true }], ngImport: i0, template: "<ng-template>\r\n <div role=\"tooltip\" [id]=\"tooltipId\" [class]=\"baseClasses()\">\r\n <div>\r\n <ng-content></ng-content>\r\n </div>\r\n <div [class]=\"arrowClasses()\" [attr.data-position]=\"currentArrowPosition()\"></div>\r\n </div>\r\n</ng-template>\r\n", styles: [":host{display:contents}\n"] }); }
|
|
371
|
+
}
|
|
372
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: TooltipComponent, decorators: [{
|
|
373
|
+
type: Component,
|
|
374
|
+
args: [{ selector: "mona-tooltip", template: "<ng-template>\r\n <div role=\"tooltip\" [id]=\"tooltipId\" [class]=\"baseClasses()\">\r\n <div>\r\n <ng-content></ng-content>\r\n </div>\r\n <div [class]=\"arrowClasses()\" [attr.data-position]=\"currentArrowPosition()\"></div>\r\n </div>\r\n</ng-template>\r\n", styles: [":host{display:contents}\n"] }]
|
|
375
|
+
}], ctorParameters: () => [], propDecorators: { templateRef: [{ type: i0.ViewChild, args: [i0.forwardRef(() => TemplateRef), { isSignal: true }] }], disabled: [{ type: i0.Input, args: [{ isSignal: true, alias: "disabled", required: false }] }], hidden: [{ type: i0.Output, args: ["hidden"] }], hideDelay: [{ type: i0.Input, args: [{ isSignal: true, alias: "hideDelay", required: false }] }], position: [{ type: i0.Input, args: [{ isSignal: true, alias: "position", required: false }] }], rounded: [{ type: i0.Input, args: [{ isSignal: true, alias: "rounded", required: false }] }], showDelay: [{ type: i0.Input, args: [{ isSignal: true, alias: "showDelay", required: false }] }], shown: [{ type: i0.Output, args: ["shown"] }], target: [{ type: i0.Input, args: [{ isSignal: true, alias: "target", required: true }] }] } });
|
|
376
|
+
|
|
377
|
+
class TooltipDirective {
|
|
378
|
+
#destroyRef;
|
|
379
|
+
#host;
|
|
380
|
+
#injector;
|
|
381
|
+
#popupService;
|
|
382
|
+
#renderer;
|
|
383
|
+
#currentAnchor;
|
|
384
|
+
#hideTimeoutId;
|
|
385
|
+
#mutationObserver;
|
|
386
|
+
#popupRef;
|
|
387
|
+
#showTimeoutId;
|
|
388
|
+
#subscription;
|
|
389
|
+
#tooltipId;
|
|
390
|
+
constructor() {
|
|
391
|
+
this.#destroyRef = inject(DestroyRef);
|
|
392
|
+
this.#host = inject((ElementRef));
|
|
393
|
+
this.#injector = inject(EnvironmentInjector);
|
|
394
|
+
this.#popupService = inject(PopupService);
|
|
395
|
+
this.#renderer = inject(Renderer2);
|
|
396
|
+
this.#currentAnchor = null;
|
|
397
|
+
this.#hideTimeoutId = null;
|
|
398
|
+
this.#mutationObserver = null;
|
|
399
|
+
this.#popupRef = null;
|
|
400
|
+
this.#showTimeoutId = null;
|
|
401
|
+
this.#subscription = null;
|
|
402
|
+
this.#tooltipId = createElementControlId();
|
|
403
|
+
this.originalTitle = signal("", /* @ts-ignore */
|
|
404
|
+
...(ngDevMode ? [{ debugName: "originalTitle" }] : /* istanbul ignore next */ []));
|
|
405
|
+
/**
|
|
406
|
+
* @description Whether the tooltip is disabled. When disabled, the tooltip will not be shown.
|
|
407
|
+
* @default false
|
|
408
|
+
*/
|
|
409
|
+
this.disabled = input(false, /* @ts-ignore */
|
|
410
|
+
...(ngDevMode ? [{ debugName: "disabled" }] : /* istanbul ignore next */ []));
|
|
411
|
+
/**
|
|
412
|
+
* @description The filter to select elements that will have tooltips.
|
|
413
|
+
* It can be a CSS selector that matches elements within the host element.
|
|
414
|
+
* Only applies when `mode` is set to `content`.
|
|
415
|
+
* @default "[title]"
|
|
416
|
+
*/
|
|
417
|
+
this.filter = input("[title]", /* @ts-ignore */
|
|
418
|
+
...(ngDevMode ? [{ debugName: "filter" }] : /* istanbul ignore next */ []));
|
|
419
|
+
/**
|
|
420
|
+
* @description The delay in milliseconds before hiding the tooltip.
|
|
421
|
+
* @default 0
|
|
422
|
+
*/
|
|
423
|
+
this.hideDelay = input(0, /* @ts-ignore */
|
|
424
|
+
...(ngDevMode ? [{ debugName: "hideDelay" }] : /* istanbul ignore next */ []));
|
|
425
|
+
/**
|
|
426
|
+
* @description The mode of the tooltip.
|
|
427
|
+
* "host" mode receives the tooltip from the host element's title attribute.
|
|
428
|
+
* "content" mode uses the title attribute of elements matching the filter.
|
|
429
|
+
* @default "host"
|
|
430
|
+
*/
|
|
431
|
+
this.mode = input("host", /* @ts-ignore */
|
|
432
|
+
...(ngDevMode ? [{ debugName: "mode" }] : /* istanbul ignore next */ []));
|
|
433
|
+
/**
|
|
434
|
+
* @description The position of the tooltip relative to the target element.
|
|
435
|
+
* @default "top"
|
|
436
|
+
*/
|
|
437
|
+
this.position = input("top", /* @ts-ignore */
|
|
438
|
+
...(ngDevMode ? [{ debugName: "position" }] : /* istanbul ignore next */ []));
|
|
439
|
+
/**
|
|
440
|
+
* @description The border radius of the tooltip.
|
|
441
|
+
* @default "medium"
|
|
442
|
+
*/
|
|
443
|
+
this.rounded = input("medium", { ...(ngDevMode ? { debugName: "rounded" } : /* istanbul ignore next */ {}), alias: "tooltipRounded" });
|
|
444
|
+
/**
|
|
445
|
+
* @description The delay in milliseconds before showing the tooltip after the trigger event.
|
|
446
|
+
* @default 0
|
|
447
|
+
*/
|
|
448
|
+
this.showDelay = input(0, /* @ts-ignore */
|
|
449
|
+
...(ngDevMode ? [{ debugName: "showDelay" }] : /* istanbul ignore next */ []));
|
|
450
|
+
/**
|
|
451
|
+
* @description Emitted when the tooltip popup is hidden.
|
|
452
|
+
*/
|
|
453
|
+
this.hidden = output();
|
|
454
|
+
/**
|
|
455
|
+
* @description Emitted when the tooltip popup is shown.
|
|
456
|
+
*/
|
|
457
|
+
this.shown = output();
|
|
458
|
+
afterRenderEffect({
|
|
459
|
+
read: () => {
|
|
460
|
+
this.mode();
|
|
461
|
+
this.position();
|
|
462
|
+
this.#currentAnchor = null;
|
|
463
|
+
this.#popupRef?.close();
|
|
464
|
+
this.#refreshSubscription();
|
|
465
|
+
this.#mutationObserver?.disconnect();
|
|
466
|
+
this.#mutationObserver = null;
|
|
467
|
+
if (this.mode() === "content") {
|
|
468
|
+
this.#mutationObserver = new MutationObserver(() => this.#refreshSubscription());
|
|
469
|
+
this.#mutationObserver.observe(this.#host.nativeElement, { childList: true, subtree: true });
|
|
470
|
+
}
|
|
471
|
+
}
|
|
472
|
+
});
|
|
473
|
+
this.#destroyRef.onDestroy(() => {
|
|
474
|
+
if (this.#showTimeoutId != null) {
|
|
475
|
+
clearTimeout(this.#showTimeoutId);
|
|
476
|
+
this.#showTimeoutId = null;
|
|
477
|
+
}
|
|
478
|
+
if (this.#hideTimeoutId != null) {
|
|
479
|
+
clearTimeout(this.#hideTimeoutId);
|
|
480
|
+
this.#hideTimeoutId = null;
|
|
481
|
+
}
|
|
482
|
+
this.#mutationObserver?.disconnect();
|
|
483
|
+
this.#mutationObserver = null;
|
|
484
|
+
this.#popupRef?.close();
|
|
485
|
+
});
|
|
486
|
+
}
|
|
487
|
+
#createTooltip(text, anchor) {
|
|
488
|
+
this.#currentAnchor = anchor;
|
|
489
|
+
const component = this.#createTooltipTemplate(text);
|
|
490
|
+
if (!component) {
|
|
491
|
+
return;
|
|
492
|
+
}
|
|
493
|
+
const connectionPoints = getPositionConnectionPoints(this.position());
|
|
494
|
+
const offset = getOffsetForPosition(this.position(), true);
|
|
495
|
+
const popupRef = this.#popupService.create({
|
|
496
|
+
anchor,
|
|
497
|
+
anchorConnectionPoint: connectionPoints.anchor,
|
|
498
|
+
animation: fadePopupAnimation,
|
|
499
|
+
closeOnEscape: true,
|
|
500
|
+
closeOnMouseLeave: false,
|
|
501
|
+
closeOnOutsideClick: true,
|
|
502
|
+
content: component.instance.templateRef(),
|
|
503
|
+
hasBackdrop: false,
|
|
504
|
+
popupConnectionPoint: connectionPoints.popup,
|
|
505
|
+
offset,
|
|
506
|
+
restoreFocus: false,
|
|
507
|
+
withPush: false
|
|
508
|
+
});
|
|
509
|
+
this.#popupRef = popupRef;
|
|
510
|
+
this.#renderer.setAttribute(anchor, "aria-describedby", this.#tooltipId);
|
|
511
|
+
popupRef.opened.pipe(take(1)).subscribe(() => this.shown.emit());
|
|
512
|
+
popupRef.positionChanges
|
|
513
|
+
.pipe(takeUntil(popupRef.closed), takeUntilDestroyed(this.#destroyRef))
|
|
514
|
+
.subscribe(connectionPair => {
|
|
515
|
+
const newArrowPosition = getArrowPositionFromConnectionPair(connectionPair);
|
|
516
|
+
component.instance.currentArrowPosition.set(newArrowPosition);
|
|
517
|
+
});
|
|
518
|
+
popupRef.closed.pipe(take(1)).subscribe(() => {
|
|
519
|
+
if (this.#popupRef === popupRef) {
|
|
520
|
+
this.#popupRef = null;
|
|
521
|
+
this.#currentAnchor = null;
|
|
522
|
+
}
|
|
523
|
+
this.#renderer.removeAttribute(anchor, "aria-describedby");
|
|
524
|
+
this.#renderer.setAttribute(anchor, "title", text);
|
|
525
|
+
component.destroy();
|
|
526
|
+
this.hidden.emit();
|
|
527
|
+
});
|
|
528
|
+
}
|
|
529
|
+
#createTooltipTemplate(text) {
|
|
530
|
+
if (!text) {
|
|
531
|
+
return null;
|
|
532
|
+
}
|
|
533
|
+
const component = createComponent(TooltipTemplateComponent, {
|
|
534
|
+
environmentInjector: this.#injector
|
|
535
|
+
});
|
|
536
|
+
component.setInput("content", text);
|
|
537
|
+
component.setInput("position", this.position());
|
|
538
|
+
component.setInput("rounded", this.rounded());
|
|
539
|
+
component.setInput("tooltipId", this.#tooltipId);
|
|
540
|
+
return component;
|
|
541
|
+
}
|
|
542
|
+
#handleHide() {
|
|
543
|
+
if (!this.#popupRef) {
|
|
544
|
+
return;
|
|
545
|
+
}
|
|
546
|
+
const hideDelay = this.hideDelay();
|
|
547
|
+
if (hideDelay > 0) {
|
|
548
|
+
const popupRef = this.#popupRef;
|
|
549
|
+
this.#hideTimeoutId = setTimeout(() => {
|
|
550
|
+
this.#hideTimeoutId = null;
|
|
551
|
+
if (this.#popupRef === popupRef) {
|
|
552
|
+
popupRef.close();
|
|
553
|
+
}
|
|
554
|
+
}, hideDelay);
|
|
555
|
+
}
|
|
556
|
+
else {
|
|
557
|
+
this.#popupRef.close();
|
|
558
|
+
}
|
|
559
|
+
}
|
|
560
|
+
#handleShow(targetElement) {
|
|
561
|
+
if (this.disabled()) {
|
|
562
|
+
return;
|
|
563
|
+
}
|
|
564
|
+
if (this.#popupRef && this.#currentAnchor === targetElement) {
|
|
565
|
+
return;
|
|
566
|
+
}
|
|
567
|
+
this.#popupRef?.close();
|
|
568
|
+
const title = targetElement.getAttribute("title") || "";
|
|
569
|
+
this.#renderer.removeAttribute(targetElement, "title");
|
|
570
|
+
if (this.mode() === "host") {
|
|
571
|
+
this.originalTitle.set(title);
|
|
572
|
+
}
|
|
573
|
+
if (title) {
|
|
574
|
+
const showDelay = this.showDelay();
|
|
575
|
+
if (showDelay > 0) {
|
|
576
|
+
this.#showTimeoutId = setTimeout(() => {
|
|
577
|
+
this.#showTimeoutId = null;
|
|
578
|
+
if (!this.#popupRef || this.#currentAnchor !== targetElement) {
|
|
579
|
+
this.#createTooltip(title, targetElement);
|
|
580
|
+
}
|
|
581
|
+
}, showDelay);
|
|
582
|
+
}
|
|
583
|
+
else {
|
|
584
|
+
this.#createTooltip(title, targetElement);
|
|
585
|
+
}
|
|
586
|
+
}
|
|
587
|
+
}
|
|
588
|
+
#refreshSubscription() {
|
|
589
|
+
if (this.#subscription) {
|
|
590
|
+
this.#subscription.unsubscribe();
|
|
591
|
+
this.#subscription = null;
|
|
592
|
+
}
|
|
593
|
+
this.#setSubscription();
|
|
594
|
+
}
|
|
595
|
+
#setSubscription() {
|
|
596
|
+
const composite = new Subscription();
|
|
597
|
+
let elements;
|
|
598
|
+
if (this.mode() === "host") {
|
|
599
|
+
elements = [this.#host.nativeElement];
|
|
600
|
+
}
|
|
601
|
+
else {
|
|
602
|
+
elements = Array.from(this.#host.nativeElement.querySelectorAll(this.filter()));
|
|
603
|
+
}
|
|
604
|
+
composite.add(fromEvent(elements, "pointerenter")
|
|
605
|
+
.pipe(tap(event => {
|
|
606
|
+
const targetElement = event.currentTarget;
|
|
607
|
+
this.#handleShow(targetElement);
|
|
608
|
+
}), takeUntilDestroyed(this.#destroyRef))
|
|
609
|
+
.subscribe());
|
|
610
|
+
composite.add(fromEvent(elements, "pointerleave")
|
|
611
|
+
.pipe(tap(() => this.#handleHide()), takeUntilDestroyed(this.#destroyRef))
|
|
612
|
+
.subscribe());
|
|
613
|
+
composite.add(fromEvent(elements, "focusin")
|
|
614
|
+
.pipe(tap(event => {
|
|
615
|
+
const targetElement = event.currentTarget;
|
|
616
|
+
this.#handleShow(targetElement);
|
|
617
|
+
}), takeUntilDestroyed(this.#destroyRef))
|
|
618
|
+
.subscribe());
|
|
619
|
+
composite.add(fromEvent(elements, "focusout")
|
|
620
|
+
.pipe(tap(() => this.#handleHide()), takeUntilDestroyed(this.#destroyRef))
|
|
621
|
+
.subscribe());
|
|
622
|
+
this.#subscription = composite;
|
|
623
|
+
}
|
|
624
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: TooltipDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
625
|
+
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "22.0.6", type: TooltipDirective, isStandalone: true, selector: "[monaTooltip]", inputs: { disabled: { classPropertyName: "disabled", publicName: "disabled", isSignal: true, isRequired: false, transformFunction: null }, filter: { classPropertyName: "filter", publicName: "filter", isSignal: true, isRequired: false, transformFunction: null }, hideDelay: { classPropertyName: "hideDelay", publicName: "hideDelay", isSignal: true, isRequired: false, transformFunction: null }, mode: { classPropertyName: "mode", publicName: "mode", isSignal: true, isRequired: false, transformFunction: null }, position: { classPropertyName: "position", publicName: "position", isSignal: true, isRequired: false, transformFunction: null }, rounded: { classPropertyName: "rounded", publicName: "tooltipRounded", isSignal: true, isRequired: false, transformFunction: null }, showDelay: { classPropertyName: "showDelay", publicName: "showDelay", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { hidden: "hidden", shown: "shown" }, host: { properties: { "attr.data-mona-title": "originalTitle()" } }, ngImport: i0 }); }
|
|
626
|
+
}
|
|
627
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: TooltipDirective, decorators: [{
|
|
628
|
+
type: Directive,
|
|
629
|
+
args: [{
|
|
630
|
+
selector: "[monaTooltip]",
|
|
631
|
+
host: {
|
|
632
|
+
"[attr.data-mona-title]": "originalTitle()"
|
|
633
|
+
}
|
|
634
|
+
}]
|
|
635
|
+
}], ctorParameters: () => [], propDecorators: { disabled: [{ type: i0.Input, args: [{ isSignal: true, alias: "disabled", required: false }] }], filter: [{ type: i0.Input, args: [{ isSignal: true, alias: "filter", required: false }] }], hideDelay: [{ type: i0.Input, args: [{ isSignal: true, alias: "hideDelay", required: false }] }], mode: [{ type: i0.Input, args: [{ isSignal: true, alias: "mode", required: false }] }], position: [{ type: i0.Input, args: [{ isSignal: true, alias: "position", required: false }] }], rounded: [{ type: i0.Input, args: [{ isSignal: true, alias: "tooltipRounded", required: false }] }], showDelay: [{ type: i0.Input, args: [{ isSignal: true, alias: "showDelay", required: false }] }], hidden: [{ type: i0.Output, args: ["hidden"] }], shown: [{ type: i0.Output, args: ["shown"] }] } });
|
|
636
|
+
class TooltipTemplateComponent {
|
|
637
|
+
constructor() {
|
|
638
|
+
this.#themeService = inject(ThemeService);
|
|
639
|
+
this.arrowClasses = computed(() => {
|
|
640
|
+
const theme = this.#themeService.theme();
|
|
641
|
+
return tooltipArrowThemeVariants(theme)();
|
|
642
|
+
}, /* @ts-ignore */
|
|
643
|
+
...(ngDevMode ? [{ debugName: "arrowClasses" }] : /* istanbul ignore next */ []));
|
|
644
|
+
this.baseClasses = computed(() => {
|
|
645
|
+
const theme = this.#themeService.theme();
|
|
646
|
+
const rounded = this.rounded();
|
|
647
|
+
const userClasses = `p-2`;
|
|
648
|
+
const variants = tooltipBaseThemeVariants(theme)({ rounded });
|
|
649
|
+
return twMerge(variants, userClasses);
|
|
650
|
+
}, /* @ts-ignore */
|
|
651
|
+
...(ngDevMode ? [{ debugName: "baseClasses" }] : /* istanbul ignore next */ []));
|
|
652
|
+
this.currentArrowPosition = linkedSignal(() => this.position(), /* @ts-ignore */
|
|
653
|
+
...(ngDevMode ? [{ debugName: "currentArrowPosition" }] : /* istanbul ignore next */ []));
|
|
654
|
+
/**
|
|
655
|
+
* @description The text content displayed in the tooltip.
|
|
656
|
+
*/
|
|
657
|
+
this.content = input.required(/* @ts-ignore */
|
|
658
|
+
...(ngDevMode ? [{ debugName: "content" }] : /* istanbul ignore next */ []));
|
|
659
|
+
/**
|
|
660
|
+
* @description The position of the tooltip relative to the target element.
|
|
661
|
+
*/
|
|
662
|
+
this.position = input("top", /* @ts-ignore */
|
|
663
|
+
...(ngDevMode ? [{ debugName: "position" }] : /* istanbul ignore next */ []));
|
|
664
|
+
/**
|
|
665
|
+
* @description The border radius of the tooltip.
|
|
666
|
+
*/
|
|
667
|
+
this.rounded = input("medium", /* @ts-ignore */
|
|
668
|
+
...(ngDevMode ? [{ debugName: "rounded" }] : /* istanbul ignore next */ []));
|
|
669
|
+
/**
|
|
670
|
+
* @description The unique id for the tooltip element, used for aria-describedby linkage.
|
|
671
|
+
*/
|
|
672
|
+
this.tooltipId = input("", /* @ts-ignore */
|
|
673
|
+
...(ngDevMode ? [{ debugName: "tooltipId" }] : /* istanbul ignore next */ []));
|
|
674
|
+
this.templateRef = viewChild.required(TemplateRef, /* @ts-ignore */
|
|
675
|
+
...(ngDevMode ? [{ debugName: "templateRef" }] : /* istanbul ignore next */ []));
|
|
676
|
+
}
|
|
677
|
+
#themeService;
|
|
678
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: TooltipTemplateComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
|
679
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.2.0", version: "22.0.6", type: TooltipTemplateComponent, isStandalone: true, selector: "ng-component", inputs: { content: { classPropertyName: "content", publicName: "content", isSignal: true, isRequired: true, transformFunction: null }, position: { classPropertyName: "position", publicName: "position", isSignal: true, isRequired: false, transformFunction: null }, rounded: { classPropertyName: "rounded", publicName: "rounded", isSignal: true, isRequired: false, transformFunction: null }, tooltipId: { classPropertyName: "tooltipId", publicName: "tooltipId", isSignal: true, isRequired: false, transformFunction: null } }, viewQueries: [{ propertyName: "templateRef", first: true, predicate: TemplateRef, descendants: true, isSignal: true }], ngImport: i0, template: `
|
|
680
|
+
<ng-template>
|
|
681
|
+
<div role="tooltip" [id]="tooltipId()" [class]="baseClasses()">
|
|
682
|
+
<div>
|
|
683
|
+
{{ content() }}
|
|
684
|
+
</div>
|
|
685
|
+
<div [class]="arrowClasses()" [attr.data-position]="currentArrowPosition()"></div>
|
|
686
|
+
</div>
|
|
687
|
+
</ng-template>
|
|
688
|
+
`, isInline: true, changeDetection: i0.ChangeDetectionStrategy.Eager }); }
|
|
689
|
+
}
|
|
690
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: TooltipTemplateComponent, decorators: [{
|
|
691
|
+
type: Component,
|
|
692
|
+
args: [{
|
|
693
|
+
changeDetection: ChangeDetectionStrategy.Eager,
|
|
694
|
+
template: `
|
|
695
|
+
<ng-template>
|
|
696
|
+
<div role="tooltip" [id]="tooltipId()" [class]="baseClasses()">
|
|
697
|
+
<div>
|
|
698
|
+
{{ content() }}
|
|
699
|
+
</div>
|
|
700
|
+
<div [class]="arrowClasses()" [attr.data-position]="currentArrowPosition()"></div>
|
|
701
|
+
</div>
|
|
702
|
+
</ng-template>
|
|
703
|
+
`
|
|
704
|
+
}]
|
|
705
|
+
}], propDecorators: { content: [{ type: i0.Input, args: [{ isSignal: true, alias: "content", required: true }] }], position: [{ type: i0.Input, args: [{ isSignal: true, alias: "position", required: false }] }], rounded: [{ type: i0.Input, args: [{ isSignal: true, alias: "rounded", required: false }] }], tooltipId: [{ type: i0.Input, args: [{ isSignal: true, alias: "tooltipId", required: false }] }], templateRef: [{ type: i0.ViewChild, args: [i0.forwardRef(() => TemplateRef), { isSignal: true }] }] } });
|
|
706
|
+
|
|
707
|
+
/*
|
|
708
|
+
* Public API Surface of @nanahoshi/mona-ui/tooltip
|
|
709
|
+
*/
|
|
710
|
+
|
|
711
|
+
/**
|
|
712
|
+
* Generated bundle index. Do not edit.
|
|
713
|
+
*/
|
|
714
|
+
|
|
715
|
+
export { TooltipComponent, TooltipDirective, getOffsetForPosition, getPositionConnectionPoints, tooltipArrowThemeVariants };
|
|
716
|
+
//# sourceMappingURL=nanahoshi-mona-ui-tooltip.mjs.map
|