@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.
Files changed (227) hide show
  1. package/README.md +2 -0
  2. package/command/package.json +4 -0
  3. package/docs/auto-complete.md +733 -0
  4. package/docs/avatar.md +220 -0
  5. package/docs/breadcrumb.md +320 -0
  6. package/docs/button-group.md +392 -0
  7. package/docs/button.md +256 -0
  8. package/docs/calendar.md +515 -0
  9. package/docs/card.md +292 -0
  10. package/docs/chart.md +4058 -0
  11. package/docs/checkbox.md +374 -0
  12. package/docs/chip.md +339 -0
  13. package/docs/circular-progress-bar.md +287 -0
  14. package/docs/collapsible.md +308 -0
  15. package/docs/color-gradient.md +336 -0
  16. package/docs/color-palette.md +317 -0
  17. package/docs/color-picker.md +387 -0
  18. package/docs/combo-box.md +764 -0
  19. package/docs/command.md +582 -0
  20. package/docs/contextmenu.md +530 -0
  21. package/docs/date-picker.md +251 -0
  22. package/docs/datetime-picker.md +284 -0
  23. package/docs/decimal-textbox.md +260 -0
  24. package/docs/dialog.md +822 -0
  25. package/docs/dropdown-button.md +507 -0
  26. package/docs/dropdown-list.md +779 -0
  27. package/docs/editor.md +374 -0
  28. package/docs/expansion-panel.md +348 -0
  29. package/docs/fieldset.md +217 -0
  30. package/docs/forms.md +162 -0
  31. package/docs/grid.md +2053 -0
  32. package/docs/input.md +197 -0
  33. package/docs/installation.md +54 -0
  34. package/docs/introduction.md +46 -0
  35. package/docs/label.md +340 -0
  36. package/docs/list-box.md +637 -0
  37. package/docs/list-view.md +584 -0
  38. package/docs/menubar.md +559 -0
  39. package/docs/multi-select.md +765 -0
  40. package/docs/notification.md +460 -0
  41. package/docs/numeric-textbox.md +301 -0
  42. package/docs/otp-input.md +539 -0
  43. package/docs/pager.md +513 -0
  44. package/docs/placeholder.md +176 -0
  45. package/docs/popover.md +423 -0
  46. package/docs/popup-menu.md +658 -0
  47. package/docs/popup.md +617 -0
  48. package/docs/progress-bar.md +368 -0
  49. package/docs/radio-button.md +451 -0
  50. package/docs/range-slider.md +367 -0
  51. package/docs/rating.md +518 -0
  52. package/docs/scroll-view.md +375 -0
  53. package/docs/segmented.md +434 -0
  54. package/docs/sheet.md +348 -0
  55. package/docs/sidebar.md +1126 -0
  56. package/docs/skeleton.md +181 -0
  57. package/docs/slider.md +423 -0
  58. package/docs/spinner.md +370 -0
  59. package/docs/split-button.md +522 -0
  60. package/docs/splitter.md +342 -0
  61. package/docs/stepper.md +539 -0
  62. package/docs/switch.md +340 -0
  63. package/docs/tabs.md +542 -0
  64. package/docs/textarea.md +196 -0
  65. package/docs/textbox.md +332 -0
  66. package/docs/theming.md +403 -0
  67. package/docs/time-picker.md +254 -0
  68. package/docs/tooltip-directive.md +340 -0
  69. package/docs/tooltip.md +321 -0
  70. package/docs/tree-view.md +1018 -0
  71. package/docs/window.md +663 -0
  72. package/fesm2022/nanahoshi-mona-ui-auto-complete.mjs +1 -1
  73. package/fesm2022/nanahoshi-mona-ui-breadcrumb.mjs +8 -0
  74. package/fesm2022/nanahoshi-mona-ui-button-group.mjs +1 -1
  75. package/fesm2022/nanahoshi-mona-ui-button.mjs +14 -2
  76. package/fesm2022/nanahoshi-mona-ui-calendar.mjs +5 -2
  77. package/fesm2022/nanahoshi-mona-ui-chart.mjs +108 -22
  78. package/fesm2022/nanahoshi-mona-ui-check-box.mjs +4 -0
  79. package/fesm2022/nanahoshi-mona-ui-chip.mjs +1 -1
  80. package/fesm2022/nanahoshi-mona-ui-circular-progress-bar.mjs +4 -0
  81. package/fesm2022/nanahoshi-mona-ui-collapsible.mjs +16 -2
  82. package/fesm2022/nanahoshi-mona-ui-combo-box.mjs +1 -1
  83. package/fesm2022/nanahoshi-mona-ui-command.mjs +924 -0
  84. package/fesm2022/nanahoshi-mona-ui-common.mjs +4 -0
  85. package/fesm2022/nanahoshi-mona-ui-contextmenu.mjs +10 -6
  86. package/fesm2022/nanahoshi-mona-ui-date-picker.mjs +2 -1
  87. package/fesm2022/nanahoshi-mona-ui-datetime-picker.mjs +2 -1
  88. package/fesm2022/nanahoshi-mona-ui-dialog.mjs +9 -5
  89. package/fesm2022/nanahoshi-mona-ui-dropdown-button.mjs +9 -5
  90. package/fesm2022/nanahoshi-mona-ui-dropdowns.mjs +55 -1
  91. package/fesm2022/nanahoshi-mona-ui-editor.mjs +3 -2
  92. package/fesm2022/nanahoshi-mona-ui-expansion-panel.mjs +13 -0
  93. package/fesm2022/nanahoshi-mona-ui-fieldset.mjs +5 -0
  94. package/fesm2022/{nanahoshi-mona-ui-grid-grid-footer-row.component-2tVhD2hK.mjs → nanahoshi-mona-ui-grid-grid-footer-row.component-DjNnVxHE.mjs} +2 -2
  95. package/fesm2022/{nanahoshi-mona-ui-grid-grid-list.component-BAN70Wcn.mjs → nanahoshi-mona-ui-grid-grid-list.component-ihQIKeP-.mjs} +5 -5
  96. package/fesm2022/{nanahoshi-mona-ui-grid-grid-row.component-C_kCaA5b.mjs → nanahoshi-mona-ui-grid-grid-row.component-BpnybNcs.mjs} +18 -35
  97. package/fesm2022/{nanahoshi-mona-ui-grid-grid-virtual-list.component-BsNfrAHz.mjs → nanahoshi-mona-ui-grid-grid-virtual-list.component-CYlgfc7c.mjs} +5 -5
  98. package/fesm2022/{nanahoshi-mona-ui-grid-nanahoshi-mona-ui-grid-CEfVa7eo.mjs → nanahoshi-mona-ui-grid-nanahoshi-mona-ui-grid-LCzfCYd3.mjs} +4653 -4529
  99. package/fesm2022/nanahoshi-mona-ui-grid.mjs +1 -1
  100. package/fesm2022/nanahoshi-mona-ui-i18n-icu.mjs +10 -0
  101. package/fesm2022/nanahoshi-mona-ui-internal-list.mjs +1 -0
  102. package/fesm2022/nanahoshi-mona-ui-internal-popup-menu.mjs +168 -0
  103. package/fesm2022/nanahoshi-mona-ui-internal-tree.mjs +19 -1
  104. package/fesm2022/nanahoshi-mona-ui-list-box.mjs +14 -0
  105. package/fesm2022/nanahoshi-mona-ui-list-view.mjs +32 -0
  106. package/fesm2022/nanahoshi-mona-ui-locales-ar-sa.mjs +10 -0
  107. package/fesm2022/nanahoshi-mona-ui-locales-de-de.mjs +10 -0
  108. package/fesm2022/nanahoshi-mona-ui-locales-es-es.mjs +10 -0
  109. package/fesm2022/nanahoshi-mona-ui-locales-fr-fr.mjs +10 -0
  110. package/fesm2022/nanahoshi-mona-ui-locales-id-id.mjs +10 -0
  111. package/fesm2022/nanahoshi-mona-ui-locales-it-it.mjs +10 -0
  112. package/fesm2022/nanahoshi-mona-ui-locales-ja-jp.mjs +10 -0
  113. package/fesm2022/nanahoshi-mona-ui-locales-ko-kr.mjs +10 -0
  114. package/fesm2022/nanahoshi-mona-ui-locales-pt-br.mjs +10 -0
  115. package/fesm2022/nanahoshi-mona-ui-locales-ru-ru.mjs +10 -0
  116. package/fesm2022/nanahoshi-mona-ui-locales-tr-tr.mjs +10 -0
  117. package/fesm2022/nanahoshi-mona-ui-locales-zh-cn.mjs +10 -0
  118. package/fesm2022/nanahoshi-mona-ui-locales-zh-tw.mjs +10 -0
  119. package/fesm2022/nanahoshi-mona-ui-menubar.mjs +15 -8
  120. package/fesm2022/nanahoshi-mona-ui-multi-select.mjs +8 -5
  121. package/fesm2022/nanahoshi-mona-ui-notification.mjs +9 -0
  122. package/fesm2022/nanahoshi-mona-ui-numeric-text-box.mjs +1 -1
  123. package/fesm2022/nanahoshi-mona-ui-otp-input.mjs +5 -0
  124. package/fesm2022/nanahoshi-mona-ui-pager.mjs +2 -1
  125. package/fesm2022/nanahoshi-mona-ui-popover.mjs +14 -6
  126. package/fesm2022/nanahoshi-mona-ui-popup-menu.mjs +48 -183
  127. package/fesm2022/nanahoshi-mona-ui-popup.mjs +16 -0
  128. package/fesm2022/nanahoshi-mona-ui-progress-bar.mjs +4 -0
  129. package/fesm2022/nanahoshi-mona-ui-rating.mjs +2 -0
  130. package/fesm2022/nanahoshi-mona-ui-scroll-view.mjs +7 -3
  131. package/fesm2022/nanahoshi-mona-ui-segmented.mjs +2 -1
  132. package/fesm2022/nanahoshi-mona-ui-sheet.mjs +5 -5
  133. package/fesm2022/nanahoshi-mona-ui-sidebar.mjs +1 -1
  134. package/fesm2022/nanahoshi-mona-ui-slider.mjs +8 -3
  135. package/fesm2022/nanahoshi-mona-ui-split-button.mjs +10 -7
  136. package/fesm2022/nanahoshi-mona-ui-stepper.mjs +18 -21
  137. package/fesm2022/nanahoshi-mona-ui-tabs.mjs +11 -8
  138. package/fesm2022/nanahoshi-mona-ui-text-box.mjs +9 -1
  139. package/fesm2022/nanahoshi-mona-ui-theme.mjs +53 -21
  140. package/fesm2022/nanahoshi-mona-ui-time-picker.mjs +2 -1
  141. package/fesm2022/nanahoshi-mona-ui-tooltip.mjs +16 -5
  142. package/fesm2022/nanahoshi-mona-ui-tree-view.mjs +13 -11
  143. package/fesm2022/nanahoshi-mona-ui-window.mjs +12 -5
  144. package/i18n/catalogs/en-US.messages.json +10 -0
  145. package/internal/popup-menu/package.json +4 -0
  146. package/llms.txt +123 -0
  147. package/locales/ar-sa/ar-sa.messages.json +10 -0
  148. package/locales/de-de/de-de.messages.json +10 -0
  149. package/locales/es-es/es-es.messages.json +10 -0
  150. package/locales/fr-fr/fr-fr.messages.json +10 -0
  151. package/locales/id-id/id-id.messages.json +10 -0
  152. package/locales/it-it/it-it.messages.json +10 -0
  153. package/locales/ja-jp/ja-jp.messages.json +10 -0
  154. package/locales/ko-kr/ko-kr.messages.json +10 -0
  155. package/locales/pt-br/pt-br.messages.json +10 -0
  156. package/locales/ru-ru/ru-ru.messages.json +10 -0
  157. package/locales/tr-tr/tr-tr.messages.json +10 -0
  158. package/locales/zh-cn/zh-cn.messages.json +10 -0
  159. package/locales/zh-tw/zh-tw.messages.json +10 -0
  160. package/package.json +9 -1
  161. package/styles.css +12 -2
  162. package/types/nanahoshi-mona-ui-auto-complete.d.ts +1 -1
  163. package/types/nanahoshi-mona-ui-breadcrumb.d.ts +8 -0
  164. package/types/nanahoshi-mona-ui-button.d.ts +12 -0
  165. package/types/nanahoshi-mona-ui-calendar.d.ts +3 -0
  166. package/types/nanahoshi-mona-ui-chart.d.ts +200 -0
  167. package/types/nanahoshi-mona-ui-check-box.d.ts +4 -0
  168. package/types/nanahoshi-mona-ui-circular-progress-bar.d.ts +4 -0
  169. package/types/nanahoshi-mona-ui-collapsible.d.ts +10 -0
  170. package/types/nanahoshi-mona-ui-combo-box.d.ts +1 -1
  171. package/types/nanahoshi-mona-ui-command.d.ts +253 -0
  172. package/types/nanahoshi-mona-ui-common.d.ts +17 -1
  173. package/types/nanahoshi-mona-ui-contextmenu.d.ts +5 -2
  174. package/types/nanahoshi-mona-ui-date-picker.d.ts +2 -1
  175. package/types/nanahoshi-mona-ui-datetime-picker.d.ts +2 -1
  176. package/types/nanahoshi-mona-ui-dialog.d.ts +58 -1
  177. package/types/nanahoshi-mona-ui-dropdown-button.d.ts +7 -3
  178. package/types/nanahoshi-mona-ui-dropdowns.d.ts +55 -1
  179. package/types/nanahoshi-mona-ui-editor.d.ts +31 -0
  180. package/types/nanahoshi-mona-ui-expansion-panel.d.ts +13 -0
  181. package/types/nanahoshi-mona-ui-fieldset.d.ts +5 -0
  182. package/types/nanahoshi-mona-ui-grid.d.ts +162 -35
  183. package/types/nanahoshi-mona-ui-i18n.d.ts +144 -1
  184. package/types/nanahoshi-mona-ui-internal-list.d.ts +16 -1
  185. package/types/nanahoshi-mona-ui-internal-popup-menu.d.ts +165 -0
  186. package/types/nanahoshi-mona-ui-internal-tree.d.ts +21 -2
  187. package/types/nanahoshi-mona-ui-internal.d.ts +4 -5
  188. package/types/nanahoshi-mona-ui-label.d.ts +1 -0
  189. package/types/nanahoshi-mona-ui-list-box.d.ts +27 -4
  190. package/types/nanahoshi-mona-ui-list-view.d.ts +34 -1
  191. package/types/nanahoshi-mona-ui-list.d.ts +1 -1
  192. package/types/nanahoshi-mona-ui-locales-ar-sa.d.ts +10 -0
  193. package/types/nanahoshi-mona-ui-locales-de-de.d.ts +10 -0
  194. package/types/nanahoshi-mona-ui-locales-es-es.d.ts +10 -0
  195. package/types/nanahoshi-mona-ui-locales-fr-fr.d.ts +10 -0
  196. package/types/nanahoshi-mona-ui-locales-id-id.d.ts +10 -0
  197. package/types/nanahoshi-mona-ui-locales-it-it.d.ts +10 -0
  198. package/types/nanahoshi-mona-ui-locales-ja-jp.d.ts +10 -0
  199. package/types/nanahoshi-mona-ui-locales-ko-kr.d.ts +10 -0
  200. package/types/nanahoshi-mona-ui-locales-pt-br.d.ts +10 -0
  201. package/types/nanahoshi-mona-ui-locales-ru-ru.d.ts +10 -0
  202. package/types/nanahoshi-mona-ui-locales-tr-tr.d.ts +10 -0
  203. package/types/nanahoshi-mona-ui-locales-zh-cn.d.ts +10 -0
  204. package/types/nanahoshi-mona-ui-locales-zh-tw.d.ts +10 -0
  205. package/types/nanahoshi-mona-ui-menubar.d.ts +10 -3
  206. package/types/nanahoshi-mona-ui-multi-select.d.ts +3 -3
  207. package/types/nanahoshi-mona-ui-notification.d.ts +9 -0
  208. package/types/nanahoshi-mona-ui-numeric-text-box.d.ts +1 -1
  209. package/types/nanahoshi-mona-ui-otp-input.d.ts +1 -0
  210. package/types/nanahoshi-mona-ui-pager.d.ts +5 -1
  211. package/types/nanahoshi-mona-ui-popover.d.ts +9 -1
  212. package/types/nanahoshi-mona-ui-popup-menu.d.ts +48 -161
  213. package/types/nanahoshi-mona-ui-popup.d.ts +16 -0
  214. package/types/nanahoshi-mona-ui-progress-bar.d.ts +4 -0
  215. package/types/nanahoshi-mona-ui-rating.d.ts +2 -0
  216. package/types/nanahoshi-mona-ui-segmented.d.ts +1 -0
  217. package/types/nanahoshi-mona-ui-sheet.d.ts +1 -1
  218. package/types/nanahoshi-mona-ui-slider.d.ts +2 -0
  219. package/types/nanahoshi-mona-ui-spinner.d.ts +7 -0
  220. package/types/nanahoshi-mona-ui-split-button.d.ts +7 -4
  221. package/types/nanahoshi-mona-ui-stepper.d.ts +11 -2
  222. package/types/nanahoshi-mona-ui-tabs.d.ts +4 -1
  223. package/types/nanahoshi-mona-ui-text-box.d.ts +9 -1
  224. package/types/nanahoshi-mona-ui-time-picker.d.ts +2 -1
  225. package/types/nanahoshi-mona-ui-tooltip.d.ts +10 -2
  226. package/types/nanahoshi-mona-ui-tree-view.d.ts +6 -5
  227. package/types/nanahoshi-mona-ui-window.d.ts +66 -1
