@nanahoshi/mona-ui 0.24.7 → 0.24.9

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 (97) hide show
  1. package/fesm2022/nanahoshi-mona-ui-auto-complete.mjs +1 -1
  2. package/fesm2022/nanahoshi-mona-ui-button-group.mjs +37 -9
  3. package/fesm2022/nanahoshi-mona-ui-button.mjs +8 -2
  4. package/fesm2022/nanahoshi-mona-ui-color-gradient.mjs +4 -3
  5. package/fesm2022/nanahoshi-mona-ui-combo-box.mjs +1 -1
  6. package/fesm2022/nanahoshi-mona-ui-contextmenu.mjs +101 -47
  7. package/fesm2022/nanahoshi-mona-ui-dialog.mjs +339 -101
  8. package/fesm2022/nanahoshi-mona-ui-dropdown-button.mjs +119 -69
  9. package/fesm2022/nanahoshi-mona-ui-dropdown-list.mjs +1 -1
  10. package/fesm2022/nanahoshi-mona-ui-editor.mjs +2 -2
  11. package/fesm2022/{nanahoshi-mona-ui-grid-grid-footer-row.component-vXXNWmEN.mjs → nanahoshi-mona-ui-grid-grid-footer-row.component-DhKLnW06.mjs} +2 -2
  12. package/fesm2022/{nanahoshi-mona-ui-grid-grid-list.component-DDgNmgE0.mjs → nanahoshi-mona-ui-grid-grid-list.component-voGbKOiB.mjs} +4 -4
  13. package/fesm2022/{nanahoshi-mona-ui-grid-grid-row.component-Dzf6Vbs_.mjs → nanahoshi-mona-ui-grid-grid-row.component-HQ1Kv6R9.mjs} +2 -3
  14. package/fesm2022/{nanahoshi-mona-ui-grid-grid-virtual-list.component-DAPNqnWV.mjs → nanahoshi-mona-ui-grid-grid-virtual-list.component-PNLJFcuH.mjs} +4 -4
  15. package/fesm2022/{nanahoshi-mona-ui-grid-nanahoshi-mona-ui-grid-B9rmDLq8.mjs → nanahoshi-mona-ui-grid-nanahoshi-mona-ui-grid-BO19AVwC.mjs} +10 -10
  16. package/fesm2022/nanahoshi-mona-ui-grid.mjs +1 -1
  17. package/fesm2022/nanahoshi-mona-ui-i18n-icu.mjs +44 -3
  18. package/fesm2022/nanahoshi-mona-ui-internal-filter-input.mjs +20 -4
  19. package/fesm2022/nanahoshi-mona-ui-internal-list.mjs +335 -45
  20. package/fesm2022/nanahoshi-mona-ui-internal-tree.mjs +565 -197
  21. package/fesm2022/nanahoshi-mona-ui-internal.mjs +465 -23
  22. package/fesm2022/nanahoshi-mona-ui-list-box.mjs +598 -208
  23. package/fesm2022/nanahoshi-mona-ui-list-view.mjs +193 -71
  24. package/fesm2022/nanahoshi-mona-ui-locales-ar-sa.mjs +29 -3
  25. package/fesm2022/nanahoshi-mona-ui-locales-de-de.mjs +33 -3
  26. package/fesm2022/nanahoshi-mona-ui-locales-es-es.mjs +33 -3
  27. package/fesm2022/nanahoshi-mona-ui-locales-fr-fr.mjs +40 -3
  28. package/fesm2022/nanahoshi-mona-ui-locales-id-id.mjs +29 -3
  29. package/fesm2022/nanahoshi-mona-ui-locales-it-it.mjs +33 -3
  30. package/fesm2022/nanahoshi-mona-ui-locales-ja-jp.mjs +29 -3
  31. package/fesm2022/nanahoshi-mona-ui-locales-ko-kr.mjs +29 -3
  32. package/fesm2022/nanahoshi-mona-ui-locales-pt-br.mjs +33 -3
  33. package/fesm2022/nanahoshi-mona-ui-locales-ru-ru.mjs +49 -3
  34. package/fesm2022/nanahoshi-mona-ui-locales-tr-tr.mjs +29 -3
  35. package/fesm2022/nanahoshi-mona-ui-locales-zh-cn.mjs +29 -3
  36. package/fesm2022/nanahoshi-mona-ui-locales-zh-tw.mjs +29 -3
  37. package/fesm2022/nanahoshi-mona-ui-menubar.mjs +127 -133
  38. package/fesm2022/nanahoshi-mona-ui-multi-select.mjs +1 -1
  39. package/fesm2022/nanahoshi-mona-ui-notification.mjs +473 -240
  40. package/fesm2022/nanahoshi-mona-ui-popover.mjs +202 -90
  41. package/fesm2022/nanahoshi-mona-ui-popup-menu.mjs +609 -256
  42. package/fesm2022/nanahoshi-mona-ui-popup.mjs +2 -0
  43. package/fesm2022/nanahoshi-mona-ui-sheet.mjs +45 -10
  44. package/fesm2022/nanahoshi-mona-ui-split-button.mjs +102 -58
  45. package/fesm2022/nanahoshi-mona-ui-tooltip.mjs +286 -443
  46. package/fesm2022/nanahoshi-mona-ui-tree-view.mjs +205 -140
  47. package/fesm2022/nanahoshi-mona-ui-window.mjs +591 -310
  48. package/i18n/catalogs/en-US.messages.json +32 -6
  49. package/locales/ar-sa/ar-sa.messages.json +29 -3
  50. package/locales/de-de/de-de.messages.json +29 -3
  51. package/locales/es-es/es-es.messages.json +29 -3
  52. package/locales/fr-fr/fr-fr.messages.json +29 -3
  53. package/locales/id-id/id-id.messages.json +29 -3
  54. package/locales/it-it/it-it.messages.json +29 -3
  55. package/locales/ja-jp/ja-jp.messages.json +29 -3
  56. package/locales/ko-kr/ko-kr.messages.json +29 -3
  57. package/locales/pt-br/pt-br.messages.json +29 -3
  58. package/locales/ru-ru/ru-ru.messages.json +29 -3
  59. package/locales/tr-tr/tr-tr.messages.json +29 -3
  60. package/locales/zh-cn/zh-cn.messages.json +29 -3
  61. package/locales/zh-tw/zh-tw.messages.json +29 -3
  62. package/package.json +1 -1
  63. package/types/nanahoshi-mona-ui-button-group.d.ts +13 -3
  64. package/types/nanahoshi-mona-ui-button.d.ts +20 -3
  65. package/types/nanahoshi-mona-ui-contextmenu.d.ts +5 -6
  66. package/types/nanahoshi-mona-ui-dialog.d.ts +131 -20
  67. package/types/nanahoshi-mona-ui-dropdown-button.d.ts +75 -56
  68. package/types/nanahoshi-mona-ui-i18n.d.ts +69 -0
  69. package/types/nanahoshi-mona-ui-internal-filter-input.d.ts +14 -2
  70. package/types/nanahoshi-mona-ui-internal-list.d.ts +89 -10
  71. package/types/nanahoshi-mona-ui-internal-tree.d.ts +155 -40
  72. package/types/nanahoshi-mona-ui-internal.d.ts +128 -16
  73. package/types/nanahoshi-mona-ui-list-box.d.ts +148 -47
  74. package/types/nanahoshi-mona-ui-list-view.d.ts +112 -21
  75. package/types/nanahoshi-mona-ui-locales-ar-sa.d.ts +26 -0
  76. package/types/nanahoshi-mona-ui-locales-de-de.d.ts +26 -0
  77. package/types/nanahoshi-mona-ui-locales-es-es.d.ts +26 -0
  78. package/types/nanahoshi-mona-ui-locales-fr-fr.d.ts +26 -0
  79. package/types/nanahoshi-mona-ui-locales-id-id.d.ts +26 -0
  80. package/types/nanahoshi-mona-ui-locales-it-it.d.ts +26 -0
  81. package/types/nanahoshi-mona-ui-locales-ja-jp.d.ts +26 -0
  82. package/types/nanahoshi-mona-ui-locales-ko-kr.d.ts +26 -0
  83. package/types/nanahoshi-mona-ui-locales-pt-br.d.ts +26 -0
  84. package/types/nanahoshi-mona-ui-locales-ru-ru.d.ts +26 -0
  85. package/types/nanahoshi-mona-ui-locales-tr-tr.d.ts +26 -0
  86. package/types/nanahoshi-mona-ui-locales-zh-cn.d.ts +26 -0
  87. package/types/nanahoshi-mona-ui-locales-zh-tw.d.ts +26 -0
  88. package/types/nanahoshi-mona-ui-menubar.d.ts +65 -62
  89. package/types/nanahoshi-mona-ui-notification.d.ts +76 -16
  90. package/types/nanahoshi-mona-ui-popover.d.ts +44 -17
  91. package/types/nanahoshi-mona-ui-popup-menu.d.ts +110 -32
  92. package/types/nanahoshi-mona-ui-popup.d.ts +2 -0
  93. package/types/nanahoshi-mona-ui-sheet.d.ts +16 -5
  94. package/types/nanahoshi-mona-ui-split-button.d.ts +29 -7
  95. package/types/nanahoshi-mona-ui-tooltip.d.ts +43 -20
  96. package/types/nanahoshi-mona-ui-tree-view.d.ts +84 -40
  97. package/types/nanahoshi-mona-ui-window.d.ts +103 -14
