@nanahoshi/mona-ui 0.24.8 → 0.24.10
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/fesm2022/nanahoshi-mona-ui-button-group.mjs +37 -9
- package/fesm2022/nanahoshi-mona-ui-button.mjs +8 -2
- package/fesm2022/nanahoshi-mona-ui-color-gradient.mjs +4 -3
- package/fesm2022/nanahoshi-mona-ui-color-picker.mjs +2 -2
- package/fesm2022/nanahoshi-mona-ui-contextmenu.mjs +101 -47
- package/fesm2022/nanahoshi-mona-ui-dialog.mjs +342 -102
- package/fesm2022/nanahoshi-mona-ui-dropdown-button.mjs +119 -69
- package/fesm2022/nanahoshi-mona-ui-editor.mjs +1054 -452
- package/fesm2022/{nanahoshi-mona-ui-grid-grid-footer-row.component-DdyHnUIr.mjs → nanahoshi-mona-ui-grid-grid-footer-row.component-DhKLnW06.mjs} +2 -2
- package/fesm2022/{nanahoshi-mona-ui-grid-grid-list.component-B6gq7Hu3.mjs → nanahoshi-mona-ui-grid-grid-list.component-voGbKOiB.mjs} +4 -4
- package/fesm2022/{nanahoshi-mona-ui-grid-grid-row.component-DdUY3I7P.mjs → nanahoshi-mona-ui-grid-grid-row.component-HQ1Kv6R9.mjs} +2 -3
- package/fesm2022/{nanahoshi-mona-ui-grid-grid-virtual-list.component-DG8Bu4Dy.mjs → nanahoshi-mona-ui-grid-grid-virtual-list.component-PNLJFcuH.mjs} +4 -4
- package/fesm2022/{nanahoshi-mona-ui-grid-nanahoshi-mona-ui-grid-CVqpbMcb.mjs → nanahoshi-mona-ui-grid-nanahoshi-mona-ui-grid-BO19AVwC.mjs} +9 -9
- package/fesm2022/nanahoshi-mona-ui-grid.mjs +1 -1
- package/fesm2022/nanahoshi-mona-ui-i18n-icu.mjs +23 -0
- package/fesm2022/nanahoshi-mona-ui-internal.mjs +567 -33
- package/fesm2022/nanahoshi-mona-ui-locales-ar-sa.mjs +20 -0
- package/fesm2022/nanahoshi-mona-ui-locales-de-de.mjs +20 -0
- package/fesm2022/nanahoshi-mona-ui-locales-es-es.mjs +20 -0
- package/fesm2022/nanahoshi-mona-ui-locales-fr-fr.mjs +20 -0
- package/fesm2022/nanahoshi-mona-ui-locales-id-id.mjs +20 -0
- package/fesm2022/nanahoshi-mona-ui-locales-it-it.mjs +20 -0
- package/fesm2022/nanahoshi-mona-ui-locales-ja-jp.mjs +20 -0
- package/fesm2022/nanahoshi-mona-ui-locales-ko-kr.mjs +20 -0
- package/fesm2022/nanahoshi-mona-ui-locales-pt-br.mjs +20 -0
- package/fesm2022/nanahoshi-mona-ui-locales-ru-ru.mjs +20 -0
- package/fesm2022/nanahoshi-mona-ui-locales-tr-tr.mjs +20 -0
- package/fesm2022/nanahoshi-mona-ui-locales-zh-cn.mjs +20 -0
- package/fesm2022/nanahoshi-mona-ui-locales-zh-tw.mjs +20 -0
- package/fesm2022/nanahoshi-mona-ui-menubar.mjs +127 -133
- package/fesm2022/nanahoshi-mona-ui-notification.mjs +473 -240
- package/fesm2022/nanahoshi-mona-ui-popover.mjs +202 -90
- package/fesm2022/nanahoshi-mona-ui-popup-menu.mjs +609 -256
- package/fesm2022/nanahoshi-mona-ui-popup.mjs +2 -0
- package/fesm2022/nanahoshi-mona-ui-sheet.mjs +45 -10
- package/fesm2022/nanahoshi-mona-ui-split-button.mjs +102 -58
- package/fesm2022/nanahoshi-mona-ui-tooltip.mjs +286 -443
- package/fesm2022/nanahoshi-mona-ui-window.mjs +594 -311
- package/i18n/catalogs/en-US.messages.json +24 -4
- package/locales/ar-sa/ar-sa.messages.json +20 -0
- package/locales/de-de/de-de.messages.json +20 -0
- package/locales/es-es/es-es.messages.json +20 -0
- package/locales/fr-fr/fr-fr.messages.json +20 -0
- package/locales/id-id/id-id.messages.json +20 -0
- package/locales/it-it/it-it.messages.json +20 -0
- package/locales/ja-jp/ja-jp.messages.json +20 -0
- package/locales/ko-kr/ko-kr.messages.json +20 -0
- package/locales/pt-br/pt-br.messages.json +20 -0
- package/locales/ru-ru/ru-ru.messages.json +20 -0
- package/locales/tr-tr/tr-tr.messages.json +20 -0
- package/locales/zh-cn/zh-cn.messages.json +20 -0
- package/locales/zh-tw/zh-tw.messages.json +20 -0
- package/package.json +1 -1
- package/types/nanahoshi-mona-ui-button-group.d.ts +13 -3
- package/types/nanahoshi-mona-ui-button.d.ts +20 -3
- package/types/nanahoshi-mona-ui-contextmenu.d.ts +5 -6
- package/types/nanahoshi-mona-ui-dialog.d.ts +131 -20
- package/types/nanahoshi-mona-ui-dropdown-button.d.ts +75 -56
- package/types/nanahoshi-mona-ui-editor.d.ts +118 -21
- package/types/nanahoshi-mona-ui-i18n.d.ts +37 -0
- package/types/nanahoshi-mona-ui-internal.d.ts +142 -16
- package/types/nanahoshi-mona-ui-locales-ar-sa.d.ts +20 -0
- package/types/nanahoshi-mona-ui-locales-de-de.d.ts +20 -0
- package/types/nanahoshi-mona-ui-locales-es-es.d.ts +20 -0
- package/types/nanahoshi-mona-ui-locales-fr-fr.d.ts +20 -0
- package/types/nanahoshi-mona-ui-locales-id-id.d.ts +20 -0
- package/types/nanahoshi-mona-ui-locales-it-it.d.ts +20 -0
- package/types/nanahoshi-mona-ui-locales-ja-jp.d.ts +20 -0
- package/types/nanahoshi-mona-ui-locales-ko-kr.d.ts +20 -0
- package/types/nanahoshi-mona-ui-locales-pt-br.d.ts +20 -0
- package/types/nanahoshi-mona-ui-locales-ru-ru.d.ts +20 -0
- package/types/nanahoshi-mona-ui-locales-tr-tr.d.ts +20 -0
- package/types/nanahoshi-mona-ui-locales-zh-cn.d.ts +20 -0
- package/types/nanahoshi-mona-ui-locales-zh-tw.d.ts +20 -0
- package/types/nanahoshi-mona-ui-menubar.d.ts +65 -62
- package/types/nanahoshi-mona-ui-notification.d.ts +76 -16
- package/types/nanahoshi-mona-ui-popover.d.ts +44 -17
- package/types/nanahoshi-mona-ui-popup-menu.d.ts +110 -32
- package/types/nanahoshi-mona-ui-popup.d.ts +2 -0
- package/types/nanahoshi-mona-ui-sheet.d.ts +16 -5
- package/types/nanahoshi-mona-ui-split-button.d.ts +29 -7
- package/types/nanahoshi-mona-ui-tooltip.d.ts +43 -20
- package/types/nanahoshi-mona-ui-window.d.ts +103 -14
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { NgTemplateOutlet } from '@angular/common';
|
|
2
2
|
import * as i0 from '@angular/core';
|
|
3
|
-
import { forwardRef, Directive, inject, DestroyRef, contentChildren, viewChild,
|
|
3
|
+
import { forwardRef, Directive, inject, DestroyRef, signal, contentChildren, viewChild, contentChild, TemplateRef, computed, input, viewChildren, output, effect, untracked, afterNextRender, Component } from '@angular/core';
|
|
4
4
|
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
5
|
+
import { LucideChevronDown } from '@lucide/angular';
|
|
6
|
+
import { ButtonDirective, BUTTON_GROUP_MEMBER } from '@nanahoshi/mona-ui/button';
|
|
7
7
|
import { createElementControlId } from '@nanahoshi/mona-ui/internal';
|
|
8
|
-
import {
|
|
8
|
+
import { PopupMenuGroupTemplateDirective, PopupMenuTemplateOrigin, PopupMenuGroupTemplateToken, PopupMenuIconTemplateDirective, PopupMenuIconTemplateToken, PopupMenuShortcutTemplateDirective, PopupMenuShortcutTemplateToken, PopupMenuTextTemplateDirective, PopupMenuTextTemplateToken, PopupMenuItemType, PopupMenuTemplateType, ensurePopupComponentTypes, PopupMenuOrigin, ensurePopupTemplateTypes, PopupMenuToken, PopupMenuComponent, PopupMenuCheckboxItemComponent, PopupMenuGroupComponent, PopupMenuItemComponent, PopupMenuRadioGroupComponent, PopupMenuRadioItemComponent, PopupMenuRadioItemToken, PopupMenuSeparatorComponent } from '@nanahoshi/mona-ui/popup-menu';
|
|
9
|
+
import { fromEvent } from 'rxjs';
|
|
9
10
|
|
|
10
11
|
class DropdownButtonMenuGroupTemplateDirective extends PopupMenuGroupTemplateDirective {
|
|
11
12
|
constructor() {
|
|
@@ -122,66 +123,108 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImpor
|
|
|
122
123
|
}]
|
|
123
124
|
}] });
|
|
124
125
|
|
|
126
|
+
const componentTypeMap = {
|
|
127
|
+
[PopupMenuItemType.CheckboxMenuItem]: "mona-dropdown-button-checkbox-item",
|
|
128
|
+
[PopupMenuItemType.MenuGroup]: "mona-dropdown-button-group",
|
|
129
|
+
[PopupMenuItemType.MenuItem]: "mona-dropdown-button-item",
|
|
130
|
+
[PopupMenuItemType.RadioGroup]: "mona-dropdown-button-radio-group",
|
|
131
|
+
[PopupMenuItemType.RadioItem]: "mona-dropdown-button-radio-item",
|
|
132
|
+
[PopupMenuItemType.Separator]: "mona-dropdown-button-separator"
|
|
133
|
+
};
|
|
134
|
+
const templateTypeMap = {
|
|
135
|
+
[PopupMenuTemplateType.Group]: "monaDropdownButtonMenuGroupTemplate",
|
|
136
|
+
[PopupMenuTemplateType.Icon]: "monaDropdownButtonMenuItemIconTemplate",
|
|
137
|
+
[PopupMenuTemplateType.Shortcut]: "monaDropdownButtonMenuItemShortcutTemplate",
|
|
138
|
+
[PopupMenuTemplateType.Text]: "monaDropdownButtonMenuItemTextTemplate"
|
|
139
|
+
};
|
|
140
|
+
const ensureDropdownButtonComponentTypes = (components) => {
|
|
141
|
+
ensurePopupComponentTypes({
|
|
142
|
+
components,
|
|
143
|
+
componentTypeMap,
|
|
144
|
+
origin: PopupMenuOrigin.DropdownButton,
|
|
145
|
+
prefix: "mona-dropdown-button"
|
|
146
|
+
});
|
|
147
|
+
};
|
|
148
|
+
const ensureDropdownButtonTemplateTypes = (templates) => {
|
|
149
|
+
ensurePopupTemplateTypes({
|
|
150
|
+
templates,
|
|
151
|
+
templateTypeMap,
|
|
152
|
+
origin: PopupMenuTemplateOrigin.DropdownButton,
|
|
153
|
+
prefix: "mona-dropdown-button"
|
|
154
|
+
});
|
|
155
|
+
};
|
|
156
|
+
|
|
125
157
|
class DropdownButtonComponent {
|
|
126
158
|
#destroyRef;
|
|
159
|
+
#triggerWidth;
|
|
127
160
|
constructor() {
|
|
128
161
|
this.#destroyRef = inject(DestroyRef);
|
|
162
|
+
this.#triggerWidth = signal(0, /* @ts-ignore */
|
|
163
|
+
...(ngDevMode ? [{ debugName: "#triggerWidth" }] : /* istanbul ignore next */ []));
|
|
129
164
|
this.menuItemComponents = contentChildren(PopupMenuToken, { ...(ngDevMode ? { debugName: "menuItemComponents" } : /* istanbul ignore next */ {}), descendants: false });
|
|
130
165
|
this.buttonRef = viewChild("dropdownButton", /* @ts-ignore */
|
|
131
166
|
...(ngDevMode ? [{ debugName: "buttonRef" }] : /* istanbul ignore next */ []));
|
|
132
|
-
this.
|
|
133
|
-
|
|
134
|
-
const text = this.text();
|
|
135
|
-
return ariaLabel || `${text} dropdown button`.trim();
|
|
136
|
-
}, /* @ts-ignore */
|
|
137
|
-
...(ngDevMode ? [{ debugName: "dropdownButtonAriaLabel" }] : /* istanbul ignore next */ []));
|
|
167
|
+
this.groupTemplate = contentChild(DropdownButtonMenuGroupTemplateDirective, { ...(ngDevMode ? { debugName: "groupTemplate" } : /* istanbul ignore next */ {}), read: TemplateRef,
|
|
168
|
+
descendants: false });
|
|
138
169
|
this.isMenuOpen = signal(false, /* @ts-ignore */
|
|
139
170
|
...(ngDevMode ? [{ debugName: "isMenuOpen" }] : /* istanbul ignore next */ []));
|
|
140
171
|
this.menuId = createElementControlId();
|
|
141
|
-
this.groupTemplate = contentChild(DropdownButtonMenuGroupTemplateDirective, { ...(ngDevMode ? { debugName: "groupTemplate" } : /* istanbul ignore next */ {}), read: TemplateRef,
|
|
142
|
-
descendants: false });
|
|
143
172
|
this.menuItemIconTemplate = contentChild(DropdownButtonMenuItemIconTemplateDirective, { ...(ngDevMode ? { debugName: "menuItemIconTemplate" } : /* istanbul ignore next */ {}), read: TemplateRef,
|
|
144
173
|
descendants: false });
|
|
174
|
+
this.menuItemShortcutTemplate = contentChild(DropdownButtonMenuItemShortcutTemplateDirective, { ...(ngDevMode ? { debugName: "menuItemShortcutTemplate" } : /* istanbul ignore next */ {}), read: TemplateRef,
|
|
175
|
+
descendants: false });
|
|
176
|
+
this.menuItemTextTemplate = contentChild(DropdownButtonMenuItemTextTemplateDirective, { ...(ngDevMode ? { debugName: "menuItemTextTemplate" } : /* istanbul ignore next */ {}), read: TemplateRef,
|
|
177
|
+
descendants: false });
|
|
145
178
|
this.menuItems = computed(() => {
|
|
146
179
|
return this.menuItemComponents()
|
|
147
180
|
.map(item => item.getPopupMenuItem())
|
|
148
181
|
.flatMap(i => i);
|
|
149
182
|
}, /* @ts-ignore */
|
|
150
183
|
...(ngDevMode ? [{ debugName: "menuItems" }] : /* istanbul ignore next */ []));
|
|
151
|
-
this.menuItemShortcutTemplate = contentChild(DropdownButtonMenuItemShortcutTemplateDirective, { ...(ngDevMode ? { debugName: "menuItemShortcutTemplate" } : /* istanbul ignore next */ {}), read: TemplateRef,
|
|
152
|
-
descendants: false });
|
|
153
|
-
this.menuItemTextTemplate = contentChild(DropdownButtonMenuItemTextTemplateDirective, { ...(ngDevMode ? { debugName: "menuItemTextTemplate" } : /* istanbul ignore next */ {}), read: TemplateRef,
|
|
154
|
-
descendants: false });
|
|
155
184
|
this.popupMenuRef = viewChild("popupMenu", /* @ts-ignore */
|
|
156
185
|
...(ngDevMode ? [{ debugName: "popupMenuRef" }] : /* istanbul ignore next */ []));
|
|
186
|
+
this.popupMenuRounded = computed(() => {
|
|
187
|
+
const rounded = this.rounded();
|
|
188
|
+
return rounded === "full" ? "large" : rounded;
|
|
189
|
+
}, /* @ts-ignore */
|
|
190
|
+
...(ngDevMode ? [{ debugName: "popupMenuRounded" }] : /* istanbul ignore next */ []));
|
|
191
|
+
this.popupMinWidth = computed(() => this.popupWidth() || this.#triggerWidth() || undefined, /* @ts-ignore */
|
|
192
|
+
...(ngDevMode ? [{ debugName: "popupMinWidth" }] : /* istanbul ignore next */ []));
|
|
157
193
|
this.textTemplate = contentChild(DropdownButtonTextTemplateDirective, { ...(ngDevMode ? { debugName: "textTemplate" } : /* istanbul ignore next */ {}), read: TemplateRef });
|
|
158
194
|
/**
|
|
159
|
-
* @description Accessible name for the dropdown button.
|
|
160
|
-
*
|
|
195
|
+
* @description Accessible name for the dropdown button. Leave it empty when the button shows its name as text;
|
|
196
|
+
* set it (or `aria-labelledby`) when the button shows only an icon.
|
|
161
197
|
* @default ""
|
|
162
198
|
*/
|
|
163
199
|
this.ariaLabel = input("", { ...(ngDevMode ? { debugName: "ariaLabel" } : /* istanbul ignore next */ {}), alias: "aria-label" });
|
|
164
200
|
/**
|
|
165
201
|
* @description ID of an external element that provides the accessible name for the dropdown button.
|
|
166
|
-
* Takes precedence over `
|
|
202
|
+
* Takes precedence over `aria-label` when both are set.
|
|
167
203
|
* @default ""
|
|
168
204
|
*/
|
|
169
205
|
this.ariaLabelledby = input("", { ...(ngDevMode ? { debugName: "ariaLabelledby" } : /* istanbul ignore next */ {}), alias: "aria-labelledby" });
|
|
170
206
|
/**
|
|
171
|
-
* @description Renders the button
|
|
172
|
-
*
|
|
207
|
+
* @description Renders the button with reduced visual emphasis and removes pointer interaction. Disabling the
|
|
208
|
+
* button closes its open menu.
|
|
173
209
|
* @default false
|
|
174
210
|
*/
|
|
175
|
-
this.
|
|
176
|
-
...(ngDevMode ? [{ debugName: "
|
|
211
|
+
this.disabled = input(false, /* @ts-ignore */
|
|
212
|
+
...(ngDevMode ? [{ debugName: "disabled" }] : /* istanbul ignore next */ []));
|
|
177
213
|
/**
|
|
178
|
-
*
|
|
214
|
+
* The trigger button, which joins a surrounding `mona-button-group`.
|
|
215
|
+
*/
|
|
216
|
+
this.groupButtons = viewChildren(ButtonDirective, /* @ts-ignore */
|
|
217
|
+
...(ngDevMode ? [{ debugName: "groupButtons" }] : /* istanbul ignore next */ []));
|
|
218
|
+
/**
|
|
219
|
+
* @description Renders the button as a square for icon-only usage, removing horizontal text padding and the arrow.
|
|
220
|
+
* Set `aria-label` when no visible text is present to ensure an accessible name.
|
|
179
221
|
* @default false
|
|
180
222
|
*/
|
|
181
|
-
this.
|
|
182
|
-
...(ngDevMode ? [{ debugName: "
|
|
223
|
+
this.iconOnly = input(false, /* @ts-ignore */
|
|
224
|
+
...(ngDevMode ? [{ debugName: "iconOnly" }] : /* istanbul ignore next */ []));
|
|
183
225
|
/**
|
|
184
|
-
* @description Displays a loading indicator and prevents interaction while an operation is in progress.
|
|
226
|
+
* @description Displays a loading indicator and prevents interaction while an operation is in progress. Starting
|
|
227
|
+
* to load closes the open menu.
|
|
185
228
|
* @default false
|
|
186
229
|
*/
|
|
187
230
|
this.loading = input(false, /* @ts-ignore */
|
|
@@ -197,11 +240,25 @@ class DropdownButtonComponent {
|
|
|
197
240
|
*/
|
|
198
241
|
this.menuItemClick = output();
|
|
199
242
|
/**
|
|
200
|
-
* @description
|
|
243
|
+
* @description Minimum width of the popup menu in pixels. A value of `0` makes the menu at least as wide as the
|
|
244
|
+
* button.
|
|
245
|
+
* @default 0
|
|
246
|
+
*/
|
|
247
|
+
this.popupWidth = input(0, /* @ts-ignore */
|
|
248
|
+
...(ngDevMode ? [{ debugName: "popupWidth" }] : /* istanbul ignore next */ []));
|
|
249
|
+
/**
|
|
250
|
+
* @description Border-radius preset applied to the button. The menu follows it (`"full"` gives it large corners).
|
|
201
251
|
* @default "medium"
|
|
202
252
|
*/
|
|
203
253
|
this.rounded = input("medium", /* @ts-ignore */
|
|
204
254
|
...(ngDevMode ? [{ debugName: "rounded" }] : /* istanbul ignore next */ []));
|
|
255
|
+
/**
|
|
256
|
+
* @description Shows a down arrow after the text, so the button reads as one that opens a menu. Icon-only buttons
|
|
257
|
+
* never show it.
|
|
258
|
+
* @default true
|
|
259
|
+
*/
|
|
260
|
+
this.showArrow = input(true, /* @ts-ignore */
|
|
261
|
+
...(ngDevMode ? [{ debugName: "showArrow" }] : /* istanbul ignore next */ []));
|
|
205
262
|
/**
|
|
206
263
|
* @description Size preset controlling the button's dimensions.
|
|
207
264
|
* @default "medium"
|
|
@@ -220,8 +277,17 @@ class DropdownButtonComponent {
|
|
|
220
277
|
* @default ""
|
|
221
278
|
*/
|
|
222
279
|
this.userClass = input("", { ...(ngDevMode ? { debugName: "userClass" } : /* istanbul ignore next */ {}), alias: "class" });
|
|
280
|
+
effect(() => ensureDropdownButtonComponentTypes(this.menuItemComponents()));
|
|
281
|
+
effect(() => {
|
|
282
|
+
if (this.disabled() || this.loading()) {
|
|
283
|
+
untracked(() => this.popupMenuRef()?.closeMenu());
|
|
284
|
+
}
|
|
285
|
+
});
|
|
223
286
|
afterNextRender({
|
|
224
|
-
read: () =>
|
|
287
|
+
read: () => {
|
|
288
|
+
this.#setKeyboardEvents();
|
|
289
|
+
this.#observeTriggerWidth();
|
|
290
|
+
}
|
|
225
291
|
});
|
|
226
292
|
}
|
|
227
293
|
onMenuClose() {
|
|
@@ -240,10 +306,19 @@ class DropdownButtonComponent {
|
|
|
240
306
|
this.buttonRef()?.nativeElement?.focus();
|
|
241
307
|
}
|
|
242
308
|
}
|
|
243
|
-
#
|
|
309
|
+
#observeTriggerWidth() {
|
|
310
|
+
const button = this.buttonRef()?.nativeElement;
|
|
311
|
+
if (!button || typeof ResizeObserver === "undefined") {
|
|
312
|
+
return;
|
|
313
|
+
}
|
|
314
|
+
const observer = new ResizeObserver(() => this.#triggerWidth.set(button.offsetWidth));
|
|
315
|
+
observer.observe(button);
|
|
316
|
+
this.#destroyRef.onDestroy(() => observer.disconnect());
|
|
317
|
+
}
|
|
318
|
+
#openMenuViaKeyboard(focus) {
|
|
244
319
|
const popupMenu = this.popupMenuRef();
|
|
245
|
-
if (popupMenu && !this.isMenuOpen()) {
|
|
246
|
-
popupMenu.openMenuViaKeyboard();
|
|
320
|
+
if (popupMenu && !this.isMenuOpen() && !this.disabled() && !this.loading()) {
|
|
321
|
+
popupMenu.openMenuViaKeyboard(false, focus);
|
|
247
322
|
}
|
|
248
323
|
}
|
|
249
324
|
#setKeyboardEvents() {
|
|
@@ -256,11 +331,14 @@ class DropdownButtonComponent {
|
|
|
256
331
|
.subscribe(event => {
|
|
257
332
|
switch (event.key) {
|
|
258
333
|
case "ArrowDown":
|
|
259
|
-
case "ArrowUp":
|
|
260
334
|
case " ":
|
|
261
335
|
case "Enter":
|
|
262
336
|
event.preventDefault();
|
|
263
|
-
this.#openMenuViaKeyboard();
|
|
337
|
+
this.#openMenuViaKeyboard("first");
|
|
338
|
+
break;
|
|
339
|
+
case "ArrowUp":
|
|
340
|
+
event.preventDefault();
|
|
341
|
+
this.#openMenuViaKeyboard("last");
|
|
264
342
|
break;
|
|
265
343
|
case "Escape":
|
|
266
344
|
if (this.isMenuOpen()) {
|
|
@@ -271,21 +349,24 @@ class DropdownButtonComponent {
|
|
|
271
349
|
});
|
|
272
350
|
}
|
|
273
351
|
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: DropdownButtonComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
|
274
|
-
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.0.6", type: DropdownButtonComponent, isStandalone: true, selector: "mona-dropdown-button", inputs: { ariaLabel: { classPropertyName: "ariaLabel", publicName: "aria-label", isSignal: true, isRequired: false, transformFunction: null }, ariaLabelledby: { classPropertyName: "ariaLabelledby", publicName: "aria-labelledby", isSignal: true, isRequired: false, transformFunction: null },
|
|
352
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.0.6", type: DropdownButtonComponent, isStandalone: true, selector: "mona-dropdown-button", inputs: { ariaLabel: { classPropertyName: "ariaLabel", publicName: "aria-label", isSignal: true, isRequired: false, transformFunction: null }, ariaLabelledby: { classPropertyName: "ariaLabelledby", publicName: "aria-labelledby", isSignal: true, isRequired: false, transformFunction: null }, disabled: { classPropertyName: "disabled", publicName: "disabled", isSignal: true, isRequired: false, transformFunction: null }, iconOnly: { classPropertyName: "iconOnly", publicName: "iconOnly", isSignal: true, isRequired: false, transformFunction: null }, loading: { classPropertyName: "loading", publicName: "loading", isSignal: true, isRequired: false, transformFunction: null }, look: { classPropertyName: "look", publicName: "look", isSignal: true, isRequired: false, transformFunction: null }, popupWidth: { classPropertyName: "popupWidth", publicName: "popupWidth", isSignal: true, isRequired: false, transformFunction: null }, rounded: { classPropertyName: "rounded", publicName: "rounded", isSignal: true, isRequired: false, transformFunction: null }, showArrow: { classPropertyName: "showArrow", publicName: "showArrow", isSignal: true, isRequired: false, transformFunction: null }, size: { classPropertyName: "size", publicName: "size", isSignal: true, isRequired: false, transformFunction: null }, text: { classPropertyName: "text", publicName: "text", isSignal: true, isRequired: false, transformFunction: null }, userClass: { classPropertyName: "userClass", publicName: "class", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { menuItemClick: "menuItemClick" }, host: { properties: { "attr.aria-label": "null", "attr.aria-labelledby": "null", "class": "userClass()" } }, providers: [{ provide: BUTTON_GROUP_MEMBER, useExisting: DropdownButtonComponent }], queries: [{ propertyName: "menuItemComponents", predicate: PopupMenuToken, isSignal: true }, { propertyName: "groupTemplate", first: true, predicate: DropdownButtonMenuGroupTemplateDirective, read: TemplateRef, isSignal: true }, { propertyName: "menuItemIconTemplate", first: true, predicate: DropdownButtonMenuItemIconTemplateDirective, read: TemplateRef, isSignal: true }, { propertyName: "menuItemShortcutTemplate", first: true, predicate: DropdownButtonMenuItemShortcutTemplateDirective, read: TemplateRef, isSignal: true }, { propertyName: "menuItemTextTemplate", first: true, predicate: DropdownButtonMenuItemTextTemplateDirective, read: TemplateRef, isSignal: true }, { propertyName: "textTemplate", first: true, predicate: DropdownButtonTextTemplateDirective, descendants: true, read: TemplateRef, isSignal: true }], viewQueries: [{ propertyName: "buttonRef", first: true, predicate: ["dropdownButton"], descendants: true, isSignal: true }, { propertyName: "popupMenuRef", first: true, predicate: ["popupMenu"], descendants: true, isSignal: true }, { propertyName: "groupButtons", predicate: ButtonDirective, descendants: true, isSignal: true }], ngImport: i0, template: "<button\n monaButton\n [look]=\"look()\"\n [size]=\"size()\"\n [iconOnly]=\"iconOnly()\"\n [loading]=\"loading()\"\n [rounded]=\"rounded()\"\n [disabled]=\"disabled()\"\n [toggleable]=\"false\"\n aria-haspopup=\"menu\"\n [attr.aria-label]=\"ariaLabelledby() ? null : ariaLabel() || null\"\n [attr.aria-labelledby]=\"ariaLabelledby() || null\"\n [attr.aria-expanded]=\"isMenuOpen()\"\n [attr.aria-controls]=\"isMenuOpen() ? menuId : null\"\n #dropdownButton>\n @if (textTemplate()) {\n <ng-container\n [ngTemplateOutlet]=\"textTemplate()\"\n [ngTemplateOutletContext]=\"{ $implicit: text() }\"></ng-container>\n } @else {\n {{ text() }}\n }\n @if (showArrow() && !iconOnly()) {\n <svg lucideChevronDown [size]=\"16\" class=\"shrink-0\"></svg>\n }\n</button>\n\n<mona-popup-menu\n #popupMenu\n (close)=\"onMenuClose()\"\n (menuClick)=\"onMenuItemClick($event)\"\n (open)=\"onMenuOpen()\"\n [anchorConnectionPoint]=\"'bottomcenter'\"\n [id]=\"menuId\"\n [items]=\"menuItems()\"\n [minWidth]=\"popupMinWidth()\"\n [offset]=\"{ horizontal: 0, vertical: 2 }\"\n [popupConnectionPoint]=\"'topcenter'\"\n [rounded]=\"popupMenuRounded()\"\n [size]=\"size()\"\n [target]=\"dropdownButton\"\n [trigger]=\"'click'\">\n @if (groupTemplate()) {\n <ng-template monaPopupMenuGroupTemplate let-group>\n <ng-container\n [ngTemplateOutlet]=\"groupTemplate()\"\n [ngTemplateOutletContext]=\"{ $implicit: group }\"></ng-container>\n </ng-template>\n }\n @if (menuItemIconTemplate()) {\n <ng-template monaPopupMenuIconTemplate let-item>\n <ng-container\n [ngTemplateOutlet]=\"menuItemIconTemplate()\"\n [ngTemplateOutletContext]=\"{ $implicit: item }\"></ng-container>\n </ng-template>\n }\n @if (menuItemShortcutTemplate()) {\n <ng-template monaPopupMenuShortcutTemplate let-item>\n <ng-container\n [ngTemplateOutlet]=\"menuItemShortcutTemplate()\"\n [ngTemplateOutletContext]=\"{ $implicit: item }\"></ng-container>\n </ng-template>\n }\n @if (menuItemTextTemplate()) {\n <ng-template monaPopupMenuTextTemplate let-item>\n <ng-container\n [ngTemplateOutlet]=\"menuItemTextTemplate()\"\n [ngTemplateOutletContext]=\"{ $implicit: item }\"></ng-container>\n </ng-template>\n }\n</mona-popup-menu>\n", dependencies: [{ kind: "directive", type: ButtonDirective, selector: "button[monaButton]", inputs: ["aria-haspopup", "disabled", "iconOnly", "loading", "look", "rounded", "selected", "size", "tabindex", "toggleable", "type", "class"], outputs: ["lookChange", "selectedChange"] }, { kind: "component", type: LucideChevronDown, selector: "svg[lucideChevronDown]" }, { kind: "component", type: PopupMenuComponent, selector: "mona-popup-menu", inputs: ["anchor", "anchorConnectionPoint", "ariaLabel", "ariaLabelledBy", "items", "id", "minWidth", "offset", "popupConnectionPoint", "precise", "rounded", "size", "target", "trigger", "class", "width"], outputs: ["close", "menuClick", "navigate", "open"] }, { kind: "directive", type: PopupMenuGroupTemplateDirective, selector: "ng-template[monaPopupMenuGroupTemplate]" }, { kind: "directive", type: PopupMenuIconTemplateDirective, selector: "ng-template[monaPopupMenuIconTemplate]" }, { kind: "directive", type: PopupMenuShortcutTemplateDirective, selector: "ng-template[monaPopupMenuShortcutTemplate]" }, { kind: "directive", type: PopupMenuTextTemplateDirective, selector: "ng-template[monaPopupMenuTextTemplate]" }, { kind: "directive", type: NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }] }); }
|
|
275
353
|
}
|
|
276
354
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: DropdownButtonComponent, decorators: [{
|
|
277
355
|
type: Component,
|
|
278
|
-
args: [{ selector: "mona-dropdown-button", host: {
|
|
356
|
+
args: [{ selector: "mona-dropdown-button", providers: [{ provide: BUTTON_GROUP_MEMBER, useExisting: DropdownButtonComponent }], host: {
|
|
357
|
+
"[attr.aria-label]": "null",
|
|
358
|
+
"[attr.aria-labelledby]": "null",
|
|
279
359
|
"[class]": "userClass()"
|
|
280
360
|
}, imports: [
|
|
281
361
|
ButtonDirective,
|
|
362
|
+
LucideChevronDown,
|
|
282
363
|
PopupMenuComponent,
|
|
283
364
|
PopupMenuGroupTemplateDirective,
|
|
284
365
|
PopupMenuIconTemplateDirective,
|
|
285
366
|
PopupMenuShortcutTemplateDirective,
|
|
286
367
|
PopupMenuTextTemplateDirective,
|
|
287
368
|
NgTemplateOutlet
|
|
288
|
-
], template: "<button\n monaButton\n [look]=\"look()\"\n [size]=\"size()\"\n [iconOnly]=\"iconOnly()\"\n [loading]=\"loading()\"\n [rounded]=\"rounded()\"\n [disabled]=\"disabled()\"\n [attr.aria-label]=\"ariaLabelledby() ? null :
|
|
369
|
+
], template: "<button\n monaButton\n [look]=\"look()\"\n [size]=\"size()\"\n [iconOnly]=\"iconOnly()\"\n [loading]=\"loading()\"\n [rounded]=\"rounded()\"\n [disabled]=\"disabled()\"\n [toggleable]=\"false\"\n aria-haspopup=\"menu\"\n [attr.aria-label]=\"ariaLabelledby() ? null : ariaLabel() || null\"\n [attr.aria-labelledby]=\"ariaLabelledby() || null\"\n [attr.aria-expanded]=\"isMenuOpen()\"\n [attr.aria-controls]=\"isMenuOpen() ? menuId : null\"\n #dropdownButton>\n @if (textTemplate()) {\n <ng-container\n [ngTemplateOutlet]=\"textTemplate()\"\n [ngTemplateOutletContext]=\"{ $implicit: text() }\"></ng-container>\n } @else {\n {{ text() }}\n }\n @if (showArrow() && !iconOnly()) {\n <svg lucideChevronDown [size]=\"16\" class=\"shrink-0\"></svg>\n }\n</button>\n\n<mona-popup-menu\n #popupMenu\n (close)=\"onMenuClose()\"\n (menuClick)=\"onMenuItemClick($event)\"\n (open)=\"onMenuOpen()\"\n [anchorConnectionPoint]=\"'bottomcenter'\"\n [id]=\"menuId\"\n [items]=\"menuItems()\"\n [minWidth]=\"popupMinWidth()\"\n [offset]=\"{ horizontal: 0, vertical: 2 }\"\n [popupConnectionPoint]=\"'topcenter'\"\n [rounded]=\"popupMenuRounded()\"\n [size]=\"size()\"\n [target]=\"dropdownButton\"\n [trigger]=\"'click'\">\n @if (groupTemplate()) {\n <ng-template monaPopupMenuGroupTemplate let-group>\n <ng-container\n [ngTemplateOutlet]=\"groupTemplate()\"\n [ngTemplateOutletContext]=\"{ $implicit: group }\"></ng-container>\n </ng-template>\n }\n @if (menuItemIconTemplate()) {\n <ng-template monaPopupMenuIconTemplate let-item>\n <ng-container\n [ngTemplateOutlet]=\"menuItemIconTemplate()\"\n [ngTemplateOutletContext]=\"{ $implicit: item }\"></ng-container>\n </ng-template>\n }\n @if (menuItemShortcutTemplate()) {\n <ng-template monaPopupMenuShortcutTemplate let-item>\n <ng-container\n [ngTemplateOutlet]=\"menuItemShortcutTemplate()\"\n [ngTemplateOutletContext]=\"{ $implicit: item }\"></ng-container>\n </ng-template>\n }\n @if (menuItemTextTemplate()) {\n <ng-template monaPopupMenuTextTemplate let-item>\n <ng-container\n [ngTemplateOutlet]=\"menuItemTextTemplate()\"\n [ngTemplateOutletContext]=\"{ $implicit: item }\"></ng-container>\n </ng-template>\n }\n</mona-popup-menu>\n" }]
|
|
289
370
|
}], ctorParameters: () => [], propDecorators: { menuItemComponents: [{ type: i0.ContentChildren, args: [i0.forwardRef(() => PopupMenuToken), { ...{ descendants: false }, isSignal: true }] }], buttonRef: [{ type: i0.ViewChild, args: ["dropdownButton", { isSignal: true }] }], groupTemplate: [{ type: i0.ContentChild, args: [i0.forwardRef(() => DropdownButtonMenuGroupTemplateDirective), { ...{
|
|
290
371
|
read: TemplateRef,
|
|
291
372
|
descendants: false
|
|
@@ -300,38 +381,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImpor
|
|
|
300
381
|
descendants: false
|
|
301
382
|
}, isSignal: true }] }], popupMenuRef: [{ type: i0.ViewChild, args: ["popupMenu", { isSignal: true }] }], textTemplate: [{ type: i0.ContentChild, args: [i0.forwardRef(() => DropdownButtonTextTemplateDirective), { ...{
|
|
302
383
|
read: TemplateRef
|
|
303
|
-
}, isSignal: true }] }], ariaLabel: [{ type: i0.Input, args: [{ isSignal: true, alias: "aria-label", required: false }] }], ariaLabelledby: [{ type: i0.Input, args: [{ isSignal: true, alias: "aria-labelledby", required: false }] }],
|
|
304
|
-
|
|
305
|
-
const componentTypeMap = {
|
|
306
|
-
[PopupMenuItemType.CheckboxMenuItem]: "mona-dropdown-button-checkbox-item",
|
|
307
|
-
[PopupMenuItemType.MenuGroup]: "mona-dropdown-button-group",
|
|
308
|
-
[PopupMenuItemType.MenuItem]: "mona-dropdown-button-item",
|
|
309
|
-
[PopupMenuItemType.RadioGroup]: "mona-dropdown-button-radio-group",
|
|
310
|
-
[PopupMenuItemType.RadioItem]: "mona-dropdown-button-radio-item",
|
|
311
|
-
[PopupMenuItemType.Separator]: "mona-dropdown-button-separator"
|
|
312
|
-
};
|
|
313
|
-
const templateTypeMap = {
|
|
314
|
-
[PopupMenuTemplateType.Group]: "monaDropdownButtonMenuGroupTemplate",
|
|
315
|
-
[PopupMenuTemplateType.Icon]: "monaDropdownButtonMenuItemIconTemplate",
|
|
316
|
-
[PopupMenuTemplateType.Shortcut]: "monaDropdownButtonMenuItemShortcutTemplate",
|
|
317
|
-
[PopupMenuTemplateType.Text]: "monaDropdownButtonMenuItemTextTemplate"
|
|
318
|
-
};
|
|
319
|
-
const ensureDropdownButtonComponentTypes = (components) => {
|
|
320
|
-
ensurePopupComponentTypes({
|
|
321
|
-
components,
|
|
322
|
-
componentTypeMap,
|
|
323
|
-
origin: PopupMenuOrigin.DropdownButton,
|
|
324
|
-
prefix: "mona-dropdown-button"
|
|
325
|
-
});
|
|
326
|
-
};
|
|
327
|
-
const ensureDropdownButtonTemplateTypes = (templates) => {
|
|
328
|
-
ensurePopupTemplateTypes({
|
|
329
|
-
templates,
|
|
330
|
-
templateTypeMap,
|
|
331
|
-
origin: PopupMenuTemplateOrigin.DropdownButton,
|
|
332
|
-
prefix: "mona-dropdown-button"
|
|
333
|
-
});
|
|
334
|
-
};
|
|
384
|
+
}, isSignal: true }] }], ariaLabel: [{ type: i0.Input, args: [{ isSignal: true, alias: "aria-label", required: false }] }], ariaLabelledby: [{ type: i0.Input, args: [{ isSignal: true, alias: "aria-labelledby", required: false }] }], disabled: [{ type: i0.Input, args: [{ isSignal: true, alias: "disabled", required: false }] }], groupButtons: [{ type: i0.ViewChildren, args: [i0.forwardRef(() => ButtonDirective), { isSignal: true }] }], iconOnly: [{ type: i0.Input, args: [{ isSignal: true, alias: "iconOnly", required: false }] }], loading: [{ type: i0.Input, args: [{ isSignal: true, alias: "loading", required: false }] }], look: [{ type: i0.Input, args: [{ isSignal: true, alias: "look", required: false }] }], menuItemClick: [{ type: i0.Output, args: ["menuItemClick"] }], popupWidth: [{ type: i0.Input, args: [{ isSignal: true, alias: "popupWidth", required: false }] }], rounded: [{ type: i0.Input, args: [{ isSignal: true, alias: "rounded", required: false }] }], showArrow: [{ type: i0.Input, args: [{ isSignal: true, alias: "showArrow", required: false }] }], size: [{ type: i0.Input, args: [{ isSignal: true, alias: "size", required: false }] }], text: [{ type: i0.Input, args: [{ isSignal: true, alias: "text", required: false }] }], userClass: [{ type: i0.Input, args: [{ isSignal: true, alias: "class", required: false }] }] } });
|
|
335
385
|
|
|
336
386
|
class DropdownButtonCheckboxItemComponent extends PopupMenuCheckboxItemComponent {
|
|
337
387
|
constructor() {
|