package/docs/popup.md ADDED
@@ -0,0 +1,617 @@
1
+ # Popup
2
+
3
+ > Positions arbitrary content relative to an anchor, a point or the viewport.
4
+
5
+ Entry point: `@nanahoshi/mona-ui/popup`
6
+
7
+ **Selector:** `mona-popup`
8
+
9
+ `PopupComponent` and `PopupService` position arbitrary content relative to an anchor element, an anchor point, or the viewport, using the Angular CDK overlay.
10
+
11
+ ## Overview
12
+
13
+ Popup is the positioning and lifecycle primitive that other Mona UI overlay components are built on. `Tooltip`, `Popover`, the color picker, the drop-down tree, the grid filter menu, `Dialog`, and `Window` all create their overlays through `PopupService` internally. Reach for Popup directly when you need a custom anchored overlay that none of those higher-level components already cover.
14
+
15
+ There are two ways to use it:
16
+
17
+ - **`PopupComponent`** (`<mona-popup>`) is declarative. You place content inside the element, bind an `anchor`, and the component listens for a trigger event (a click, by default) on that anchor to open and close the popup for you.
18
+ - **`PopupService`** is imperative. Call `create()` with a `PopupSettings` object to open a popup from code — useful when content must be created on demand, when you do not have a fixed anchor in a template, or when one popup must be attached to many repeated elements at once (see [Multi-element popups](#multi-element-popups-via-css-selector)).
19
+
20
+ **Use `PopupComponent` when:**
21
+
22
+ - The anchor and trigger event are known up front in a template
23
+ - You want open/close wiring handled for you, including not opening a second popup while one is already open
24
+
25
+ **Use `PopupService` directly when:**
26
+
27
+ - You need to open a popup from a service, an event handler, or any place without direct template access to `<mona-popup>`
28
+ - The popup content is a dynamically created component instance rather than a fixed projected template
29
+ - One popup definition must be attached to many DOM elements matching a CSS selector
30
+
31
+ **Use a higher-level component instead when:**
32
+
33
+ - You need a hover hint — use `Tooltip`
34
+ - You need a labeled content panel anchored to a trigger — use `Popover`
35
+ - You need a modal dialog experience — use `Dialog` or `Window`
36
+
37
+ ## Import & Quick Start
38
+
39
+ ```typescript
40
+ import { PopupComponent } from "@nanahoshi/mona-ui/popup";
41
+ ```
42
+
43
+ ```html
44
+ <button #anchor type="button">Open popup</button>
45
+ <mona-popup [anchor]="anchor">
46
+ <div class="p-4">Popup content</div>
47
+ </mona-popup>
48
+ ```
49
+
50
+ `anchor` accepts a raw `Element`, an `ElementRef`, or a `{ x, y }` point — `#anchor` above resolves to the native `<button>` element. The default `trigger` is `"click"` on that anchor.
51
+
52
+ ## Anatomy
53
+
54
+ Popup has a single content-projection slot. Everything placed inside `<mona-popup>...</mona-popup>` becomes the popup body, rendered the moment the popup opens. There is no structural template system or template context — for per-item template customization inside an overlay, use a higher-level component such as a drop-down list.
55
+
56
+ ## Examples
57
+
58
+ ### Custom positioning
59
+
60
+ `anchorConnectionPoint` is the point on the anchor the popup attaches to; `popupConnectionPoint` is the point on the popup that touches the anchor. Both accept the same nine-position keyword set (see the [API](#api) table below). Popup adds no ARIA, so the example sets the role, the name and `aria-expanded` itself.
61
+
62
+ `positioning-example.component.ts`
63
+
64
+ ```typescript
65
+ import { Component, signal } from "@angular/core";
66
+ import { ButtonDirective } from "@nanahoshi/mona-ui/button";
67
+ import { PopupComponent } from "@nanahoshi/mona-ui/popup";
68
+
69
+ @Component({
70
+ selector: "app-popup-positioning-example",
71
+ imports: [ButtonDirective, PopupComponent],
72
+ templateUrl: "./positioning-example.component.html"
73
+ })
74
+ export class PopupPositioningExampleComponent {
75
+ protected readonly open = signal(false);
76
+ }
77
+ ```
78
+
79
+ `positioning-example.component.html`
80
+
81
+ ```html
82
+ <button #anchor monaButton aria-haspopup="dialog" type="button" [attr.aria-expanded]="open()">
83
+ Shipping details
84
+ </button>
85
+
86
+ <mona-popup
87
+ anchorConnectionPoint="topright"
88
+ popupConnectionPoint="bottomleft"
89
+ [anchor]="anchor"
90
+ (close)="open.set(false)"
91
+ (open)="open.set(true)">
92
+ <div
93
+ aria-label="Shipping details"
94
+ class="w-56 rounded-md border border-border bg-surface-overlay p-3 text-sm text-foreground shadow-md"
95
+ role="dialog">
96
+ Ships in 2–3 working days from the Rotterdam warehouse.
97
+ </div>
98
+ </mona-popup>
99
+ ```
100
+
101
+ If the resulting position would overflow the viewport, the popup automatically tries alternate positions, then pushes itself back into view (see `withPush`). To take full control, supply an explicit CDK `positions` array — when provided and non-empty, it replaces the connection-point-based positions entirely.
102
+
103
+ ```typescript
104
+ import type { ConnectedPosition } from "@angular/cdk/overlay";
105
+
106
+ protected readonly positions: ConnectedPosition[] = [
107
+ { originX: "end", originY: "top", overlayX: "start", overlayY: "top" }
108
+ ];
109
+ ```
110
+
111
+ ```html
112
+ <mona-popup [anchor]="anchor" [positions]="positions">
113
+ <div class="p-4">Popup content</div>
114
+ </mona-popup>
115
+ ```
116
+
117
+ ### Backdrop and dismissal
118
+
119
+ `closeOnOutsideClick` (default `true`) and `closeOnEscape` (default `true`) close the popup without a backdrop. Add a backdrop when you want to dim or block the rest of the page; `closeOnBackdropClick` only has an effect once `hasBackdrop` is `true`.
120
+
121
+ `backdrop-example.component.ts`
122
+
123
+ ```typescript
124
+ import { Component, signal } from "@angular/core";
125
+ import { ButtonDirective } from "@nanahoshi/mona-ui/button";
126
+ import { PopupComponent } from "@nanahoshi/mona-ui/popup";
127
+
128
+ @Component({
129
+ selector: "app-popup-backdrop-example",
130
+ imports: [ButtonDirective, PopupComponent],
131
+ templateUrl: "./backdrop-example.component.html"
132
+ })
133
+ export class PopupBackdropExampleComponent {
134
+ protected readonly open = signal(false);
135
+ }
136
+ ```
137
+
138
+ `backdrop-example.component.html`
139
+
140
+ ```html
141
+ <button #anchor monaButton aria-haspopup="dialog" type="button" [attr.aria-expanded]="open()">
142
+ What's new
143
+ </button>
144
+
145
+ <mona-popup
146
+ [anchor]="anchor"
147
+ [closeOnBackdropClick]="true"
148
+ [hasBackdrop]="true"
149
+ (close)="open.set(false)"
150
+ (open)="open.set(true)">
151
+ <div
152
+ aria-label="What's new"
153
+ class="w-64 rounded-md border border-border bg-surface-overlay p-3 text-sm text-foreground shadow-md"
154
+ role="dialog">
155
+ Reports can now be exported as spreadsheets. Click anywhere outside, or press Escape, to close this.
156
+ </div>
157
+ </mona-popup>
158
+ ```
159
+
160
+ ### Hover-triggered popup
161
+
162
+ `trigger` accepts any DOM event name dispatched on the anchor, not a fixed set — `"contextmenu"` and `"pointerover"` work the same way as the default `"click"`.
163
+
164
+ ```html
165
+ <mona-popup [anchor]="anchor" trigger="pointerover" [closeOnMouseLeave]="true">
166
+ <div class="p-4">Popup content</div>
167
+ </mona-popup>
168
+ ```
169
+
170
+ ### Animation presets
171
+
172
+ `animation` accepts `true` (default preset), `false` (no animation), or a `PopupAnimationSettings` object with your own CSS class names. Three presets are exported:
173
+
174
+ | Export | Effect |
175
+ |--------------------------|----------------------------------------------------------------------------------------|
176
+ | `defaultPopupAnimation` | Scale and fade — used when `animation` is `true` or omitted |
177
+ | `dropdownPopupAnimation` | Scale and fade anchored to the top edge, suited to popups that open below their anchor |
178
+ | `fadePopupAnimation` | Fade only, no scaling |
179
+
180
+ ```typescript
181
+ import { dropdownPopupAnimation } from "@nanahoshi/mona-ui/popup";
182
+ ```
183
+
184
+ ```html
185
+ <mona-popup [anchor]="anchor" [animation]="dropdownPopupAnimation">
186
+ <div class="p-4">Popup content</div>
187
+ </mona-popup>
188
+ ```
189
+
190
+ To use your own classes:
191
+
192
+ ```typescript
193
+ protected readonly animation = { enter: "my-enter-class", leave: "my-leave-class" };
194
+ ```
195
+
196
+ ### Imperative usage with `PopupService`
197
+
198
+ `create()` returns a `PopupRef` synchronously; the popup is already opening by the time it returns. A template gets no context, so the example keeps the `PopupRef` to close it with the answer, and moves focus into the popup once it has opened, since the overlay sits at the end of the page, far from the anchor in Tab order.
199
+
200
+ `service-example.component.ts`
201
+
202
+ ```typescript
203
+ import { Component, inject, signal, TemplateRef, viewChild } from "@angular/core";
204
+ import { ButtonDirective } from "@nanahoshi/mona-ui/button";
205
+ import type { PopupRef } from "@nanahoshi/mona-ui/popup";
206
+ import { PopupService } from "@nanahoshi/mona-ui/popup";
207
+
208
+ @Component({
209
+ selector: "app-popup-service-example",
210
+ imports: [ButtonDirective],
211
+ templateUrl: "./service-example.component.html"
212
+ })
213
+ export class PopupServiceExampleComponent {
214
+ readonly #popupService = inject(PopupService);
215
+ #popupRef: PopupRef | null = null;
216
+ protected readonly answer = signal("none");
217
+ protected readonly question = viewChild.required<TemplateRef<void>>("question");
218
+
219
+ protected ask(anchor: HTMLElement): void {
220
+ if (this.#popupRef) {
221
+ return;
222
+ }
223
+ const popupRef = this.#popupService.create({ anchor, content: this.question() });
224
+ popupRef.opened.subscribe(() => popupRef.overlayRef.overlayElement.querySelector("button")?.focus());
225
+ popupRef.closed.subscribe(event => {
226
+ this.answer.set(typeof event.result === "string" ? event.result : "no answer");
227
+ this.#popupRef = null;
228
+ });
229
+ this.#popupRef = popupRef;
230
+ }
231
+
232
+ protected reply(value: string): void {
233
+ this.#popupRef?.close(value);
234
+ }
235
+ }
236
+ ```
237
+
238
+ `service-example.component.html`
239
+
240
+ ```html
241
+ <div class="flex flex-wrap items-center gap-3">
242
+ <button #anchor monaButton aria-haspopup="dialog" type="button" (click)="ask(anchor)">Rate this page</button>
243
+ <span aria-live="polite" class="text-sm">Answer: {{ answer() }}</span>
244
+ </div>
245
+
246
+ <ng-template #question>
247
+ <div
248
+ aria-labelledby="popup-service-example-question"
249
+ class="flex flex-col gap-2 rounded-md border border-border bg-surface-overlay p-3 text-sm text-foreground shadow-md"
250
+ role="dialog">
251
+ <p id="popup-service-example-question">Was this page helpful?</p>
252
+ <div class="flex gap-2">
253
+ <button monaButton type="button" (click)="reply('yes')">Yes</button>
254
+ <button monaButton type="button" (click)="reply('no')">No</button>
255
+ </div>
256
+ </div>
257
+ </ng-template>
258
+ ```
259
+
260
+ ### Closing programmatically and passing a result
261
+
262
+ ```typescript
263
+ confirm(popupRef: PopupRef): void {
264
+ popupRef.close({ confirmed: true });
265
+ }
266
+ ```
267
+
268
+ `close()` accepts an optional result value and an optional delay in milliseconds. Without animation, or when you pass `0` explicitly, the popup is removed from the DOM and `closed` emits immediately. With animation, the popup waits for the leave animation to finish first — see [Close timing](#close-timing).
269
+
270
+ ### Preventing a close
271
+
272
+ ```typescript
273
+ this.popupService.create({
274
+ anchor,
275
+ content,
276
+ preventClose: event => !this.canClose()
277
+ });
278
+ ```
279
+
280
+ Return `true` from `preventClose`, or call `event.preventDefault()` on the received `PopupCloseEvent`, to cancel the close. This setting only governs the built-in close triggers — see [Preventing a close](#preventing-a-close-2) under Technical & Behavior Notes for which paths it covers.
281
+
282
+ ### Multi-element popups via CSS selector
283
+
284
+ `PopupService.create()` accepts a CSS selector string as `anchor` (this is not available on `PopupComponent`, whose `anchor` input only accepts an `Element`, `ElementRef`, or point).
285
+
286
+ ```typescript
287
+ this.popupService.create({
288
+ anchor: ".help-icon",
289
+ content: helpTemplate
290
+ });
291
+ ```
292
+
293
+ Every element matching the selector at the time `create()` runs gets its own popup, opened on `pointerenter` and closed on `pointerleave`. See [Multi-element popups](#multi-element-popups) under Technical & Behavior Notes for important caveats.
294
+
295
+ ### Scroll behavior
296
+
297
+ `withScrollTracking` (default `true`) and `closeOnScroll` (default `false`) are independent settings:
298
+
299
+ ```html
300
+ <mona-popup [anchor]="anchor" [withScrollTracking]="true" [closeOnScroll]="false">
301
+ <div class="p-4">Popup content</div>
302
+ </mona-popup>
303
+ ```
304
+
305
+ - `withScrollTracking` repositions the popup when an ancestor scrolls or the window resizes. It has no effect when `positionStrategy` is `"global"`.
306
+ - `closeOnScroll` closes the popup immediately on the next scroll or resize event instead of repositioning it.
307
+
308
+ ### Focus restoration
309
+
310
+ | `restoreFocus` | Behavior |
311
+ |--------------------|-------------------------------------------------------------------------------------------------------|
312
+ | `"auto"` (default) | Restores focus to the anchor only if the anchor itself held focus immediately before the popup opened |
313
+ | `true` | Always restores focus to the anchor when the popup closes |
314
+ | `false` | Never restores focus — recommended for hover-triggered popups |
315
+
316
+ Focus capture and restoration only apply to element or point anchors, not to CSS-selector multi-element popups.
317
+
318
+ ## Behavior
319
+
320
+ ### Toggle behavior
321
+
322
+ `PopupComponent` toggles: firing the trigger event again while its popup is open closes that popup instead of opening a second one.
323
+
324
+ ### Close timing
325
+
326
+ Calling `close()` without a delay argument waits for the popup's leave animation to finish (or completes immediately if `animation` is `false`) before the popup is removed from the DOM and `closed` emits. Pass `0` as the delay to force immediate removal regardless of animation.
327
+
328
+ ### Preventing a close
329
+
330
+ `preventClose` and a `beforeClose` subscriber that calls `event.preventDefault()` are not equivalent:
331
+
332
+ - `preventClose` (and `event.preventDefault()` from inside it) is only consulted by the built-in close triggers: backdrop click, outside click, the Escape key, mouse-leave, and scroll-close.
333
+ - Calling `event.preventDefault()` from a `beforeClose` subscription cancels **any** close, including a direct `popupRef.close()` call, as long as it runs synchronously when `beforeClose` emits.
334
+
335
+ ### Multi-element popups
336
+
337
+ Popups created with a CSS-selector `anchor` always open on `pointerenter` and close on `pointerleave` — the per-trigger configuration available on `PopupComponent` does not apply to them. Only elements present in the DOM when `create()` is called are included; elements added afterward require calling `create()` again.
338
+
339
+ ### Anchor positioning defaults differ between the component and the service
340
+
341
+ `PopupComponent` defaults `anchorConnectionPoint` to `"bottomcenter"` and `popupConnectionPoint` to `"topcenter"`. Calling `PopupService.create()` directly without these settings falls back to `"bottomleft"` and `"topleft"` respectively.
342
+
343
+ - `Element | ElementRef<Element> | Point | string`. A CSS selector string is only meaningful when passed to `PopupService.create()`.
344
+
345
+ ## Accessibility
346
+
347
+ ### Keyboard
348
+
349
+ The Escape key closes the popup when `closeOnEscape` is `true` (the default), as long as the popup is currently attached.
350
+
351
+ ### Focus
352
+
353
+ Popup does not implement a focus trap. Focus restoration to the anchor on close is controlled by `restoreFocus` (see [Focus restoration](#focus-restoration) above). If your use case requires trapping focus inside the overlay, consider `Dialog` or `Window` instead.
354
+
355
+ ### ARIA
356
+
357
+ Popup renders no ARIA roles or attributes on the anchor or the popup content itself — it is a generic positioning primitive. Provide the appropriate role (for example `role="dialog"`, `role="menu"`, or `role="tooltip"`) and labeling on your projected content, and any `aria-expanded` / `aria-haspopup` state on the anchor, yourself.
358
+
359
+ ### Motion
360
+
361
+ The built-in animation presets respect `prefers-reduced-motion`.
362
+
363
+ ## API
364
+
365
+ Everything below is imported from `@nanahoshi/mona-ui/popup`.
366
+
367
+ ### `PopupComponent`
368
+
369
+ **Selector:** `mona-popup`
370
+ **Type parameters:** `T = unknown`
371
+
372
+ #### Inputs
373
+
374
+ | Name | Type | Default | Description |
375
+ | --- | --- | --- | --- |
376
+ | `anchor` (required) | `FlexibleConnectedPositionStrategyOrigin` | — | The anchor element or point for the popup. |
377
+ | `anchorConnectionPoint` | `ConnectionPoint` | `"bottomcenter"` | The connection point for the popup anchor. |
378
+ | `animation` | `boolean \| PopupAnimationSettings` | `true` | The animation settings for the popup. |
379
+ | `backdropClass` | `string \| string[]` | `[]` | The class or classes to apply to the backdrop of the popup. |
380
+ | `closeOnBackdropClick` | `boolean` | `true` | Whether to close the popup when clicking on the backdrop. Only applies when the popup has a backdrop. |
381
+ | `closeOnEscape` | `boolean` | `true` | Whether to close the popup when the escape key is pressed. Escape only reaches the topmost open popup. |
382
+ | `closeOnMouseLeave` | `boolean` | `false` | Whether to close the popup when the mouse leaves the anchor element. |
383
+ | `closeOnOutsideClick` | `boolean` | `true` | Whether to close the popup when clicking outside of it. |
384
+ | `closeOnScroll` | `boolean` | `false` | Whether to close the popup when the user scrolls the page or a scrollable container around the anchor. |
385
+ | `data` | `T` | — | Arbitrary data to pass to the popup. |
386
+ | `hasBackdrop` | `boolean` | `false` | Whether the popup should have a backdrop. |
387
+ | `height` | `number \| string` | — | The height of the popup. |
388
+ | `maxHeight` | `number \| string` | — | The maximum height of the popup. |
389
+ | `maxWidth` | `number \| string` | — | The maximum width of the popup. |
390
+ | `minHeight` | `number \| string` | — | The minimum height of the popup. |
391
+ | `minWidth` | `number \| string` | — | The minimum width of the popup. |
392
+ | `offset` | `PopupOffset` | — | The offset of the popup from the anchor. |
393
+ | `popupClass` | `string \| string[]` | `[]` | The class or classes to apply to the popup. |
394
+ | `popupConnectionPoint` | `ConnectionPoint` | `"topcenter"` | The connection point for the popup. |
395
+ | `popupWrapperClass` | `string \| string[]` | `[]` | The class or classes to apply to the popup wrapper. |
396
+ | `positions` | `Array<ConnectedPosition \| ConnectionPositionPair>` | — | The positions to use for the popup. The popup will try to position itself in the first position that fits. This is only used when the `positionStrategy` is set to `connected`. |
397
+ | `positionStrategy` | `"global" \| "connected"` | `"connected"` | The strategy for positioning the popup. `global` means the popup will be positioned relative to the viewport, `connected` means the popup will be positioned relative to the anchor element. |
398
+ | `preventClose` | `Action<PopupCloseEvent, boolean>` | — | Called when the popup is requested to close. This can be used to prevent the popup from closing. |
399
+ | `providers` | `StaticProvider[]` | `[]` | The providers that will be injected into the popup. |
400
+ | `restoreFocus` | `boolean \| "auto"` | `"auto"` | Controls focus restoration when the popup closes. - `true`: always restore focus to the anchor element. - `false`: never restore focus (recommended for tooltips). - `"auto"`: restore focus only if the anchor, or an element inside it, was focused when the popup opened. Focus is left alone if the user moved it outside the popup and the anchor before it closed. |
401
+ | `trigger` | `string` | `"click"` | The trigger event for opening the popup. |
402
+ | `width` | `number \| string \| undefined` | `undefined` | The width of the popup. |
403
+ | `withPush` | `boolean` | `true` | Whether to push the popup into the screen when it is opened. |
404
+ | `withScrollTracking` | `boolean` | `true` | Whether the popup should track scroll events and reposition itself. |
405
+
406
+ #### Outputs
407
+
408
+ | Name | Type | Description |
409
+ | --- | --- | --- |
410
+ | `close` | `void` | Emits when the popup is closed. |
411
+ | `open` | `PopupRef` | Emits when the popup is opened. |
412
+
413
+ #### Methods
414
+
415
+ | Signature | Description |
416
+ | --- | --- |
417
+ | `closePopup(): void` | Closes the popup if one is currently open. |
418
+
419
+ ### `PopupService`
420
+
421
+ #### Methods
422
+
423
+ | Signature | Description |
424
+ | --- | --- |
425
+ | `create(settings: PopupSettings): PopupRef` | Opens a popup and returns its `PopupRef`. If `settings.anchor` is a CSS selector string, creates a hover-triggered popup for every matching element (see Multi-element popups); otherwise creates a single popup attached to the given element, `ElementRef`, or point. |
426
+
427
+ ### `PopupRef`
428
+
429
+ Returned by `PopupService.create()` and emitted via `PopupComponent`'s `open` output.
430
+
431
+ #### Properties
432
+
433
+ | Name | Type | Description |
434
+ | --- | --- | --- |
435
+ | `beforeClose` (read-only) | `Observable<PopupCloseEvent>` | Emitted when the popup is about to close. This event can be prevented. If it is prevented, the popup will not close. |
436
+ | `closed` (read-only) | `Observable<PopupCloseEvent>` | Emitted when the popup is closed. This event is emitted after the animation completes. Preventing this event has no effect. |
437
+ | `closeStart` (read-only) | `Observable<PopupCloseEvent>` | Emitted when the popup begins closing, before the leave animation completes. Subscribe to this to react at the moment the close sequence starts — for example, to begin coordinating a transition in the consuming component. The `closed` observable fires after the leave animation finishes. |
438
+ | `component` (read-only) | `ComponentRef<unknown> \| null` | Reference to the component hosted in the popup. This is `null` if the popup does not contain a component. |
439
+ | `opened` (read-only) | `Observable<void>` | Emitted when the popup is opened. |
440
+ | `overlayRef` (read-only) | `OverlayRef` | Reference to the underlying CDK overlay. Use this reference to manipulate the overlay directly, such as to set its size or position. |
441
+ | `positionChanges` (read-only) | `Observable<ConnectionPositionPair>` | Returns the position pair of the popup's anchor element. |
442
+
443
+ #### Methods
444
+
445
+ | Signature | Description |
446
+ | --- | --- |
447
+ | `close<R>(result?: R, delay?: number): boolean` | Requests the popup to close. |
448
+ | `closeWithDelay<R>(delay: number = 100, result?: R): void` | Closes the popup after a delay. When the popup is closed, the overlay element is removed from the DOM instantly. This causes the animation of the child elements to not play, therefore, a delay is added to allow the animation to play. |
449
+
450
+ ### `PopupCloseEvent`
451
+
452
+ **Type parameters:** `R = unknown`
453
+ **Extends:** `PreventableEvent`
454
+
455
+ #### Properties
456
+
457
+ | Name | Type | Description |
458
+ | --- | --- | --- |
459
+ | `result` (read-only) | `R \| undefined` | The result value passed to `close()`, if any. |
460
+ | `via` (read-only) | `PopupCloseSource \| undefined` | The source of the close. |
461
+
462
+ ### Types
463
+
464
+ #### `defaultPopupAnimation`
465
+
466
+ ```typescript
467
+ const defaultPopupAnimation: Required<PopupAnimationSettings>;
468
+ ```
469
+
470
+ #### `dropdownPopupAnimation`
471
+
472
+ ```typescript
473
+ const dropdownPopupAnimation: Required<PopupAnimationSettings>;
474
+ ```
475
+
476
+ #### `fadePopupAnimation`
477
+
478
+ ```typescript
479
+ const fadePopupAnimation: Required<PopupAnimationSettings>;
480
+ ```
481
+
482
+ #### `PopupDataInjectionToken`
483
+
484
+ The `data` passed in `PopupSettings`, available to the popup content.
485
+
486
+ ```typescript
487
+ const PopupDataInjectionToken: InjectionToken<unknown>;
488
+ ```
489
+
490
+ #### `slideFromBottomPopupAnimation`
491
+
492
+ ```typescript
493
+ const slideFromBottomPopupAnimation: Required<PopupAnimationSettings>;
494
+ ```
495
+
496
+ #### `slideFromLeftPopupAnimation`
497
+
498
+ ```typescript
499
+ const slideFromLeftPopupAnimation: Required<PopupAnimationSettings>;
500
+ ```
501
+
502
+ #### `slideFromRightPopupAnimation`
503
+
504
+ ```typescript
505
+ const slideFromRightPopupAnimation: Required<PopupAnimationSettings>;
506
+ ```
507
+
508
+ #### `slideFromTopPopupAnimation`
509
+
510
+ ```typescript
511
+ const slideFromTopPopupAnimation: Required<PopupAnimationSettings>;
512
+ ```
513
+
514
+ #### `PopupAnimationSettings`
515
+
516
+ | Name | Type | Description |
517
+ | --- | --- | --- |
518
+ | `enter?` | `string \| string[]` | CSS class or classes applied by animate.enter when the popup is shown. |
519
+ | `leave?` | `string \| string[]` | CSS class or classes applied by animate.leave when the popup is hidden. |
520
+
521
+ #### `PopupOffset`
522
+
523
+ | Name | Type |
524
+ | --- | --- |
525
+ | `horizontal?` | `number` |
526
+ | `vertical?` | `number` |
527
+
528
+ #### `PopupSettings`
529
+
530
+ **Type parameters:** `T = unknown`, `C = void`
531
+
532
+ | Name | Type | Description |
533
+ | --- | --- | --- |
534
+ | `anchor` | `PopupAnchor` | The anchor element to which the popup will be connected. Can be an element, ElementRef, or CSS selector string. |
535
+ | `anchorConnectionPoint?` | `ConnectionPoint \| null` | The connection point of the anchor element to which the popup will be connected. |
536
+ | `animation?` | `boolean \| PopupAnimationSettings` | Animation settings for the popup. |
537
+ | `backdropClass?` | `string \| string[]` | Classes to be applied to the backdrop. |
538
+ | `blockScroll?` | `boolean` | Whether scrolling behind the popup should be blocked while it is open. Default: false. |
539
+ | `closeOnBackdropClick?` | `boolean` | Whether the popup will be closed when the user clicks on the backdrop. Only applies if `hasBackdrop` is true. Default: true. |
540
+ | `closeOnEscape?` | `boolean` | Whether the popup will be closed when the user presses the escape key. Escape only reaches the topmost open popup. When that popup sets this to `false`, Escape closes nothing, not even the popups underneath it. Default: true. |
541
+ | `closeOnMouseLeave?` | `boolean` | Whether the popup will be closed when the mouse leaves the anchor element. Default: false. |
542
+ | `closeOnOutsideClick?` | `boolean` | Whether the popup will be closed when the user clicks outside of it. Clicks on the backdrop are governed by `closeOnBackdropClick` instead. Default: true. |
543
+ | `closeOnScroll?` | `boolean` | Whether the popup will be closed when the user scrolls the page or a scrollable container around the anchor. Default: false. |
544
+ | `content` | `TemplateRef<C> \| ComponentType<C>` | The content to display in the popup. |
545
+ | `data?` | `T` | Optional data to pass to the popup context. |
546
+ | `hasBackdrop?` | `boolean` | Whether the popup will have a backdrop. Default: false. |
547
+ | `height?` | `number \| string` | Height of the popup. |
548
+ | `injector?` | `Injector` | Parent injector for the popup content. Component content resolves its dependencies here, after `providers`. Pass the injector of the component that opens the popup so its content can use services provided by that component, its ancestors or a lazy-loaded route. Default: the root injector. |
549
+ | `maxHeight?` | `number \| string` | Maximum height of the popup. |
550
+ | `maxWidth?` | `number \| string` | Maximum width of the popup. |
551
+ | `minHeight?` | `number \| string` | Minimum height of the popup. |
552
+ | `minWidth?` | `number \| string` | Minimum width of the popup. |
553
+ | `offset?` | `PopupOffset` | Offset of the popup. |
554
+ | `popupClass?` | `string \| string[]` | Classes to be applied to the popup. |
555
+ | `popupConnectionPoint?` | `ConnectionPoint \| null` | The connection point of the popup element to which the anchor will be connected. |
556
+ | `popupWrapperClass?` | `string \| string[]` | Classes to be applied to the popup wrapper content div. |
557
+ | `positions?` | `Array<ConnectedPosition \| ConnectionPositionPair>` | The positions to use for the popup. The popup will try to position itself in the first position that fits. This is only used when `positionStrategy` is set to `connected`. |
558
+ | `positionStrategy?` | `"global" \| "connected"` | The strategy for positioning the popup. `global` means the popup will be positioned relative to the viewport, `connected` means the popup will be positioned relative to the anchor element. |
559
+ | `preventClose?` | `Action<PopupCloseEvent, boolean>` | Optional callback invoked when the popup is about to close. Return `true` to cancel the close. Takes priority over `PopupCloseEvent.preventDefault()`. |
560
+ | `providers?` | `StaticProvider[]` | Additional Angular providers made available within the popup's injector. Use this to inject services or values that the popup content component needs. |
561
+ | `restoreFocus?` | `boolean \| "auto"` | Controls focus restoration behavior when the popup is closed. - true: Always restore focus to anchor - false: Never restore focus (recommended for tooltips) - "auto": Only restore focus if the anchor, or an element inside it, was focused when the popup opened; focus returns to that element Focus is only restored while it is on the page itself, inside the popup or inside the anchor. If the user moved it elsewhere, for example by clicking another field, it stays there. Default: "auto". |
562
+ | `width?` | `number \| string` | Width of the popup. |
563
+ | `withPush?` | `boolean` | Whether the CDK overlay should push the popup into the visible viewport when it would otherwise overflow the screen edges. Default: true. |
564
+ | `withScrollTracking?` | `boolean` | Whether the popup should track scroll events and reposition itself. Default: true. |
565
+
566
+ #### `ConnectionPoint`
567
+
568
+ ```typescript
569
+ type ConnectionPoint = | "topleft" | "topcenter" | "topright" | "centerleft" | "center" | "centerright" | "bottomleft" | "bottomcenter" | "bottomright";
570
+ ```
571
+
572
+ #### `PopupAnchor`
573
+
574
+ ```typescript
575
+ type PopupAnchor = FlexibleConnectedPositionStrategyOrigin | string;
576
+ ```
577
+
578
+ #### `PopupCloseSource`
579
+
580
+ | Member | Value | Description |
581
+ | --- | --- | --- |
582
+ | `Action` | `"action"` | A dialog action button, such as OK or Cancel. |
583
+ | `BackdropClick` | `"backdropClick"` | A click on the backdrop, when `closeOnBackdropClick` allows it. |
584
+ | `CloseButton` | `"closeButton"` | The close button of a dialog, window or sheet. |
585
+ | `Escape` | `"escape"` | The Escape key. |
586
+ | `MouseLeave` | `"mouseLeave"` | The pointer leaving the anchor, when `closeOnMouseLeave` is set. |
587
+ | `Programmatic` | `"programmatic"` | A `close()` call from code, with no user interaction behind it. |
588
+ | `OutsideClick` | `"outsideClick"` | A pointer press outside the popup and its anchor. |
589
+ | `Scroll` | `"scroll"` | The anchor scrolling away, when `closeOnScroll` is set. |
590
+
591
+ #### `Action`
592
+
593
+ From `@nanahoshi/mona-ui/common`.
594
+
595
+ A function taking a `P` and returning an `R`.
596
+
597
+ ```typescript
598
+ type Action<P = void, R = void> = (arg: P) => R;
599
+ ```
600
+
601
+ #### `PreventableEvent`
602
+
603
+ From `@nanahoshi/mona-ui/common`.
604
+
605
+ **Type parameters:** `E extends Event = Event`
606
+
607
+ | Name | Type | Description |
608
+ | --- | --- | --- |
609
+ | `originalEvent` (read-only) | `E \| undefined` | The DOM event that caused this one, when there is one. |
610
+ | `type` (read-only) | `string \| undefined` | A name for the kind of event, when the component that emits it sets one. |
611
+
612
+ **Methods**
613
+
614
+ | Signature | Description |
615
+ | --- | --- |
616
+ | `isDefaultPrevented(): boolean` | Whether `preventDefault()` was called. |
617
+ | `preventDefault(): void` | Cancels what the event announces, such as opening or closing a popup, or closing a dialog. |