@@ -1,5 +1,5 @@
1
1
  import * as i0 from '@angular/core';
2
- import { ViewContainerRef, TemplateRef, Type, ComponentRef } from '@angular/core';
2
+ import { ViewContainerRef, TemplateRef, Type, ComponentRef, EnvironmentProviders, InjectionToken } from '@angular/core';
3
3
  import { Observable } from 'rxjs';
4
4
 
5
5
  /**
@@ -18,8 +18,9 @@ interface NotificationOptions {
18
18
  */
19
19
  appendTo?: ViewContainerRef;
20
20
  /**
21
- * @description Whether a close button is rendered on the notification.
22
- * @default true when `duration` is not set, otherwise `false`
21
+ * @description Whether a close button is rendered on the notification. Timed notifications have one too, so
22
+ * they can be dismissed before their time is up.
23
+ * @default true
23
24
  */
24
25
  closable?: boolean;
25
26
  /**
@@ -28,10 +29,18 @@ interface NotificationOptions {
28
29
  closeTitle?: string;
29
30
  /**
30
31
  * @description The notification's content. Accepts plain text, a `TemplateRef`, or a component `Type` to render.
32
+ * A template gets the `NotificationRef` as `$implicit` and `data` as `data`; a component can inject
33
+ * `NOTIFICATION_REF` and `NOTIFICATION_DATA`.
31
34
  */
32
35
  content: string | TemplateRef<unknown> | Type<unknown>;
36
+ /**
37
+ * @description Data for a content component or template, available through `NOTIFICATION_DATA` or the
38
+ * template's `data` context property.
39
+ */
40
+ data?: unknown;
33
41
  /**
34
42
  * @description The time, in milliseconds, before the notification automatically closes. Omit to keep the notification open until manually closed.
43
+ * The countdown pauses while the notification is hovered or has focus, and while the window is in the background.
35
44
  */
36
45
  duration?: number;
37
46
  /**
@@ -40,7 +49,7 @@ interface NotificationOptions {
40
49
  height?: number | string;
41
50
  /**
42
51
  * @description A unique identifier for the notification. Reusing an `id` for the same `position` returns the existing notification instead of creating a new one.
43
- * @default a generated UUID
52
+ * @default a generated id
44
53
  */
45
54
  id?: string;
