@nanahoshi/mona-ui 0.25.0 → 0.26.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 +2 -0
- package/command/package.json +4 -0
- package/docs/auto-complete.md +733 -0
- package/docs/avatar.md +220 -0
- package/docs/breadcrumb.md +320 -0
- package/docs/button-group.md +392 -0
- package/docs/button.md +256 -0
- package/docs/calendar.md +515 -0
- package/docs/card.md +292 -0
- package/docs/chart.md +4058 -0
- package/docs/checkbox.md +374 -0
- package/docs/chip.md +339 -0
- package/docs/circular-progress-bar.md +287 -0
- package/docs/collapsible.md +308 -0
- package/docs/color-gradient.md +336 -0
- package/docs/color-palette.md +317 -0
- package/docs/color-picker.md +387 -0
- package/docs/combo-box.md +764 -0
- package/docs/command.md +582 -0
- package/docs/contextmenu.md +530 -0
- package/docs/date-picker.md +251 -0
- package/docs/datetime-picker.md +284 -0
- package/docs/decimal-textbox.md +260 -0
- package/docs/dialog.md +822 -0
- package/docs/dropdown-button.md +507 -0
- package/docs/dropdown-list.md +779 -0
- package/docs/editor.md +374 -0
- package/docs/expansion-panel.md +348 -0
- package/docs/fieldset.md +217 -0
- package/docs/forms.md +162 -0
- package/docs/grid.md +2053 -0
- package/docs/input.md +197 -0
- package/docs/installation.md +54 -0
- package/docs/introduction.md +46 -0
- package/docs/label.md +340 -0
- package/docs/list-box.md +637 -0
- package/docs/list-view.md +584 -0
- package/docs/menubar.md +559 -0
- package/docs/multi-select.md +765 -0
- package/docs/notification.md +460 -0
- package/docs/numeric-textbox.md +301 -0
- package/docs/otp-input.md +539 -0
- package/docs/pager.md +513 -0
- package/docs/placeholder.md +176 -0
- package/docs/popover.md +423 -0
- package/docs/popup-menu.md +658 -0
- package/docs/popup.md +617 -0
- package/docs/progress-bar.md +368 -0
- package/docs/radio-button.md +451 -0
- package/docs/range-slider.md +367 -0
- package/docs/rating.md +518 -0
- package/docs/scroll-view.md +375 -0
- package/docs/segmented.md +434 -0
- package/docs/sheet.md +348 -0
- package/docs/sidebar.md +1126 -0
- package/docs/skeleton.md +181 -0
- package/docs/slider.md +423 -0
- package/docs/spinner.md +370 -0
- package/docs/split-button.md +522 -0
- package/docs/splitter.md +342 -0
- package/docs/stepper.md +539 -0
- package/docs/switch.md +340 -0
- package/docs/tabs.md +542 -0
- package/docs/textarea.md +196 -0
- package/docs/textbox.md +332 -0
- package/docs/theming.md +403 -0
- package/docs/time-picker.md +254 -0
- package/docs/tooltip-directive.md +340 -0
- package/docs/tooltip.md +321 -0
- package/docs/tree-view.md +1018 -0
- package/docs/window.md +663 -0
- package/fesm2022/nanahoshi-mona-ui-auto-complete.mjs +1 -1
- package/fesm2022/nanahoshi-mona-ui-breadcrumb.mjs +8 -0
- package/fesm2022/nanahoshi-mona-ui-button-group.mjs +1 -1
- package/fesm2022/nanahoshi-mona-ui-button.mjs +14 -2
- package/fesm2022/nanahoshi-mona-ui-calendar.mjs +5 -2
- package/fesm2022/nanahoshi-mona-ui-chart.mjs +108 -22
- package/fesm2022/nanahoshi-mona-ui-check-box.mjs +4 -0
- package/fesm2022/nanahoshi-mona-ui-chip.mjs +1 -1
- package/fesm2022/nanahoshi-mona-ui-circular-progress-bar.mjs +4 -0
- package/fesm2022/nanahoshi-mona-ui-collapsible.mjs +16 -2
- package/fesm2022/nanahoshi-mona-ui-combo-box.mjs +1 -1
- package/fesm2022/nanahoshi-mona-ui-command.mjs +924 -0
- package/fesm2022/nanahoshi-mona-ui-common.mjs +4 -0
- package/fesm2022/nanahoshi-mona-ui-contextmenu.mjs +10 -6
- package/fesm2022/nanahoshi-mona-ui-date-picker.mjs +2 -1
- package/fesm2022/nanahoshi-mona-ui-datetime-picker.mjs +2 -1
- package/fesm2022/nanahoshi-mona-ui-dialog.mjs +9 -5
- package/fesm2022/nanahoshi-mona-ui-dropdown-button.mjs +9 -5
- package/fesm2022/nanahoshi-mona-ui-dropdowns.mjs +55 -1
- package/fesm2022/nanahoshi-mona-ui-editor.mjs +3 -2
- package/fesm2022/nanahoshi-mona-ui-expansion-panel.mjs +13 -0
- package/fesm2022/nanahoshi-mona-ui-fieldset.mjs +5 -0
- package/fesm2022/{nanahoshi-mona-ui-grid-grid-footer-row.component-2tVhD2hK.mjs → nanahoshi-mona-ui-grid-grid-footer-row.component-DjNnVxHE.mjs} +2 -2
- package/fesm2022/{nanahoshi-mona-ui-grid-grid-list.component-BAN70Wcn.mjs → nanahoshi-mona-ui-grid-grid-list.component-ihQIKeP-.mjs} +5 -5
- package/fesm2022/{nanahoshi-mona-ui-grid-grid-row.component-C_kCaA5b.mjs → nanahoshi-mona-ui-grid-grid-row.component-BpnybNcs.mjs} +18 -35
- package/fesm2022/{nanahoshi-mona-ui-grid-grid-virtual-list.component-BsNfrAHz.mjs → nanahoshi-mona-ui-grid-grid-virtual-list.component-CYlgfc7c.mjs} +5 -5
- package/fesm2022/{nanahoshi-mona-ui-grid-nanahoshi-mona-ui-grid-CEfVa7eo.mjs → nanahoshi-mona-ui-grid-nanahoshi-mona-ui-grid-LCzfCYd3.mjs} +4653 -4529
- package/fesm2022/nanahoshi-mona-ui-grid.mjs +1 -1
- package/fesm2022/nanahoshi-mona-ui-i18n-icu.mjs +10 -0
- package/fesm2022/nanahoshi-mona-ui-internal-list.mjs +1 -0
- package/fesm2022/nanahoshi-mona-ui-internal-popup-menu.mjs +168 -0
- package/fesm2022/nanahoshi-mona-ui-internal-tree.mjs +19 -1
- package/fesm2022/nanahoshi-mona-ui-list-box.mjs +14 -0
- package/fesm2022/nanahoshi-mona-ui-list-view.mjs +32 -0
- package/fesm2022/nanahoshi-mona-ui-locales-ar-sa.mjs +10 -0
- package/fesm2022/nanahoshi-mona-ui-locales-de-de.mjs +10 -0
- package/fesm2022/nanahoshi-mona-ui-locales-es-es.mjs +10 -0
- package/fesm2022/nanahoshi-mona-ui-locales-fr-fr.mjs +10 -0
- package/fesm2022/nanahoshi-mona-ui-locales-id-id.mjs +10 -0
- package/fesm2022/nanahoshi-mona-ui-locales-it-it.mjs +10 -0
- package/fesm2022/nanahoshi-mona-ui-locales-ja-jp.mjs +10 -0
- package/fesm2022/nanahoshi-mona-ui-locales-ko-kr.mjs +10 -0
- package/fesm2022/nanahoshi-mona-ui-locales-pt-br.mjs +10 -0
- package/fesm2022/nanahoshi-mona-ui-locales-ru-ru.mjs +10 -0
- package/fesm2022/nanahoshi-mona-ui-locales-tr-tr.mjs +10 -0
- package/fesm2022/nanahoshi-mona-ui-locales-zh-cn.mjs +10 -0
- package/fesm2022/nanahoshi-mona-ui-locales-zh-tw.mjs +10 -0
- package/fesm2022/nanahoshi-mona-ui-menubar.mjs +15 -8
- package/fesm2022/nanahoshi-mona-ui-multi-select.mjs +8 -5
- package/fesm2022/nanahoshi-mona-ui-notification.mjs +9 -0
- package/fesm2022/nanahoshi-mona-ui-numeric-text-box.mjs +1 -1
- package/fesm2022/nanahoshi-mona-ui-otp-input.mjs +5 -0
- package/fesm2022/nanahoshi-mona-ui-pager.mjs +2 -1
- package/fesm2022/nanahoshi-mona-ui-popover.mjs +14 -6
- package/fesm2022/nanahoshi-mona-ui-popup-menu.mjs +48 -183
- package/fesm2022/nanahoshi-mona-ui-popup.mjs +16 -0
- package/fesm2022/nanahoshi-mona-ui-progress-bar.mjs +4 -0
- package/fesm2022/nanahoshi-mona-ui-rating.mjs +2 -0
- package/fesm2022/nanahoshi-mona-ui-scroll-view.mjs +7 -3
- package/fesm2022/nanahoshi-mona-ui-segmented.mjs +2 -1
- package/fesm2022/nanahoshi-mona-ui-sheet.mjs +5 -5
- package/fesm2022/nanahoshi-mona-ui-sidebar.mjs +1 -1
- package/fesm2022/nanahoshi-mona-ui-slider.mjs +8 -3
- package/fesm2022/nanahoshi-mona-ui-split-button.mjs +10 -7
- package/fesm2022/nanahoshi-mona-ui-stepper.mjs +18 -21
- package/fesm2022/nanahoshi-mona-ui-tabs.mjs +11 -8
- package/fesm2022/nanahoshi-mona-ui-text-box.mjs +9 -1
- package/fesm2022/nanahoshi-mona-ui-theme.mjs +53 -21
- package/fesm2022/nanahoshi-mona-ui-time-picker.mjs +2 -1
- package/fesm2022/nanahoshi-mona-ui-tooltip.mjs +16 -5
- package/fesm2022/nanahoshi-mona-ui-tree-view.mjs +13 -11
- package/fesm2022/nanahoshi-mona-ui-window.mjs +12 -5
- package/i18n/catalogs/en-US.messages.json +10 -0
- package/internal/popup-menu/package.json +4 -0
- package/llms.txt +123 -0
- package/locales/ar-sa/ar-sa.messages.json +10 -0
- package/locales/de-de/de-de.messages.json +10 -0
- package/locales/es-es/es-es.messages.json +10 -0
- package/locales/fr-fr/fr-fr.messages.json +10 -0
- package/locales/id-id/id-id.messages.json +10 -0
- package/locales/it-it/it-it.messages.json +10 -0
- package/locales/ja-jp/ja-jp.messages.json +10 -0
- package/locales/ko-kr/ko-kr.messages.json +10 -0
- package/locales/pt-br/pt-br.messages.json +10 -0
- package/locales/ru-ru/ru-ru.messages.json +10 -0
- package/locales/tr-tr/tr-tr.messages.json +10 -0
- package/locales/zh-cn/zh-cn.messages.json +10 -0
- package/locales/zh-tw/zh-tw.messages.json +10 -0
- package/package.json +9 -1
- package/styles.css +12 -2
- package/types/nanahoshi-mona-ui-auto-complete.d.ts +1 -1
- package/types/nanahoshi-mona-ui-breadcrumb.d.ts +8 -0
- package/types/nanahoshi-mona-ui-button.d.ts +12 -0
- package/types/nanahoshi-mona-ui-calendar.d.ts +3 -0
- package/types/nanahoshi-mona-ui-chart.d.ts +200 -0
- package/types/nanahoshi-mona-ui-check-box.d.ts +4 -0
- package/types/nanahoshi-mona-ui-circular-progress-bar.d.ts +4 -0
- package/types/nanahoshi-mona-ui-collapsible.d.ts +10 -0
- package/types/nanahoshi-mona-ui-combo-box.d.ts +1 -1
- package/types/nanahoshi-mona-ui-command.d.ts +253 -0
- package/types/nanahoshi-mona-ui-common.d.ts +17 -1
- package/types/nanahoshi-mona-ui-contextmenu.d.ts +5 -2
- package/types/nanahoshi-mona-ui-date-picker.d.ts +2 -1
- package/types/nanahoshi-mona-ui-datetime-picker.d.ts +2 -1
- package/types/nanahoshi-mona-ui-dialog.d.ts +58 -1
- package/types/nanahoshi-mona-ui-dropdown-button.d.ts +7 -3
- package/types/nanahoshi-mona-ui-dropdowns.d.ts +55 -1
- package/types/nanahoshi-mona-ui-editor.d.ts +31 -0
- package/types/nanahoshi-mona-ui-expansion-panel.d.ts +13 -0
- package/types/nanahoshi-mona-ui-fieldset.d.ts +5 -0
- package/types/nanahoshi-mona-ui-grid.d.ts +162 -35
- package/types/nanahoshi-mona-ui-i18n.d.ts +144 -1
- package/types/nanahoshi-mona-ui-internal-list.d.ts +16 -1
- package/types/nanahoshi-mona-ui-internal-popup-menu.d.ts +165 -0
- package/types/nanahoshi-mona-ui-internal-tree.d.ts +21 -2
- package/types/nanahoshi-mona-ui-internal.d.ts +4 -5
- package/types/nanahoshi-mona-ui-label.d.ts +1 -0
- package/types/nanahoshi-mona-ui-list-box.d.ts +27 -4
- package/types/nanahoshi-mona-ui-list-view.d.ts +34 -1
- package/types/nanahoshi-mona-ui-list.d.ts +1 -1
- package/types/nanahoshi-mona-ui-locales-ar-sa.d.ts +10 -0
- package/types/nanahoshi-mona-ui-locales-de-de.d.ts +10 -0
- package/types/nanahoshi-mona-ui-locales-es-es.d.ts +10 -0
- package/types/nanahoshi-mona-ui-locales-fr-fr.d.ts +10 -0
- package/types/nanahoshi-mona-ui-locales-id-id.d.ts +10 -0
- package/types/nanahoshi-mona-ui-locales-it-it.d.ts +10 -0
- package/types/nanahoshi-mona-ui-locales-ja-jp.d.ts +10 -0
- package/types/nanahoshi-mona-ui-locales-ko-kr.d.ts +10 -0
- package/types/nanahoshi-mona-ui-locales-pt-br.d.ts +10 -0
- package/types/nanahoshi-mona-ui-locales-ru-ru.d.ts +10 -0
- package/types/nanahoshi-mona-ui-locales-tr-tr.d.ts +10 -0
- package/types/nanahoshi-mona-ui-locales-zh-cn.d.ts +10 -0
- package/types/nanahoshi-mona-ui-locales-zh-tw.d.ts +10 -0
- package/types/nanahoshi-mona-ui-menubar.d.ts +10 -3
- package/types/nanahoshi-mona-ui-multi-select.d.ts +3 -3
- package/types/nanahoshi-mona-ui-notification.d.ts +9 -0
- package/types/nanahoshi-mona-ui-numeric-text-box.d.ts +1 -1
- package/types/nanahoshi-mona-ui-otp-input.d.ts +1 -0
- package/types/nanahoshi-mona-ui-pager.d.ts +5 -1
- package/types/nanahoshi-mona-ui-popover.d.ts +9 -1
- package/types/nanahoshi-mona-ui-popup-menu.d.ts +48 -161
- package/types/nanahoshi-mona-ui-popup.d.ts +16 -0
- package/types/nanahoshi-mona-ui-progress-bar.d.ts +4 -0
- package/types/nanahoshi-mona-ui-rating.d.ts +2 -0
- package/types/nanahoshi-mona-ui-segmented.d.ts +1 -0
- package/types/nanahoshi-mona-ui-sheet.d.ts +1 -1
- package/types/nanahoshi-mona-ui-slider.d.ts +2 -0
- package/types/nanahoshi-mona-ui-spinner.d.ts +7 -0
- package/types/nanahoshi-mona-ui-split-button.d.ts +7 -4
- package/types/nanahoshi-mona-ui-stepper.d.ts +11 -2
- package/types/nanahoshi-mona-ui-tabs.d.ts +4 -1
- package/types/nanahoshi-mona-ui-text-box.d.ts +9 -1
- package/types/nanahoshi-mona-ui-time-picker.d.ts +2 -1
- package/types/nanahoshi-mona-ui-tooltip.d.ts +10 -2
- package/types/nanahoshi-mona-ui-tree-view.d.ts +6 -5
- package/types/nanahoshi-mona-ui-window.d.ts +66 -1
|
@@ -0,0 +1,340 @@
|
|
|
1
|
+
# Tooltip Directive
|
|
2
|
+
|
|
3
|
+
> Replaces a native title attribute with a styled tooltip.
|
|
4
|
+
|
|
5
|
+
Entry point: `@nanahoshi/mona-ui/tooltip`
|
|
6
|
+
|
|
7
|
+
**Selector:** `[monaTooltip]`
|
|
8
|
+
|
|
9
|
+
`TooltipDirective` replaces a native `title` attribute with a styled, positioned tooltip shown on pointer hover and keyboard focus.
|
|
10
|
+
|
|
11
|
+
## Overview
|
|
12
|
+
|
|
13
|
+
Apply `monaTooltip` to any host element that carries a native `title` attribute, or give it the tooltip's content directly: `monaTooltip="Save changes"`, or `[monaTooltip]="template"` for rich content.
|
|
14
|
+
|
|
15
|
+
The directive moves each `title` it uses to a `data-mona-title` attribute, so the browser's own tooltip never appears alongside the styled one. The title stays there for as long as the directive exists, and is put back when it is destroyed. An element named only by its title, such as an icon-only button, keeps that name through `aria-label`.
|
|
16
|
+
|
|
17
|
+
Use `TooltipDirective` when you want a styled, positioned tooltip without adding markup. Use `TooltipComponent` when one tooltip's content should live in its own element, or apply to every element matching a selector across the page.
|
|
18
|
+
|
|
19
|
+
## Import & Quick Start
|
|
20
|
+
|
|
21
|
+
```typescript
|
|
22
|
+
import { TooltipDirective } from "@nanahoshi/mona-ui/tooltip";
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
**Basic usage — `host` mode:**
|
|
26
|
+
|
|
27
|
+
By default the directive reads the `title` attribute of the element it is applied to:
|
|
28
|
+
|
|
29
|
+
```html
|
|
30
|
+
<button monaTooltip title="Save changes">Save</button>
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
**`content` mode — tooltips for descendant elements:**
|
|
34
|
+
|
|
35
|
+
Set `mode="content"` to apply the directive once to a container and have it manage tooltips for descendant elements that match `filter` (default `[title]`):
|
|
36
|
+
|
|
37
|
+
```html
|
|
38
|
+
<div monaTooltip mode="content" filter="[title]">
|
|
39
|
+
<button title="Save changes">Save</button>
|
|
40
|
+
<button title="Discard changes">Discard</button>
|
|
41
|
+
</div>
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
Elements matching `filter` that are added to or removed from the container after initial render are picked up automatically: one listener on the container handles them all.
|
|
45
|
+
|
|
46
|
+
## Examples
|
|
47
|
+
|
|
48
|
+
### Position
|
|
49
|
+
|
|
50
|
+
`start` and `end` follow the text direction. Without room, a tooltip flips to the opposite side.
|
|
51
|
+
|
|
52
|
+
`position-example.component.ts`
|
|
53
|
+
|
|
54
|
+
```typescript
|
|
55
|
+
import { Component } from "@angular/core";
|
|
56
|
+
import { ButtonDirective } from "@nanahoshi/mona-ui/button";
|
|
57
|
+
import { TooltipDirective } from "@nanahoshi/mona-ui/tooltip";
|
|
58
|
+
|
|
59
|
+
@Component({
|
|
60
|
+
selector: "app-tooltip-directive-position-example",
|
|
61
|
+
imports: [ButtonDirective, TooltipDirective],
|
|
62
|
+
templateUrl: "./position-example.component.html"
|
|
63
|
+
})
|
|
64
|
+
export class TooltipDirectivePositionExampleComponent {}
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
`position-example.component.html`
|
|
68
|
+
|
|
69
|
+
```html
|
|
70
|
+
<div class="flex flex-wrap items-center gap-2">
|
|
71
|
+
<button monaButton monaTooltip title="Opens above" type="button">Top</button>
|
|
72
|
+
<button monaButton monaTooltip position="bottom" title="Opens below" type="button">Bottom</button>
|
|
73
|
+
<button monaButton monaTooltip position="start" title="Opens before, in the reading direction" type="button">
|
|
74
|
+
Start
|
|
75
|
+
</button>
|
|
76
|
+
<button monaButton monaTooltip position="end" title="Opens after, in the reading direction" type="button">
|
|
77
|
+
End
|
|
78
|
+
</button>
|
|
79
|
+
</div>
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
### Template content
|
|
83
|
+
|
|
84
|
+
Pass a template to `monaTooltip` for content that isn't plain text. The icon-only button still needs its own `aria-label`.
|
|
85
|
+
|
|
86
|
+
`template-example.component.ts`
|
|
87
|
+
|
|
88
|
+
```typescript
|
|
89
|
+
import { Component } from "@angular/core";
|
|
90
|
+
import { LucideSave } from "@lucide/angular";
|
|
91
|
+
import { ButtonDirective } from "@nanahoshi/mona-ui/button";
|
|
92
|
+
import { TooltipDirective } from "@nanahoshi/mona-ui/tooltip";
|
|
93
|
+
|
|
94
|
+
@Component({
|
|
95
|
+
selector: "app-tooltip-directive-template-example",
|
|
96
|
+
imports: [ButtonDirective, LucideSave, TooltipDirective],
|
|
97
|
+
templateUrl: "./template-example.component.html"
|
|
98
|
+
})
|
|
99
|
+
export class TooltipDirectiveTemplateExampleComponent {}
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
`template-example.component.html`
|
|
103
|
+
|
|
104
|
+
```html
|
|
105
|
+
<button monaButton aria-label="Save" type="button" [iconOnly]="true" [monaTooltip]="shortcut">
|
|
106
|
+
<svg lucideSave aria-hidden="true" [size]="16"></svg>
|
|
107
|
+
</button>
|
|
108
|
+
|
|
109
|
+
<ng-template #shortcut>
|
|
110
|
+
Save
|
|
111
|
+
<kbd>Ctrl</kbd>
|
|
112
|
+
+
|
|
113
|
+
<kbd>S</kbd>
|
|
114
|
+
</ng-template>
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
### Content mode with a custom filter
|
|
118
|
+
|
|
119
|
+
One directive on the container shows a tooltip for every descendant that matches `filter`, including ones rendered later.
|
|
120
|
+
|
|
121
|
+
`content-mode-example.component.ts`
|
|
122
|
+
|
|
123
|
+
```typescript
|
|
124
|
+
import { Component } from "@angular/core";
|
|
125
|
+
import { ButtonDirective } from "@nanahoshi/mona-ui/button";
|
|
126
|
+
import { TooltipDirective } from "@nanahoshi/mona-ui/tooltip";
|
|
127
|
+
|
|
128
|
+
@Component({
|
|
129
|
+
selector: "app-tooltip-directive-content-mode-example",
|
|
130
|
+
imports: [ButtonDirective, TooltipDirective],
|
|
131
|
+
templateUrl: "./content-mode-example.component.html"
|
|
132
|
+
})
|
|
133
|
+
export class TooltipDirectiveContentModeExampleComponent {
|
|
134
|
+
protected readonly actions = [
|
|
135
|
+
{ description: "Upload your changes to the server", id: "save", label: "Save" },
|
|
136
|
+
{ description: "Go back to the last saved version", id: "revert", label: "Revert" },
|
|
137
|
+
{ description: "Send a link to this document", id: "share", label: "Share" }
|
|
138
|
+
];
|
|
139
|
+
}
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
`content-mode-example.component.html`
|
|
143
|
+
|
|
144
|
+
```html
|
|
145
|
+
<div class="flex flex-wrap gap-2" filter="button[title]" mode="content" monaTooltip>
|
|
146
|
+
@for (action of actions; track action.id) {
|
|
147
|
+
<button monaButton type="button" [title]="action.description">{{ action.label }}</button>
|
|
148
|
+
}
|
|
149
|
+
</div>
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
### Turning it off
|
|
153
|
+
|
|
154
|
+
While `disabled` is `true`, the tooltip doesn't open, and an open one closes. On a button or another control, `[disabled]` also reaches the control and disables it, so use `[tooltipDisabled]` there. It turns off only the tooltip.
|
|
155
|
+
|
|
156
|
+
`disabled-example.component.ts`
|
|
157
|
+
|
|
158
|
+
```typescript
|
|
159
|
+
import { Component, signal } from "@angular/core";
|
|
160
|
+
import { ButtonDirective } from "@nanahoshi/mona-ui/button";
|
|
161
|
+
import { CheckBoxComponent } from "@nanahoshi/mona-ui/check-box";
|
|
162
|
+
import { TooltipDirective } from "@nanahoshi/mona-ui/tooltip";
|
|
163
|
+
|
|
164
|
+
@Component({
|
|
165
|
+
selector: "app-tooltip-directive-disabled-example",
|
|
166
|
+
imports: [ButtonDirective, CheckBoxComponent, TooltipDirective],
|
|
167
|
+
templateUrl: "./disabled-example.component.html"
|
|
168
|
+
})
|
|
169
|
+
export class TooltipDirectiveDisabledExampleComponent {
|
|
170
|
+
protected readonly showHints = signal(true);
|
|
171
|
+
}
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
`disabled-example.component.html`
|
|
175
|
+
|
|
176
|
+
```html
|
|
177
|
+
<div class="flex flex-wrap items-center gap-4">
|
|
178
|
+
<mona-check-box label="Show hints" [(checked)]="showHints" />
|
|
179
|
+
<button monaButton monaTooltip="Uploads your local changes" type="button" [tooltipDisabled]="!showHints()">
|
|
180
|
+
Sync
|
|
181
|
+
</button>
|
|
182
|
+
</div>
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
### Show and hide delay
|
|
186
|
+
|
|
187
|
+
```html
|
|
188
|
+
<button monaButton monaTooltip title="Delete this item" [showDelay]="300" [hideDelay]="150">
|
|
189
|
+
Delete
|
|
190
|
+
</button>
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
### Visibility events
|
|
194
|
+
|
|
195
|
+
`shown` emits once the tooltip has opened, and `hidden` once it has closed.
|
|
196
|
+
|
|
197
|
+
```html
|
|
198
|
+
<button monaButton monaTooltip title="Export data" (shown)="onTooltipShown()" (hidden)="onTooltipHidden()">
|
|
199
|
+
Export
|
|
200
|
+
</button>
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
## Appearance & Styling
|
|
204
|
+
|
|
205
|
+
- **`position`** — `"top"` (default), `"bottom"`, `"left"`, `"right"`, `"start"`, or `"end"`. The side of the target the tooltip opens on. `left` and `right` are physical sides in both directions; `start` and `end` follow the text direction (in RTL, `start` is the right). When there isn't room, the tooltip flips to the opposite side, and its arrow follows.
|
|
206
|
+
- **`rounded`** (aliased as `tooltipRounded`) — `'none'`, `'small'`, `'medium'` (default), `'large'`, or `'full'`. Controls the tooltip panel's border radius.
|
|
207
|
+
- **`showDelay`** / **`hideDelay`** — milliseconds to wait before showing the tooltip, or before hiding it once the pointer or focus has left. Both default to `0`. A pointer that leaves always gets a grace of about 100 ms, so it can move onto the tooltip.
|
|
208
|
+
- **`monaTooltip`** — in `host` mode, the tooltip's content: text, or a `TemplateRef`. Without it, the host's `title` is shown. In `content` mode, each element's `title` is shown.
|
|
209
|
+
|
|
210
|
+
## Accessibility
|
|
211
|
+
|
|
212
|
+
The tooltip opens when the pointer moves onto the anchor or keyboard focus enters it, and closes when both have left. Touch pointers don't open it, since a tap would show it and hide it again at once.
|
|
213
|
+
|
|
214
|
+
It meets WCAG 1.4.13 (content on hover or focus):
|
|
215
|
+
|
|
216
|
+
- **Hoverable:** the pointer can move from the anchor onto the tooltip, and the tooltip stays open while the pointer is on it.
|
|
217
|
+
- **Dismissible:** <kbd>Escape</kbd> closes it without moving the pointer or focus, and without bringing the browser's own `title` tooltip back. It stays closed until the pointer or focus leaves the anchor and comes back.
|
|
218
|
+
- **Persistent:** it stays open until the pointer and focus have left, it's dismissed, or the anchor leaves the page.
|
|
219
|
+
|
|
220
|
+
An outside click also closes it.
|
|
221
|
+
|
|
222
|
+
While a tooltip is open, its id is added to the anchor's `aria-describedby`, alongside any ids already there, and removed again when it closes. The panel renders `role="tooltip"`.
|
|
223
|
+
|
|
224
|
+
| Attribute | When present | Value |
|
|
225
|
+
|--------------------|-----------------------------------------------------------|----------------------------------------------------------------|
|
|
226
|
+
| `aria-describedby` | While the tooltip is open | The anchor's own ids, followed by the tooltip's generated id |
|
|
227
|
+
| `aria-label` | On an anchor with no other name, once its title has moved | The title |
|
|
228
|
+
| `data-mona-title` | On each element whose title the directive has used | The title, moved from `title` until the directive is destroyed |
|
|
229
|
+
| `role="tooltip"` | On the tooltip panel itself, while open | `"tooltip"` |
|
|
230
|
+
|
|
231
|
+
**Consumer responsibilities:**
|
|
232
|
+
|
|
233
|
+
- Provide an accessible name for the anchor element independent of the tooltip. A title-only name is kept through `aria-label`, but visible text or your own `aria-label` is better.
|
|
234
|
+
- Read titles from `data-mona-title`, not `title`, in code or tests that run while the directive is attached.
|
|
235
|
+
- Don't put interactive content in a tooltip. It isn't focusable; use `Popover` for that.
|
|
236
|
+
|
|
237
|
+
## API
|
|
238
|
+
|
|
239
|
+
Everything below is imported from `@nanahoshi/mona-ui/tooltip`.
|
|
240
|
+
|
|
241
|
+
### `TooltipComponent`
|
|
242
|
+
|
|
243
|
+
**Selector:** `mona-tooltip`
|
|
244
|
+
|
|
245
|
+
#### Inputs
|
|
246
|
+
|
|
247
|
+
| Name | Type | Default | Description |
|
|
248
|
+
| --- | --- | --- | --- |
|
|
249
|
+
| `disabled` | `boolean` | `false` | Whether the tooltip is disabled. When disabled, the tooltip will not be shown, and an open one closes. |
|
|
250
|
+
| `hideDelay` | `number` | `0` | The delay in milliseconds before hiding the tooltip after the pointer or focus leaves. A pointer that leaves always gets a short grace, so it can move onto the tooltip. |
|
|
251
|
+
| `position` | `TooltipPosition` | `"top"` | The side of the target the tooltip opens on. `left` and `right` are physical; `start` and `end` follow the text direction. It flips to the opposite side when there isn't room. |
|
|
252
|
+
| `rounded` | `"full" \| "large" \| "medium" \| "none" \| "small"` | `"medium"` | The border radius of the tooltip. |
|
|
253
|
+
| `showDelay` | `number` | `0` | The delay in milliseconds before showing the tooltip after the trigger event. |
|
|
254
|
+
| `target` (required) | `PopupAnchor` | — | The target element(s) to which the tooltip is attached. Can be an Element, ElementRef, or CSS selector string. A selector matches elements anywhere in the document, including ones added later. |
|
|
255
|
+
|
|
256
|
+
#### Outputs
|
|
257
|
+
|
|
258
|
+
| Name | Type | Description |
|
|
259
|
+
| --- | --- | --- |
|
|
260
|
+
| `hidden` | `void` | Emitted when the tooltip popup is hidden. |
|
|
261
|
+
| `shown` | `void` | Emitted when the tooltip popup is shown. |
|
|
262
|
+
|
|
263
|
+
### `TooltipDirective`
|
|
264
|
+
|
|
265
|
+
**Selector:** `[monaTooltip]`
|
|
266
|
+
|
|
267
|
+
#### Inputs
|
|
268
|
+
|
|
269
|
+
| Name | Type | Default | Description |
|
|
270
|
+
| --- | --- | --- | --- |
|
|
271
|
+
| `contentOf` | `((element: HTMLElement) => string) \| null` | `null` | Reads the tooltip's text from the matched element, in place of its `title`, which then stays where it is. An empty result shows nothing. |
|
|
272
|
+
| `disabled` | `boolean` | `false` | Whether the tooltip is disabled. When disabled, the tooltip will not be shown, and an open one closes. On a button or another control, `[disabled]` also reaches the control, so use `tooltipDisabled` there. |
|
|
273
|
+
| `filter` | `string` | `"[title]"` | The filter to select elements that will have tooltips. It can be a CSS selector that matches elements within the host element, including ones added later. Only applies when `mode` is set to `content`. |
|
|
274
|
+
| `hideDelay` | `number` | `0` | The delay in milliseconds before hiding the tooltip after the pointer or focus leaves. A pointer that leaves always gets a short grace, so it can move onto the tooltip. |
|
|
275
|
+
| `mode` | `"host" \| "content"` | `"host"` | The mode of the tooltip. "host" mode shows the host's tooltip content, or its title attribute. "content" mode uses the title attribute of elements matching the filter. |
|
|
276
|
+
| `monaTooltip` | `string \| TemplateRef<unknown> \| null \| undefined` | `""` | The tooltip's content in host mode: text, or a template. Without it, the host's `title` is shown. |
|
|
277
|
+
| `position` | `TooltipPosition` | `"top"` | The side of the target the tooltip opens on. `left` and `right` are physical; `start` and `end` follow the text direction. It flips to the opposite side when there isn't room. |
|
|
278
|
+
| `showDelay` | `number` | `0` | The delay in milliseconds before showing the tooltip after the trigger event. |
|
|
279
|
+
| `tooltipDisabled` | `boolean` | `false` | Disables only the tooltip, like `disabled`, on an element whose own `disabled` would take the same binding, such as a `monaButton` or a native control. |
|
|
280
|
+
| `tooltipRounded` | `"full" \| "large" \| "medium" \| "none" \| "small"` | `"medium"` | The border radius of the tooltip. |
|
|
281
|
+
|
|
282
|
+
#### Outputs
|
|
283
|
+
|
|
284
|
+
| Name | Type | Description |
|
|
285
|
+
| --- | --- | --- |
|
|
286
|
+
| `hidden` | `void` | Emitted when the tooltip popup is hidden. |
|
|
287
|
+
| `shown` | `void` | Emitted when the tooltip popup is shown. |
|
|
288
|
+
|
|
289
|
+
### `getOffsetForPosition`
|
|
290
|
+
|
|
291
|
+
**Deprecated.** No longer used by the tooltip or popover, which keep the gap on the side they flip to and place
|
|
292
|
+
`left` and `right` physically in RTL. Kept for existing callers. Gets the appropriate offset for a tooltip based on its position.
|
|
293
|
+
The offset ensures proper spacing between the tooltip and its anchor element.
|
|
294
|
+
|
|
295
|
+
```typescript
|
|
296
|
+
function getOffsetForPosition(position: Position, arrowVisible: boolean): PopupOffset;
|
|
297
|
+
```
|
|
298
|
+
|
|
299
|
+
### `getPositionConnectionPoints`
|
|
300
|
+
|
|
301
|
+
**Deprecated.** No longer used by the tooltip or popover. Kept for existing callers.
|
|
302
|
+
|
|
303
|
+
```typescript
|
|
304
|
+
function getPositionConnectionPoints(position: Position): { anchor: ConnectionPoint; popup: ConnectionPoint };
|
|
305
|
+
```
|
|
306
|
+
|
|
307
|
+
### Types
|
|
308
|
+
|
|
309
|
+
#### `tooltipArrowThemeVariants`
|
|
310
|
+
|
|
311
|
+
```typescript
|
|
312
|
+
const tooltipArrowThemeVariants: (props?: ClassProp | undefined) => string;
|
|
313
|
+
```
|
|
314
|
+
|
|
315
|
+
#### `OverlaySide`
|
|
316
|
+
|
|
317
|
+
A side of the anchor. `start` and `end` follow the direction.
|
|
318
|
+
|
|
319
|
+
```typescript
|
|
320
|
+
type OverlaySide = "bottom" | "end" | "left" | "right" | "start" | "top";
|
|
321
|
+
```
|
|
322
|
+
|
|
323
|
+
#### `TooltipPosition`
|
|
324
|
+
|
|
325
|
+
The side of its anchor a tooltip opens on. `left` and `right` are physical in every direction; `start` and `end`
|
|
326
|
+
follow the text direction.
|
|
327
|
+
|
|
328
|
+
```typescript
|
|
329
|
+
type TooltipPosition = OverlaySide;
|
|
330
|
+
```
|
|
331
|
+
|
|
332
|
+
#### `Position`
|
|
333
|
+
|
|
334
|
+
From `@nanahoshi/mona-ui/common`.
|
|
335
|
+
|
|
336
|
+
```typescript
|
|
337
|
+
type Position = "top" | "right" | "bottom" | "left";
|
|
338
|
+
```
|
|
339
|
+
|
|
340
|
+
**Documented elsewhere:** [`ConnectionPoint`](popup.md), [`PopupAnchor`](popup.md), [`PopupOffset`](popup.md)
|
package/docs/tooltip.md
ADDED
|
@@ -0,0 +1,321 @@
|
|
|
1
|
+
# Tooltip
|
|
2
|
+
|
|
3
|
+
> A floating tooltip with projected content, anchored to a separate target.
|
|
4
|
+
|
|
5
|
+
Entry point: `@nanahoshi/mona-ui/tooltip`
|
|
6
|
+
|
|
7
|
+
**Selector:** `mona-tooltip`
|
|
8
|
+
|
|
9
|
+
`TooltipComponent` shows a floating, positioned tooltip with projected content, anchored to a separately specified target element on pointer hover and keyboard focus.
|
|
10
|
+
|
|
11
|
+
## Overview
|
|
12
|
+
|
|
13
|
+
`TooltipComponent` is placed anywhere in a template and points at a separate `target` element. Unlike `TooltipDirective`, its content comes from projected content, not a `title` attribute, so it supports icons, formatting, and multiple lines.
|
|
14
|
+
|
|
15
|
+
Use `TooltipComponent` when the tooltip needs more than plain text. Use `TooltipDirective` (`monaTooltip`) when a `title` attribute is enough and you want to avoid adding a separate element.
|
|
16
|
+
|
|
17
|
+
## Import & Quick Start
|
|
18
|
+
|
|
19
|
+
```typescript
|
|
20
|
+
import { TooltipComponent } from "@nanahoshi/mona-ui/tooltip";
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
**Targeting an element reference:**
|
|
24
|
+
|
|
25
|
+
```html
|
|
26
|
+
<button #saveButton>Save</button>
|
|
27
|
+
<mona-tooltip [target]="saveButton">Save your current changes</mona-tooltip>
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
**Targeting a CSS selector:**
|
|
31
|
+
|
|
32
|
+
A selector target attaches the same tooltip behavior to every matching element in the document, including ones added after initial render. One listener on the document handles them all, so nothing watches the page for changes:
|
|
33
|
+
|
|
34
|
+
```html
|
|
35
|
+
<div class="flex gap-2">
|
|
36
|
+
<button class="action" data-action="save">Save</button>
|
|
37
|
+
<button class="action" data-action="discard">Discard</button>
|
|
38
|
+
</div>
|
|
39
|
+
<mona-tooltip target=".action">Action button</mona-tooltip>
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
## Examples
|
|
43
|
+
|
|
44
|
+
### Position
|
|
45
|
+
|
|
46
|
+
`start` and `end` follow the text direction. Without room, a tooltip flips to the opposite side.
|
|
47
|
+
|
|
48
|
+
`position-example.component.ts`
|
|
49
|
+
|
|
50
|
+
```typescript
|
|
51
|
+
import { Component } from "@angular/core";
|
|
52
|
+
import { ButtonDirective } from "@nanahoshi/mona-ui/button";
|
|
53
|
+
import { TooltipComponent } from "@nanahoshi/mona-ui/tooltip";
|
|
54
|
+
|
|
55
|
+
@Component({
|
|
56
|
+
selector: "app-tooltip-position-example",
|
|
57
|
+
imports: [ButtonDirective, TooltipComponent],
|
|
58
|
+
templateUrl: "./position-example.component.html"
|
|
59
|
+
})
|
|
60
|
+
export class TooltipPositionExampleComponent {}
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
`position-example.component.html`
|
|
64
|
+
|
|
65
|
+
```html
|
|
66
|
+
<div class="flex flex-wrap items-center gap-2">
|
|
67
|
+
<button #top monaButton type="button">Top</button>
|
|
68
|
+
<button #bottom monaButton type="button">Bottom</button>
|
|
69
|
+
<button #start monaButton type="button">Start</button>
|
|
70
|
+
<button #end monaButton type="button">End</button>
|
|
71
|
+
</div>
|
|
72
|
+
|
|
73
|
+
<mona-tooltip [target]="top">Opens above</mona-tooltip>
|
|
74
|
+
<mona-tooltip position="bottom" [target]="bottom">Opens below</mona-tooltip>
|
|
75
|
+
<mona-tooltip position="start" [target]="start">Opens before, in the reading direction</mona-tooltip>
|
|
76
|
+
<mona-tooltip position="end" [target]="end">Opens after, in the reading direction</mona-tooltip>
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
### Show and hide delay
|
|
80
|
+
|
|
81
|
+
`delay-example.component.ts`
|
|
82
|
+
|
|
83
|
+
```typescript
|
|
84
|
+
import { Component } from "@angular/core";
|
|
85
|
+
import { ButtonDirective } from "@nanahoshi/mona-ui/button";
|
|
86
|
+
import { TooltipComponent } from "@nanahoshi/mona-ui/tooltip";
|
|
87
|
+
|
|
88
|
+
@Component({
|
|
89
|
+
selector: "app-tooltip-delay-example",
|
|
90
|
+
imports: [ButtonDirective, TooltipComponent],
|
|
91
|
+
templateUrl: "./delay-example.component.html"
|
|
92
|
+
})
|
|
93
|
+
export class TooltipDelayExampleComponent {}
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
`delay-example.component.html`
|
|
97
|
+
|
|
98
|
+
```html
|
|
99
|
+
<button #deleteButton monaButton look="error" type="button">Delete project</button>
|
|
100
|
+
|
|
101
|
+
<mona-tooltip [hideDelay]="150" [showDelay]="500" [target]="deleteButton">
|
|
102
|
+
The project and its files are removed for everyone.
|
|
103
|
+
</mona-tooltip>
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
### Turning it off
|
|
107
|
+
|
|
108
|
+
While `disabled` is `true`, the tooltip doesn't open.
|
|
109
|
+
|
|
110
|
+
`disabled-example.component.ts`
|
|
111
|
+
|
|
112
|
+
```typescript
|
|
113
|
+
import { Component, signal } from "@angular/core";
|
|
114
|
+
import { ButtonDirective } from "@nanahoshi/mona-ui/button";
|
|
115
|
+
import { CheckBoxComponent } from "@nanahoshi/mona-ui/check-box";
|
|
116
|
+
import { TooltipComponent } from "@nanahoshi/mona-ui/tooltip";
|
|
117
|
+
|
|
118
|
+
@Component({
|
|
119
|
+
selector: "app-tooltip-disabled-example",
|
|
120
|
+
imports: [ButtonDirective, CheckBoxComponent, TooltipComponent],
|
|
121
|
+
templateUrl: "./disabled-example.component.html"
|
|
122
|
+
})
|
|
123
|
+
export class TooltipDisabledExampleComponent {
|
|
124
|
+
protected readonly showHints = signal(true);
|
|
125
|
+
}
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
`disabled-example.component.html`
|
|
129
|
+
|
|
130
|
+
```html
|
|
131
|
+
<div class="flex flex-wrap items-center gap-4">
|
|
132
|
+
<mona-check-box label="Show hints" [(checked)]="showHints" />
|
|
133
|
+
<button #syncButton monaButton type="button">Sync</button>
|
|
134
|
+
</div>
|
|
135
|
+
|
|
136
|
+
<mona-tooltip [disabled]="!showHints()" [target]="syncButton">Uploads your local changes</mona-tooltip>
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
### Rich content
|
|
140
|
+
|
|
141
|
+
The icon is decorative, so it gets `aria-hidden="true"`. Keep links and buttons out of a tooltip.
|
|
142
|
+
|
|
143
|
+
`rich-content-example.component.ts`
|
|
144
|
+
|
|
145
|
+
```typescript
|
|
146
|
+
import { Component } from "@angular/core";
|
|
147
|
+
import { LucideCircleCheck } from "@lucide/angular";
|
|
148
|
+
import { ButtonDirective } from "@nanahoshi/mona-ui/button";
|
|
149
|
+
import { TooltipComponent } from "@nanahoshi/mona-ui/tooltip";
|
|
150
|
+
|
|
151
|
+
@Component({
|
|
152
|
+
selector: "app-tooltip-rich-content-example",
|
|
153
|
+
imports: [ButtonDirective, LucideCircleCheck, TooltipComponent],
|
|
154
|
+
templateUrl: "./rich-content-example.component.html"
|
|
155
|
+
})
|
|
156
|
+
export class TooltipRichContentExampleComponent {}
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
`rich-content-example.component.html`
|
|
160
|
+
|
|
161
|
+
```html
|
|
162
|
+
<button #statusButton monaButton type="button">Build status</button>
|
|
163
|
+
|
|
164
|
+
<mona-tooltip [target]="statusButton">
|
|
165
|
+
<div class="flex flex-col gap-1">
|
|
166
|
+
<span class="flex items-center gap-1">
|
|
167
|
+
<svg lucideCircleCheck aria-hidden="true" [size]="14"></svg>
|
|
168
|
+
<strong>Passing</strong>
|
|
169
|
+
</span>
|
|
170
|
+
<span>Last run 4 minutes ago, 212 tests</span>
|
|
171
|
+
</div>
|
|
172
|
+
</mona-tooltip>
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
### Visibility events
|
|
176
|
+
|
|
177
|
+
`shown` emits once the tooltip has opened, and `hidden` once it has closed.
|
|
178
|
+
|
|
179
|
+
```html
|
|
180
|
+
<button #exportButton>Export</button>
|
|
181
|
+
<mona-tooltip [target]="exportButton" (shown)="onTooltipShown()" (hidden)="onTooltipHidden()">
|
|
182
|
+
Export the current view
|
|
183
|
+
</mona-tooltip>
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
## Appearance & Styling
|
|
187
|
+
|
|
188
|
+
- **`position`** — `"top"` (default), `"bottom"`, `"left"`, `"right"`, `"start"`, or `"end"`. The side of the target the tooltip opens on. `left` and `right` are physical sides in both directions; `start` and `end` follow the text direction (in RTL, `start` is the right). When there isn't room, the tooltip flips to the opposite side, and its arrow follows.
|
|
189
|
+
- **`rounded`** — `'none'`, `'small'`, `'medium'` (default), `'large'`, or `'full'`. Controls the tooltip panel's border radius.
|
|
190
|
+
- **`showDelay`** / **`hideDelay`** — milliseconds to wait before showing the tooltip, or before hiding it once the pointer or focus has left. Both default to `0`. A pointer that leaves always gets a grace of about 100 ms, so it can move onto the tooltip.
|
|
191
|
+
- **Projected content** — anything placed between the `<mona-tooltip>` tags is rendered inside the tooltip panel, including markup and other components.
|
|
192
|
+
- **`contentOf`** — on `TooltipDirective`, a function from the element to its text, for when the text isn't in a `title`, as with `mode="content"` over rows that keep theirs elsewhere. The element's own `title` isn't touched, and an empty result shows nothing.
|
|
193
|
+
|
|
194
|
+
## Accessibility
|
|
195
|
+
|
|
196
|
+
The tooltip opens when the pointer moves onto the target or keyboard focus enters it, and closes when both have left. Touch pointers don't open it, since a tap would show it and hide it again at once; touch users get the target's own name and description.
|
|
197
|
+
|
|
198
|
+
It meets WCAG 1.4.13 (content on hover or focus):
|
|
199
|
+
|
|
200
|
+
- **Hoverable:** the pointer can move from the target onto the tooltip, and the tooltip stays open while the pointer is on it.
|
|
201
|
+
- **Dismissible:** <kbd>Escape</kbd> closes it without moving the pointer or focus. It stays closed until the pointer or focus leaves the target and comes back.
|
|
202
|
+
- **Persistent:** it stays open until the pointer and focus have left, it's dismissed, or the target leaves the page.
|
|
203
|
+
|
|
204
|
+
An outside click also closes it.
|
|
205
|
+
|
|
206
|
+
While a tooltip is open, its id is added to the target's `aria-describedby`, alongside any ids already there, and removed again when it closes. The panel renders `role="tooltip"`.
|
|
207
|
+
|
|
208
|
+
| Attribute | When present | Value |
|
|
209
|
+
|--------------------|-----------------------------------------|--------------------------------------------------------------|
|
|
210
|
+
| `aria-describedby` | While the tooltip is open | The target's own ids, followed by the tooltip's generated id |
|
|
211
|
+
| `role="tooltip"` | On the tooltip panel itself, while open | `"tooltip"` |
|
|
212
|
+
|
|
213
|
+
**Consumer responsibilities:**
|
|
214
|
+
|
|
215
|
+
- Provide an accessible name for the `target` element independent of the tooltip (the tooltip supplies a description, not a name).
|
|
216
|
+
- Don't put interactive content (links, buttons) in a tooltip. It isn't focusable; use `Popover` for that.
|
|
217
|
+
|
|
218
|
+
## API
|
|
219
|
+
|
|
220
|
+
Everything below is imported from `@nanahoshi/mona-ui/tooltip`.
|
|
221
|
+
|
|
222
|
+
### `TooltipComponent`
|
|
223
|
+
|
|
224
|
+
**Selector:** `mona-tooltip`
|
|
225
|
+
|
|
226
|
+
#### Inputs
|
|
227
|
+
|
|
228
|
+
| Name | Type | Default | Description |
|
|
229
|
+
| --- | --- | --- | --- |
|
|
230
|
+
| `disabled` | `boolean` | `false` | Whether the tooltip is disabled. When disabled, the tooltip will not be shown, and an open one closes. |
|
|
231
|
+
| `hideDelay` | `number` | `0` | The delay in milliseconds before hiding the tooltip after the pointer or focus leaves. A pointer that leaves always gets a short grace, so it can move onto the tooltip. |
|
|
232
|
+
| `position` | `TooltipPosition` | `"top"` | The side of the target the tooltip opens on. `left` and `right` are physical; `start` and `end` follow the text direction. It flips to the opposite side when there isn't room. |
|
|
233
|
+
| `rounded` | `"full" \| "large" \| "medium" \| "none" \| "small"` | `"medium"` | The border radius of the tooltip. |
|
|
234
|
+
| `showDelay` | `number` | `0` | The delay in milliseconds before showing the tooltip after the trigger event. |
|
|
235
|
+
| `target` (required) | `PopupAnchor` | — | The target element(s) to which the tooltip is attached. Can be an Element, ElementRef, or CSS selector string. A selector matches elements anywhere in the document, including ones added later. |
|
|
236
|
+
|
|
237
|
+
#### Outputs
|
|
238
|
+
|
|
239
|
+
| Name | Type | Description |
|
|
240
|
+
| --- | --- | --- |
|
|
241
|
+
| `hidden` | `void` | Emitted when the tooltip popup is hidden. |
|
|
242
|
+
| `shown` | `void` | Emitted when the tooltip popup is shown. |
|
|
243
|
+
|
|
244
|
+
### `TooltipDirective`
|
|
245
|
+
|
|
246
|
+
**Selector:** `[monaTooltip]`
|
|
247
|
+
|
|
248
|
+
#### Inputs
|
|
249
|
+
|
|
250
|
+
| Name | Type | Default | Description |
|
|
251
|
+
| --- | --- | --- | --- |
|
|
252
|
+
| `contentOf` | `((element: HTMLElement) => string) \| null` | `null` | Reads the tooltip's text from the matched element, in place of its `title`, which then stays where it is. An empty result shows nothing. |
|
|
253
|
+
| `disabled` | `boolean` | `false` | Whether the tooltip is disabled. When disabled, the tooltip will not be shown, and an open one closes. On a button or another control, `[disabled]` also reaches the control, so use `tooltipDisabled` there. |
|
|
254
|
+
| `filter` | `string` | `"[title]"` | The filter to select elements that will have tooltips. It can be a CSS selector that matches elements within the host element, including ones added later. Only applies when `mode` is set to `content`. |
|
|
255
|
+
| `hideDelay` | `number` | `0` | The delay in milliseconds before hiding the tooltip after the pointer or focus leaves. A pointer that leaves always gets a short grace, so it can move onto the tooltip. |
|
|
256
|
+
| `mode` | `"host" \| "content"` | `"host"` | The mode of the tooltip. "host" mode shows the host's tooltip content, or its title attribute. "content" mode uses the title attribute of elements matching the filter. |
|
|
257
|
+
| `monaTooltip` | `string \| TemplateRef<unknown> \| null \| undefined` | `""` | The tooltip's content in host mode: text, or a template. Without it, the host's `title` is shown. |
|
|
258
|
+
| `position` | `TooltipPosition` | `"top"` | The side of the target the tooltip opens on. `left` and `right` are physical; `start` and `end` follow the text direction. It flips to the opposite side when there isn't room. |
|
|
259
|
+
| `showDelay` | `number` | `0` | The delay in milliseconds before showing the tooltip after the trigger event. |
|
|
260
|
+
| `tooltipDisabled` | `boolean` | `false` | Disables only the tooltip, like `disabled`, on an element whose own `disabled` would take the same binding, such as a `monaButton` or a native control. |
|
|
261
|
+
| `tooltipRounded` | `"full" \| "large" \| "medium" \| "none" \| "small"` | `"medium"` | The border radius of the tooltip. |
|
|
262
|
+
|
|
263
|
+
#### Outputs
|
|
264
|
+
|
|
265
|
+
| Name | Type | Description |
|
|
266
|
+
| --- | --- | --- |
|
|
267
|
+
| `hidden` | `void` | Emitted when the tooltip popup is hidden. |
|
|
268
|
+
| `shown` | `void` | Emitted when the tooltip popup is shown. |
|
|
269
|
+
|
|
270
|
+
### `getOffsetForPosition`
|
|
271
|
+
|
|
272
|
+
**Deprecated.** No longer used by the tooltip or popover, which keep the gap on the side they flip to and place
|
|
273
|
+
`left` and `right` physically in RTL. Kept for existing callers. Gets the appropriate offset for a tooltip based on its position.
|
|
274
|
+
The offset ensures proper spacing between the tooltip and its anchor element.
|
|
275
|
+
|
|
276
|
+
```typescript
|
|
277
|
+
function getOffsetForPosition(position: Position, arrowVisible: boolean): PopupOffset;
|
|
278
|
+
```
|
|
279
|
+
|
|
280
|
+
### `getPositionConnectionPoints`
|
|
281
|
+
|
|
282
|
+
**Deprecated.** No longer used by the tooltip or popover. Kept for existing callers.
|
|
283
|
+
|
|
284
|
+
```typescript
|
|
285
|
+
function getPositionConnectionPoints(position: Position): { anchor: ConnectionPoint; popup: ConnectionPoint };
|
|
286
|
+
```
|
|
287
|
+
|
|
288
|
+
### Types
|
|
289
|
+
|
|
290
|
+
#### `tooltipArrowThemeVariants`
|
|
291
|
+
|
|
292
|
+
```typescript
|
|
293
|
+
const tooltipArrowThemeVariants: (props?: ClassProp | undefined) => string;
|
|
294
|
+
```
|
|
295
|
+
|
|
296
|
+
#### `OverlaySide`
|
|
297
|
+
|
|
298
|
+
A side of the anchor. `start` and `end` follow the direction.
|
|
299
|
+
|
|
300
|
+
```typescript
|
|
301
|
+
type OverlaySide = "bottom" | "end" | "left" | "right" | "start" | "top";
|
|
302
|
+
```
|
|
303
|
+
|
|
304
|
+
#### `TooltipPosition`
|
|
305
|
+
|
|
306
|
+
The side of its anchor a tooltip opens on. `left` and `right` are physical in every direction; `start` and `end`
|
|
307
|
+
follow the text direction.
|
|
308
|
+
|
|
309
|
+
```typescript
|
|
310
|
+
type TooltipPosition = OverlaySide;
|
|
311
|
+
```
|
|
312
|
+
|
|
313
|
+
#### `Position`
|
|
314
|
+
|
|
315
|
+
From `@nanahoshi/mona-ui/common`.
|
|
316
|
+
|
|
317
|
+
```typescript
|
|
318
|
+
type Position = "top" | "right" | "bottom" | "left";
|
|
319
|
+
```
|
|
320
|
+
|
|
321
|
+
**Documented elsewhere:** [`ConnectionPoint`](popup.md), [`PopupAnchor`](popup.md), [`PopupOffset`](popup.md)
|