46
55
  /**
@@ -67,9 +76,13 @@ interface NotificationOptions {
67
76
  width?: number | string;
68
77
  }
69
78
 
79
+ /**
80
+ * @description The options `NotificationRef.update()` can change on a notification that is already shown.
81
+ */
82
+ type NotificationUpdate = Partial<Pick<NotificationOptions, "closable" | "content" | "title" | "type">>;
70
83
  interface NotificationRef {
71
84
  /**
72
- * @description Emits once the notification has finished closing and been removed.
85
+ * @description Emits once the notification has finished closing, after its leave animation, and been removed.
73
86
  */
74
87
  readonly afterHide: Observable<void>;
75
88
  /**
@@ -80,34 +93,81 @@ interface NotificationRef {
80
93
  * @description Closes the notification.
81
94
  */
82
95
  hide(): void;
96
+ /**
97
+ * @description The notification's id: the one given in its options, or a generated one.
98
+ */
99
+ readonly id: string;
100
+ /**
101
+ * @description Changes the content, title, type or close button of the notification. The new message is
102
+ * announced to assistive technology.
103
+ */
104
+ update(changes: NotificationUpdate): void;
83
105
  }
84
106
 
85
107
  declare class NotificationService {
86
108
  #private;
87
- private notificationContainerMap;
88
- private notificationContainerSubscriptions;
89
109
  constructor();
90
110
  hide(id: string): void;
91
111
  hideAll(): void;
92
112
  show(options: NotificationOptions): NotificationRef;
93
- private createContainerComponent;
94
- private createNotification;
95
- private createNotificationContainer;
96
- private getNotificationDataById;
97
- private initialize;
98
- private removeNotificationData;
99
- private scheduleTimeout;
100
113
  static ɵfac: i0.ɵɵFactoryDeclaration<NotificationService, never>;
101
114
  static ɵprov: i0.ɵɵInjectableDeclaration<NotificationService>;
102
115
  }
103
116
 
117
+ /**
118
+ * @description Application-wide settings for notifications, given with `provideNotificationDefaults()`.
119
+ */
120
+ interface NotificationDefaults {
121
+ /**
122
+ * @description Whether notifications with a `duration` close on their own. Turn it off to leave every
123
+ * notification open until the user closes it (WCAG 2.2.1).
124
+ * @default true
125
+ */
126
+ readonly autoHide: boolean;
127
+ /**
128
+ * @description A factor applied to every `duration`, for example `2` to keep notifications twice as long.
129
+ * @default 1
130
+ */
131
+ readonly durationScale: number;
132
+ /**
133
+ * @description The most notifications shown at once at each position. The oldest closes to make room for a new
134
+ * one. Without it, there is no limit.
135
+ */
136
+ readonly maxVisible?: number;
137
+ /**
138
+ * @description Whether the countdown pauses while the browser window doesn't have focus.
139
+ * @default true
140
+ */
141
+ readonly pauseOnWindowBlur: boolean;
142
+ }
143
+
144
+ /**
145
+ * Sets application-wide notification behavior: whether timed notifications close on their own, how much longer they
146
+ * stay, how many show at once, and whether the countdown pauses while the window is in the background.
147
+ */
148
+ declare function provideNotificationDefaults(defaults: Partial<NotificationDefaults>): EnvironmentProviders;
149
+
150
+ /**
151
+ * @description Application-wide notification settings. Provide them with `provideNotificationDefaults()`.
152
+ */
153
+ declare const NOTIFICATION_DEFAULTS: InjectionToken<NotificationDefaults>;
154
+ /**
155
+ * @description The `data` given in the notification's options, for a content component or template to inject.
156
+ */
157
+ declare const NOTIFICATION_DATA: InjectionToken<unknown>;
158
+ /**
159
+ * @description The reference of the notification a content component or template is shown in.
160
+ */
161
+ declare const NOTIFICATION_REF: InjectionToken<NotificationRef>;
162
+
104
163
  declare const NOTIFICATION_DEFAULT_MESSAGES: {
105
164
  close: string;
106
165
  error: string;
107
166
  info: string;
167
+ region: string;
108
168
  success: string;
109
169
  warning: string;
110
170
  };
111
171
 
112
- export { NOTIFICATION_DEFAULT_MESSAGES, NotificationService };
113
- export type { NotificationOptions, NotificationPosition, NotificationRef, NotificationType };
172
+ export { NOTIFICATION_DATA, NOTIFICATION_DEFAULTS, NOTIFICATION_DEFAULT_MESSAGES, NOTIFICATION_REF, NotificationService, provideNotificationDefaults };
173
+ export type { NotificationDefaults, NotificationOptions, NotificationPosition, NotificationRef, NotificationType, NotificationUpdate };
@@ -1,9 +1,10 @@
1
+ import * as _nanahoshi_mona_ui_internal from '@nanahoshi/mona-ui/internal';
2
+ import { VariantInputs, PhysicalOverlaySide, OverlaySide } from '@nanahoshi/mona-ui/internal';
1
3
  import * as _angular_core from '@angular/core';
2
4
  import { TemplateRef, ElementRef } from '@angular/core';
3
- import { PreventableEvent, Position } from '@nanahoshi/mona-ui/common';
5
+ import { PreventableEvent } from '@nanahoshi/mona-ui/common';
4
6
  import { PopupRef } from '@nanahoshi/mona-ui/popup';
5
7
  import * as class_variance_authority_types from 'class-variance-authority/types';
6
- import { VariantInputs } from '@nanahoshi/mona-ui/internal';
7
8
  import { VariantProps } from 'class-variance-authority';
8
9
 
9
10
  declare class PopoverHideEvent extends PreventableEvent {
@@ -55,31 +56,51 @@ declare class PopoverComponent implements PopoverVariantInputs {
55
56
  protected readonly arrowClasses: _angular_core.Signal<string>;
56
57
  protected readonly baseClasses: _angular_core.Signal<string>;
57
58
  protected readonly contentClasses: _angular_core.Signal<string>;
58
- protected readonly currentArrowPosition: _angular_core.Signal<Position>;
59
+ protected readonly currentArrowPosition: _angular_core.WritableSignal<PhysicalOverlaySide>;
59
60
  protected readonly footerTemplateRef: _angular_core.Signal<TemplateRef<any> | undefined>;
61
+ protected readonly hasTitle: _angular_core.Signal<boolean>;
60
62
  protected readonly headerClasses: _angular_core.Signal<string>;
61
63
  protected readonly headerId: _angular_core.Signal<string | null>;
62
- protected readonly titleTemplateRef: _angular_core.Signal<TemplateRef<any> | undefined>;
63
64
  protected readonly templateRef: _angular_core.Signal<TemplateRef<any>>;
65
+ protected readonly titleTemplateRef: _angular_core.Signal<TemplateRef<any> | undefined>;
64
66
  protected readonly uid: string;
65
- protected popupRef: PopupRef | null;
67
+ /**
68
+ * @description Accessible name for the popover when it has no `title` or title template.
69
+ */
70
+ readonly ariaLabel: _angular_core.InputSignal<string | undefined>;
71
+ /**
72
+ * @description Whether focus moves into the popover when it opens: to its first focusable element, or to the
73
+ * popover itself. Defaults to `true`, except for the `hover` trigger.
74
+ */
75
+ readonly autoFocus: _angular_core.InputSignal<boolean | undefined>;
76
+ /**
77
+ * @description Whether pressing Escape closes the popover.
78
+ * @default true
79
+ */
80
+ readonly closeOnEscape: _angular_core.InputSignal<boolean>;
81
+ /**
82
+ * @description Whether a click outside the popover and its target closes it.
83
+ * @default true
84
+ */
85
+ readonly closeOnOutsideClick: _angular_core.InputSignal<boolean>;
66
86
  /**
67
87
  * @description Display the arrow of the popover.
68
88
  */
69
89
  readonly displayArrow: _angular_core.InputSignal<boolean>;
90
+ /**
91
+ * @description Emits when the popover is hidden.
92
+ */
93
+ readonly hidden: _angular_core.OutputEmitterRef<void>;
70
94
  /**
71
95
  * @description Emits when the popover is about to be closed.
72
96
  * This event is preventable.
73
97
  */
74
98
  readonly hide: _angular_core.OutputEmitterRef<PopoverHideEvent>;
75
99
  /**
76
- * @description Emits when the popover is hidden.
77
- */
78
- readonly hidden: _angular_core.OutputEmitterRef<void>;
79
- /**
80
- * @description The position of the popover relative to the target element.
100
+ * @description The side of the target the popover opens on. `left` and `right` are physical; `start` and `end`
101
+ * follow the text direction. It flips to the opposite side when there isn't room.
81
102
  */
82
- readonly position: _angular_core.InputSignal<Position>;
103
+ readonly position: _angular_core.InputSignal<_nanahoshi_mona_ui_internal.OverlaySide>;
83
104
  /**
84
105
  * @description The border radius of the popover.
85
106
  */
@@ -90,7 +111,7 @@ declare class PopoverComponent implements PopoverVariantInputs {
90
111
  */
91
112
  readonly show: _angular_core.OutputEmitterRef<PopoverShowEvent>;
92
113
  /**
93
- * @description Emits when the popover is shown.
114
+ * @description Emits once the popover has opened.
94
115
  */
95
116
  readonly shown: _angular_core.OutputEmitterRef<PopoverShownEvent>;
96
117
  /**
@@ -103,16 +124,16 @@ declare class PopoverComponent implements PopoverVariantInputs {
103
124
  readonly title: _angular_core.InputSignal<string>;
104
125
  /**
105
126
  * @description The trigger that opens/closes the popover.
106
- * "click" toggles on click, "hover" opens on pointer enter and closes on
107
- * pointer leave, "none" disables automatic triggering (use `open()`/`close()`
108
- * instead). Any other DOM event name is also accepted and used as-is.
127
+ * "click" toggles on click, "hover" opens while the pointer is on the target or the popover, or focus is on the
128
+ * target, "none" disables automatic triggering (use `open()`/`close()` instead). Any other DOM event name is
129
+ * also accepted and used as-is.
109
130
  */
110
131
  readonly trigger: _angular_core.InputSignal<PopoverTrigger>;
111
132
  constructor();
112
133
  close(): void;
113
134
  open(): void;
114
135
  static ɵfac: _angular_core.ɵɵFactoryDeclaration<PopoverComponent, never>;
115
- static ɵcmp: _angular_core.ɵɵComponentDeclaration<PopoverComponent, "mona-popover", ["monaPopover"], { "displayArrow": { "alias": "displayArrow"; "required": false; "isSignal": true; }; "position": { "alias": "position"; "required": false; "isSignal": true; }; "rounded": { "alias": "rounded"; "required": false; "isSignal": true; }; "target": { "alias": "target"; "required": true; "isSignal": true; }; "title": { "alias": "title"; "required": false; "isSignal": true; }; "trigger": { "alias": "trigger"; "required": false; "isSignal": true; }; }, { "hide": "hide"; "hidden": "hidden"; "show": "show"; "shown": "shown"; }, ["footerTemplateRef", "titleTemplateRef"], ["*"], true, never>;
136
+ static ɵcmp: _angular_core.ɵɵComponentDeclaration<PopoverComponent, "mona-popover", ["monaPopover"], { "ariaLabel": { "alias": "ariaLabel"; "required": false; "isSignal": true; }; "autoFocus": { "alias": "autoFocus"; "required": false; "isSignal": true; }; "closeOnEscape": { "alias": "closeOnEscape"; "required": false; "isSignal": true; }; "closeOnOutsideClick": { "alias": "closeOnOutsideClick"; "required": false; "isSignal": true; }; "displayArrow": { "alias": "displayArrow"; "required": false; "isSignal": true; }; "position": { "alias": "position"; "required": false; "isSignal": true; }; "rounded": { "alias": "rounded"; "required": false; "isSignal": true; }; "target": { "alias": "target"; "required": true; "isSignal": true; }; "title": { "alias": "title"; "required": false; "isSignal": true; }; "trigger": { "alias": "trigger"; "required": false; "isSignal": true; }; }, { "hidden": "hidden"; "hide": "hide"; "show": "show"; "shown": "shown"; }, ["footerTemplateRef", "titleTemplateRef"], ["*"], true, never>;
116
137
  }
117
138
 
118
139
  declare class PopoverFooterTemplateDirective {
@@ -125,5 +146,11 @@ declare class PopoverTitleTemplateDirective {
125
146
  static ɵdir: _angular_core.ɵɵDirectiveDeclaration<PopoverTitleTemplateDirective, "ng-template[monaPopoverTitleTemplate]", never, {}, {}, never, never, true, never>;
126
147
  }
127
148
 
149
+ /**
150
+ * The side of its target a popover opens on. `left` and `right` are physical in every direction; `start` and `end`
151
+ * follow the text direction.
152
+ */
153
+ type PopoverPosition = OverlaySide;
154
+
128
155
  export { PopoverComponent, PopoverFooterTemplateDirective, PopoverHideEvent, PopoverShowEvent, PopoverShownEvent, PopoverTitleTemplateDirective };
129
- export type { PopoverTrigger };
156
+ export type { PopoverPosition, PopoverTrigger };
@@ -1,22 +1,34 @@
1
1
  import * as _angular_core from '@angular/core';
2
2
  import { Signal, TemplateRef, ElementRef, InjectionToken, OnInit } from '@angular/core';
3
- import * as _mirei_ts_collections from '@mirei/ts-collections';
4
- import { PreventableEvent, ClassInputType } from '@nanahoshi/mona-ui/common';
5
- import { PopupCloseEvent, PopupRef, ConnectionPoint, PopupOffset } from '@nanahoshi/mona-ui/popup';
6
3
  import { Subject } from 'rxjs';
4
+ import { PreventableEvent, ClassInputType } from '@nanahoshi/mona-ui/common';
5
+ import { PopupCloseEvent, ConnectionPoint, PopupOffset } from '@nanahoshi/mona-ui/popup';
7
6
  import * as class_variance_authority_types from 'class-variance-authority/types';
8
7
  import { VariantProps } from 'class-variance-authority';
9
8
  import { VariantInputs } from '@nanahoshi/mona-ui/internal';
10
9
  import * as _nanahoshi_mona_ui_popup_menu from '@nanahoshi/mona-ui/popup-menu';
11
10
 
12
- declare class PopupMenuCloseEvent extends PreventableEvent {
13
- constructor(originalEvent?: PopupCloseEvent);
14
- }
15
-
11
+ /**
12
+ * Emitted when a menu item is activated by a click, Enter or Space. Preventing it keeps the menu open and leaves a
13
+ * checkbox or radio item's state unchanged.
14
+ */
16
15
  declare class PopupMenuItemClickEvent extends PreventableEvent {
17
16
  #private;
18
17
  constructor(item: PopupMenuItem, originalEvent: MouseEvent);
18
+ /**
19
+ * For a checkbox or radio item, the state the item has once the click is applied (if it isn't prevented).
20
+ * `undefined` for other items.
21
+ */
22
+ get checked(): boolean | undefined;
19
23
  get item(): PopupMenuItem;
24
+ /**
25
+ * The item's label.
26
+ */
27
+ get label(): string;
28
+ /**
29
+ * The item's `value`: the `value` input of the item component, or the `value` of a `MenuItem`.
30
+ */
31
+ get value(): unknown;
20
32
  }
21
33
 
22
34
  interface PopupMenuItem {
@@ -24,33 +36,57 @@ interface PopupMenuItem {
24
36
  checked?: Signal<boolean>;
25
37
  click$?: Subject<PopupMenuItemClickEvent>;
26
38
  disabled: boolean;
39
+ /**
40
+ * The group the item belongs to. Consecutive items with the same key form a group. A string key, or a symbol
41
+ * with a description, is the group's title.
42
+ */
27
43
  group: string | symbol;
28
- groupTemplate: Signal<TemplateRef<any> | null> | null;
29
- iconTemplate: Signal<TemplateRef<any> | null> | null;
44
+ groupTemplate: Signal<TemplateRef<unknown> | null> | null;
45
+ iconTemplate: Signal<TemplateRef<unknown> | null> | null;
30
46
  items: PopupMenuItem[];
31
47
  label: string;
32
48
  radio?: boolean;
33
49
  selected?: Signal<boolean>;
34
50
  separator?: boolean;
35
- shortcutTemplate: Signal<TemplateRef<any> | null> | null;
36
- textTemplate: Signal<TemplateRef<any> | null> | null;
51
+ shortcutTemplate: Signal<TemplateRef<unknown> | null> | null;
52
+ textTemplate: Signal<TemplateRef<unknown> | null> | null;
37
53
  uid: string;
38
- value?: Signal<string>;
54
+ value?: Signal<unknown>;
39
55
  }
40
56
  interface MenuItem {
57
+ /**
58
+ * Whether the item is a checkbox item. Its `checked` state toggles when it's activated, unless `menuClick` is
59
+ * prevented. The state lives in the menu: read the new state from the event's `checked` and keep it in your
60
+ * items if they can be replaced.
61
+ */
41
62
  checkable?: boolean;
42
63
  checked?: boolean;
43
64
  disabled?: boolean;
65
+ /**
66
+ * The title of the group the item belongs to. Consecutive items with the same group form one group.
67
+ */
44
68
  group?: string;
45
69
  items?: MenuItem[];
46
70
  label: string;
47
71
  separator?: boolean;
72
+ /**
73
+ * A value that identifies the item in `menuClick` (the event's `value`).
74
+ */
75
+ value?: unknown;
48
76
  }
49
77
 
50
- interface PopupMenuNavigationEvent {
51
- direction: "up" | "down" | "left" | "right";
52
- item: PopupMenuItem | null;
53
- level: number;
78
+ /** A run of consecutive menu items that share a group key. */
79
+ interface PopupMenuItemGroup {
80
+ readonly items: readonly PopupMenuItem[];
81
+ readonly key: string | symbol;
82
+ /** The id of the group's title element, when it has a title. */
83
+ readonly labelId: string;
84
+ /** The group's title: a string key, or a symbol key's description. Empty for ungrouped items. */
85
+ readonly title: string;
86
+ }
87
+
88
+ declare class PopupMenuCloseEvent extends PreventableEvent {
89
+ constructor(originalEvent?: PopupCloseEvent);
54
90
  }
55
91
 
56
92
  declare const popupMenuBaseThemeVariants: (props?: ({
@@ -77,6 +113,15 @@ type PopupMenuLinkVariantProps = VariantProps<typeof popupMenuLinkThemeVariants>
77
113
  type PopupMenuVariantProps = PopupMenuBaseVariantProps & PopupMenuContainerVariantProps & PopupMenuGroupHeaderVariantProps & PopupMenuIconContainerVariantProps & PopupMenuItemVariantProps & PopupMenuLinkVariantProps;
78
114
  type PopupMenuVariantInput = VariantInputs<PopupMenuVariantProps>;
79
115
 
116
+ interface PopupMenuNavigationEvent {
117
+ direction: "up" | "down" | "left" | "right";
118
+ item: PopupMenuItem | null;
119
+ level: number;
120
+ }
121
+
122
+ /** The item a menu opened from the keyboard highlights first. */
123
+ type PopupMenuInitialFocus = "first" | "last";
124
+
80
125
  declare class PopupMenuComponent implements PopupMenuVariantInput {
81
126
  #private;
82
127
  private readonly groupTemplateConfig;
@@ -84,8 +129,7 @@ declare class PopupMenuComponent implements PopupMenuVariantInput {
84
129
  private readonly nestedComponents;
85
130
  private readonly shortcutTemplateConfig;
86
131
  private readonly textTemplateConfig;
87
- protected readonly menuItems: _angular_core.Signal<_mirei_ts_collections.ImmutableSet<_mirei_ts_collections.IGroup<string | symbol, PopupMenuItem>>>;
88
- protected popupRef: PopupRef | null;
132
+ protected readonly menuItems: _angular_core.Signal<PopupMenuItemGroup[]>;
89
133
  /**
90
134
  * @description The anchor element that the context menu will be anchored to.
91
135
  * Only applicable when `precise` is set to `false`.
@@ -96,6 +140,15 @@ declare class PopupMenuComponent implements PopupMenuVariantInput {
96
140
  * Only applicable when `precise` is set to `false`.
97
141
  */
98
142
  readonly anchorConnectionPoint: _angular_core.InputSignal<ConnectionPoint | null | undefined>;
143
+ /**
144
+ * @description The accessible name of the root menu. Takes precedence over `ariaLabelledBy`.
145
+ */
146
+ readonly ariaLabel: _angular_core.InputSignal<string>;
147
+ /**
148
+ * @description The ids of the elements that name the root menu. When neither this nor `ariaLabel` is set, the
149
+ * menu is named by the target element if it has an id.
150
+ */
151
+ readonly ariaLabelledBy: _angular_core.InputSignal<string>;
99
152
  /**
100
153
  * @description The event that is emitted when the popup menu is closed.
101
154
  */
@@ -160,26 +213,44 @@ declare class PopupMenuComponent implements PopupMenuVariantInput {
160
213
  * @description The event that triggers the popup menu.
161
214
  */
162
215
  readonly trigger: _angular_core.InputSignal<string>;
216
+ readonly userClass: _angular_core.InputSignalWithTransform<string | undefined, ClassInputType>;
163
217
  /**
164
218
  * @description Sets the width of the popup menu.
165
219
  * This will be applied to the root menu and all submenus.
166
220
  */
167
221
  readonly width: _angular_core.InputSignal<string | number | undefined>;
168
- readonly userClass: _angular_core.InputSignalWithTransform<string | undefined, ClassInputType>;
169
222
  constructor();
223
+ /**
224
+ * @description Keeps focus where it is when the open menu closes, instead of returning it to the element that
225
+ * had it before the menu opened. Used when another menu takes over, as in a menubar.
226
+ */
170
227
  clearFocusRestoration(): void;
228
+ /**
229
+ * @description Closes the menu. Focus returns to the element that had it before the menu opened, unless focus
230
+ * has already moved elsewhere.
231
+ */
171
232
  closeMenu(): void;
172
233
  openMenu(viaContextMenuKey: boolean): void;
173
- openMenuViaKeyboard(viaContextMenuKey?: boolean): void;
234
+ /**
235
+ * @description Opens the menu as the keyboard does, with its first (or last) item highlighted.
236
+ * @param viaContextMenuKey Whether the menu opens from the ContextMenu key or Shift+F10.
237
+ * @param focus The item to highlight: "first" (ArrowDown, Enter, Space) or "last" (ArrowUp).
238
+ */
239
+ openMenuViaKeyboard(viaContextMenuKey?: boolean, focus?: PopupMenuInitialFocus): void;
240
+ /**
241
+ * @deprecated Focus now returns to the element that had it before the menu opened after every close.
242
+ */
174
243
  setRestoreFocusForKeyboard(): void;
244
+ private closeFromList;
175
245
  private createMenu;
176
246
  private getPopupAnchor;
247
+ private openFor;
248
+ private restoreFocus;
177
249
  private setMenuItemClickSubscription;
178
250
  private setNavigationSubscription;
179
- private setSubscriptions;
180
251
  private setTriggerSubscription;
181
252
  static ɵfac: _angular_core.ɵɵFactoryDeclaration<PopupMenuComponent, never>;
182
- static ɵcmp: _angular_core.ɵɵComponentDeclaration<PopupMenuComponent, "mona-popup-menu", never, { "anchor": { "alias": "anchor"; "required": false; "isSignal": true; }; "anchorConnectionPoint": { "alias": "anchorConnectionPoint"; "required": false; "isSignal": true; }; "items": { "alias": "items"; "required": false; "isSignal": true; }; "menuId": { "alias": "id"; "required": false; "isSignal": true; }; "minWidth": { "alias": "minWidth"; "required": false; "isSignal": true; }; "offset": { "alias": "offset"; "required": false; "isSignal": true; }; "popupConnectionPoint": { "alias": "popupConnectionPoint"; "required": false; "isSignal": true; }; "precise": { "alias": "precise"; "required": false; "isSignal": true; }; "rounded": { "alias": "rounded"; "required": false; "isSignal": true; }; "size": { "alias": "size"; "required": false; "isSignal": true; }; "target": { "alias": "target"; "required": true; "isSignal": true; }; "trigger": { "alias": "trigger"; "required": false; "isSignal": true; }; "width": { "alias": "width"; "required": false; "isSignal": true; }; "userClass": { "alias": "class"; "required": false; "isSignal": true; }; }, { "close": "close"; "menuClick": "menuClick"; "navigate": "navigate"; "open": "open"; }, ["groupTemplateConfig", "iconTemplateConfig", "nestedComponents", "shortcutTemplateConfig", "textTemplateConfig"], never, true, never>;
253
+ static ɵcmp: _angular_core.ɵɵComponentDeclaration<PopupMenuComponent, "mona-popup-menu", never, { "anchor": { "alias": "anchor"; "required": false; "isSignal": true; }; "anchorConnectionPoint": { "alias": "anchorConnectionPoint"; "required": false; "isSignal": true; }; "ariaLabel": { "alias": "ariaLabel"; "required": false; "isSignal": true; }; "ariaLabelledBy": { "alias": "ariaLabelledBy"; "required": false; "isSignal": true; }; "items": { "alias": "items"; "required": false; "isSignal": true; }; "menuId": { "alias": "id"; "required": false; "isSignal": true; }; "minWidth": { "alias": "minWidth"; "required": false; "isSignal": true; }; "offset": { "alias": "offset"; "required": false; "isSignal": true; }; "popupConnectionPoint": { "alias": "popupConnectionPoint"; "required": false; "isSignal": true; }; "precise": { "alias": "precise"; "required": false; "isSignal": true; }; "rounded": { "alias": "rounded"; "required": false; "isSignal": true; }; "size": { "alias": "size"; "required": false; "isSignal": true; }; "target": { "alias": "target"; "required": true; "isSignal": true; }; "trigger": { "alias": "trigger"; "required": false; "isSignal": true; }; "userClass": { "alias": "class"; "required": false; "isSignal": true; }; "width": { "alias": "width"; "required": false; "isSignal": true; }; }, { "close": "close"; "menuClick": "menuClick"; "navigate": "navigate"; "open": "open"; }, ["groupTemplateConfig", "iconTemplateConfig", "nestedComponents", "shortcutTemplateConfig", "textTemplateConfig"], never, true, never>;
183
254
  }
184
255
 
185
256
  declare const PopupMenuToken: InjectionToken<PopupMenuConfig>;
@@ -195,7 +266,7 @@ interface PopupMenuConfig {
195
266
  }
196
267
  interface PopupTemplateConfig {
197
268
  readonly origin: PopupMenuTemplateOrigin;
198
- readonly template: TemplateRef<any>;
269
+ readonly template: TemplateRef<unknown>;
199
270
  readonly type: PopupMenuTemplateType;
200
271
  }
201
272
  declare enum PopupMenuOrigin {
@@ -232,13 +303,10 @@ declare class PopupMenuCheckboxItemComponent implements PopupMenuConfig, OnInit
232
303
  protected readonly shortcutTemplateConfig: _angular_core.Signal<_nanahoshi_mona_ui_popup_menu.PopupTemplateConfig | undefined>;
233
304
  protected readonly textTemplateConfig: _angular_core.Signal<_nanahoshi_mona_ui_popup_menu.PopupTemplateConfig | undefined>;
234
305
  /**
235
- * @description Sets the checked state of the menu item.
306
+ * @description The checked state of the menu item. Activating the item toggles it (unless its `menuClick` is
307
+ * prevented) and emits `checkedChange`, so it works with or without a two-way binding.
236
308
  */
237
- readonly checked: _angular_core.InputSignal<boolean>;
238
- /**
239
- * @description Emits when the checked state of the menu item changes.
240
- */
241
- readonly checkedChange: _angular_core.OutputEmitterRef<boolean>;
309
+ readonly checked: _angular_core.ModelSignal<boolean>;
242
310
  /**
243
311
  * @description Sets the disabled state of the menu item.
244
312
  */
@@ -254,11 +322,15 @@ declare class PopupMenuCheckboxItemComponent implements PopupMenuConfig, OnInit
254
322
  readonly menuClick: _angular_core.OutputEmitterRef<PopupMenuItemClickEvent>;
255
323
  readonly origin: PopupMenuOrigin;
256
324
  readonly type = PopupMenuItemType.CheckboxMenuItem;
325
+ /**
326
+ * @description A value that identifies the item. It's the `value` of the item's `menuClick` events.
327
+ */
328
+ readonly value: _angular_core.InputSignal<unknown>;
257
329
  getPopupMenuItem(): PopupMenuItem[];
258
330
  ngOnInit(): void;
259
331
  private setSubscriptions;
260
332
  static ɵfac: _angular_core.ɵɵFactoryDeclaration<PopupMenuCheckboxItemComponent, never>;
261
- static ɵcmp: _angular_core.ɵɵComponentDeclaration<PopupMenuCheckboxItemComponent, "mona-popup-menu-checkbox-item", never, { "checked": { "alias": "checked"; "required": false; "isSignal": true; }; "disabled": { "alias": "disabled"; "required": false; "isSignal": true; }; "label": { "alias": "label"; "required": false; "isSignal": true; }; }, { "checkedChange": "checkedChange"; "menuClick": "menuClick"; }, ["shortcutTemplateConfig", "textTemplateConfig"], never, true, never>;
333
+ static ɵcmp: _angular_core.ɵɵComponentDeclaration<PopupMenuCheckboxItemComponent, "mona-popup-menu-checkbox-item", never, { "checked": { "alias": "checked"; "required": false; "isSignal": true; }; "disabled": { "alias": "disabled"; "required": false; "isSignal": true; }; "label": { "alias": "label"; "required": false; "isSignal": true; }; "value": { "alias": "value"; "required": false; "isSignal": true; }; }, { "checked": "checkedChange"; "menuClick": "menuClick"; }, ["shortcutTemplateConfig", "textTemplateConfig"], never, true, never>;
262
334
  }
263
335
 
264
336
  declare class PopupMenuItemComponent implements PopupMenuConfig, OnInit {
@@ -282,11 +354,16 @@ declare class PopupMenuItemComponent implements PopupMenuConfig, OnInit {
282
354
  readonly menuClick: _angular_core.OutputEmitterRef<PopupMenuItemClickEvent>;
283
355
  readonly origin: PopupMenuOrigin;
284
356
  readonly type: PopupMenuItemType;
357
+ /**
358
+ * @description A value that identifies the item. It's the `value` of the item's `menuClick` events, so
359
+ * handlers don't depend on the label's text.
360
+ */
361
+ readonly value: _angular_core.InputSignal<unknown>;
285
362
  getPopupMenuItem(): PopupMenuItem[];
286
363
  ngOnInit(): void;
287
364
  private setSubscriptions;
288
365
  static ɵfac: _angular_core.ɵɵFactoryDeclaration<PopupMenuItemComponent, never>;
289
- static ɵcmp: _angular_core.ɵɵComponentDeclaration<PopupMenuItemComponent, "mona-popup-menu-item", never, { "disabled": { "alias": "disabled"; "required": false; "isSignal": true; }; "label": { "alias": "label"; "required": false; "isSignal": true; }; }, { "menuClick": "menuClick"; }, ["iconTemplateConfig", "items", "shortcutTemplateConfig", "textTemplateConfig"], never, true, never>;
366
+ static ɵcmp: _angular_core.ɵɵComponentDeclaration<PopupMenuItemComponent, "mona-popup-menu-item", never, { "disabled": { "alias": "disabled"; "required": false; "isSignal": true; }; "label": { "alias": "label"; "required": false; "isSignal": true; }; "value": { "alias": "value"; "required": false; "isSignal": true; }; }, { "menuClick": "menuClick"; }, ["iconTemplateConfig", "items", "shortcutTemplateConfig", "textTemplateConfig"], never, true, never>;
290
367
  }
291
368
 
292
369
  declare class PopupMenuGroupComponent implements PopupMenuConfig {
@@ -339,7 +416,8 @@ declare class PopupMenuRadioItemComponent implements PopupMenuConfig, OnInit {
339
416
  readonly label: _angular_core.InputSignal<string>;
340
417
  /**
341
418
  * @description The click event of the menu item.
342
- * Emits when the menu item is selected by keyboard or mouse.
419
+ * Emits when the menu item is selected by keyboard or mouse, before the radio group selects it. Preventing it
420
+ * keeps the group's value and the menu open.
343
421
  */
344
422
  readonly menuClick: _angular_core.OutputEmitterRef<PopupMenuItemClickEvent>;
345
423
  readonly origin: PopupMenuOrigin;
@@ -19,6 +19,8 @@ interface PopupCloseEventOptions<R = unknown, E = unknown> {
19
19
  via?: PopupCloseSource;
20
20
  }
21
21
  declare enum PopupCloseSource {
22
+ /** A dialog action button, such as OK or Cancel. */
23
+ Action = "action",
22
24
  BackdropClick = "backdropClick",
23
25
  CloseButton = "closeButton",
24
26
  Escape = "escape",
@@ -6,7 +6,13 @@ import * as class_variance_authority_types from 'class-variance-authority/types'
6
6
  import { VariantInputs } from '@nanahoshi/mona-ui/internal';
7
7
  import { VariantProps } from 'class-variance-authority';
8
8
 
9
- type SheetSide = "top" | "right" | "bottom" | "left";
9
+ /**
10
+ * Edge the sheet opens from. `left` and `right` are physical, whatever the direction; `start` and `end` follow it
11
+ * (`start` is the left edge in LTR and the right edge in RTL).
12
+ */
13
+ type SheetSide = "bottom" | "end" | "left" | "right" | "start" | "top";
14
+ /** A side resolved to a physical edge. */
15
+ type SheetPhysicalSide = "bottom" | "left" | "right" | "top";
10
16
 
11
17
  /**
12
18
  * `overflow-clip` rather than `overflow-hidden` is deliberate. `hidden` would make the sheet a scroll
@@ -14,12 +20,12 @@ type SheetSide = "top" | "right" | "bottom" | "left";
14
20
  * still has the sheet translated off-screen, which cancels the animation. `clip` cannot scroll.
15
21
  */
16
22
  declare const sheetBaseVariants: (props?: ({
17
- side?: "top" | "right" | "bottom" | "left" | null | undefined;
23
+ side?: "bottom" | "left" | "right" | "top" | null | undefined;
18
24
  } & class_variance_authority_types.ClassProp) | undefined) => string;
19
25
  type SheetVariantProps = VariantProps<typeof sheetBaseVariants>;
20
26
  type SheetVariantInput = VariantInputs<SheetVariantProps>;
21
27
 
22
- declare class SheetComponent implements SheetVariantInput {
28
+ declare class SheetComponent implements Omit<SheetVariantInput, "side"> {
23
29
  #private;
24
30
  private readonly sheetTemplate;
25
31
  protected readonly baseClass: _angular_core.Signal<string>;
@@ -49,10 +55,15 @@ declare class SheetComponent implements SheetVariantInput {
49
55
  readonly height: _angular_core.InputSignal<string | number | undefined>;
50
56
  /** @description Internationalization message overrides for accessible labels. */
51
57
  readonly messages: _angular_core.InputSignal<Partial<MonaSheetMessages> | undefined>;
52
- /** @description Edge of the viewport from which the sheet opens. @default "right" */
58
+ /**
59
+ * @description Edge of the viewport from which the sheet opens. `left` and `right` are physical; `start` and
60
+ * `end` follow the direction (`start` is the left edge in LTR and the right edge in RTL). The edge is fixed
61
+ * once the sheet opens. @default "right"
62
+ */
53
63
  readonly side: _angular_core.InputSignal<SheetSide>;
54
64
  /** @description Title displayed in the sheet header and used as its accessible name. */
55
65
  readonly title: _angular_core.InputSignal<string | undefined>;
66
+ /** @description Additional CSS classes merged onto the sheet panel via `tailwind-merge`. */
56
67
  readonly userClass: _angular_core.InputSignalWithTransform<string | undefined, ClassInputType>;
57
68
  /** @description Explicit sheet width. Numbers are interpreted as pixels. */
58
69
  readonly width: _angular_core.InputSignal<string | number | undefined>;
@@ -65,4 +76,4 @@ declare class SheetComponent implements SheetVariantInput {
65
76
  declare const SHEET_DEFAULT_MESSAGES: MonaSheetMessages;
66
77
 
67
78
  export { SHEET_DEFAULT_MESSAGES, SheetComponent };
68
- export type { SheetSide };
79
+ export type { SheetPhysicalSide, SheetSide };