@cute-widgets/base 20.0.1
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/CHANGELOG.md +1 -0
- package/LICENSE.md +191 -0
- package/README.md +190 -0
- package/abstract/index.d.ts +327 -0
- package/alert/index.d.ts +68 -0
- package/autocomplete/index.d.ts +442 -0
- package/badge/index.d.ts +26 -0
- package/bottom-sheet/index.d.ts +231 -0
- package/button/index.d.ts +182 -0
- package/button-toggle/index.d.ts +225 -0
- package/card/index.d.ts +163 -0
- package/checkbox/index.d.ts +174 -0
- package/chips/index.d.ts +963 -0
- package/collapse/index.d.ts +97 -0
- package/core/animation/index.d.ts +43 -0
- package/core/datetime/index.d.ts +404 -0
- package/core/directives/index.d.ts +168 -0
- package/core/error/index.d.ts +74 -0
- package/core/index.d.ts +1039 -0
- package/core/interfaces/index.d.ts +114 -0
- package/core/layout/index.d.ts +53 -0
- package/core/line/index.d.ts +37 -0
- package/core/nav/index.d.ts +321 -0
- package/core/observers/index.d.ts +124 -0
- package/core/option/index.d.ts +185 -0
- package/core/pipes/index.d.ts +53 -0
- package/core/ripple/index.d.ts +66 -0
- package/core/testing/index.d.ts +154 -0
- package/core/theming/index.d.ts +118 -0
- package/core/types/index.d.ts +53 -0
- package/core/utils/index.d.ts +129 -0
- package/cute-widgets-base-20.0.1.tgz +0 -0
- package/datepicker/index.d.ts +1817 -0
- package/dialog/index.d.ts +484 -0
- package/divider/index.d.ts +24 -0
- package/expansion/README.md +8 -0
- package/expansion/index.d.ts +308 -0
- package/fesm2022/cute-widgets-base-abstract.mjs +547 -0
- package/fesm2022/cute-widgets-base-abstract.mjs.map +1 -0
- package/fesm2022/cute-widgets-base-alert.mjs +198 -0
- package/fesm2022/cute-widgets-base-alert.mjs.map +1 -0
- package/fesm2022/cute-widgets-base-autocomplete.mjs +1217 -0
- package/fesm2022/cute-widgets-base-autocomplete.mjs.map +1 -0
- package/fesm2022/cute-widgets-base-badge.mjs +75 -0
- package/fesm2022/cute-widgets-base-badge.mjs.map +1 -0
- package/fesm2022/cute-widgets-base-bottom-sheet.mjs +416 -0
- package/fesm2022/cute-widgets-base-bottom-sheet.mjs.map +1 -0
- package/fesm2022/cute-widgets-base-button-toggle.mjs +640 -0
- package/fesm2022/cute-widgets-base-button-toggle.mjs.map +1 -0
- package/fesm2022/cute-widgets-base-button.mjs +546 -0
- package/fesm2022/cute-widgets-base-button.mjs.map +1 -0
- package/fesm2022/cute-widgets-base-card.mjs +471 -0
- package/fesm2022/cute-widgets-base-card.mjs.map +1 -0
- package/fesm2022/cute-widgets-base-checkbox.mjs +390 -0
- package/fesm2022/cute-widgets-base-checkbox.mjs.map +1 -0
- package/fesm2022/cute-widgets-base-chips.mjs +2360 -0
- package/fesm2022/cute-widgets-base-chips.mjs.map +1 -0
- package/fesm2022/cute-widgets-base-collapse.mjs +259 -0
- package/fesm2022/cute-widgets-base-collapse.mjs.map +1 -0
- package/fesm2022/cute-widgets-base-core-animation.mjs +53 -0
- package/fesm2022/cute-widgets-base-core-animation.mjs.map +1 -0
- package/fesm2022/cute-widgets-base-core-datetime.mjs +568 -0
- package/fesm2022/cute-widgets-base-core-datetime.mjs.map +1 -0
- package/fesm2022/cute-widgets-base-core-directives.mjs +404 -0
- package/fesm2022/cute-widgets-base-core-directives.mjs.map +1 -0
- package/fesm2022/cute-widgets-base-core-error.mjs +105 -0
- package/fesm2022/cute-widgets-base-core-error.mjs.map +1 -0
- package/fesm2022/cute-widgets-base-core-interfaces.mjs +22 -0
- package/fesm2022/cute-widgets-base-core-interfaces.mjs.map +1 -0
- package/fesm2022/cute-widgets-base-core-layout.mjs +74 -0
- package/fesm2022/cute-widgets-base-core-layout.mjs.map +1 -0
- package/fesm2022/cute-widgets-base-core-line.mjs +87 -0
- package/fesm2022/cute-widgets-base-core-line.mjs.map +1 -0
- package/fesm2022/cute-widgets-base-core-nav.mjs +863 -0
- package/fesm2022/cute-widgets-base-core-nav.mjs.map +1 -0
- package/fesm2022/cute-widgets-base-core-observers.mjs +304 -0
- package/fesm2022/cute-widgets-base-core-observers.mjs.map +1 -0
- package/fesm2022/cute-widgets-base-core-option.mjs +373 -0
- package/fesm2022/cute-widgets-base-core-option.mjs.map +1 -0
- package/fesm2022/cute-widgets-base-core-pipes.mjs +97 -0
- package/fesm2022/cute-widgets-base-core-pipes.mjs.map +1 -0
- package/fesm2022/cute-widgets-base-core-ripple.mjs +172 -0
- package/fesm2022/cute-widgets-base-core-ripple.mjs.map +1 -0
- package/fesm2022/cute-widgets-base-core-testing.mjs +210 -0
- package/fesm2022/cute-widgets-base-core-testing.mjs.map +1 -0
- package/fesm2022/cute-widgets-base-core-theming.mjs +314 -0
- package/fesm2022/cute-widgets-base-core-theming.mjs.map +1 -0
- package/fesm2022/cute-widgets-base-core-types.mjs +22 -0
- package/fesm2022/cute-widgets-base-core-types.mjs.map +1 -0
- package/fesm2022/cute-widgets-base-core-utils.mjs +257 -0
- package/fesm2022/cute-widgets-base-core-utils.mjs.map +1 -0
- package/fesm2022/cute-widgets-base-core.mjs +1600 -0
- package/fesm2022/cute-widgets-base-core.mjs.map +1 -0
- package/fesm2022/cute-widgets-base-datepicker.mjs +4827 -0
- package/fesm2022/cute-widgets-base-datepicker.mjs.map +1 -0
- package/fesm2022/cute-widgets-base-dialog.mjs +1046 -0
- package/fesm2022/cute-widgets-base-dialog.mjs.map +1 -0
- package/fesm2022/cute-widgets-base-divider.mjs +86 -0
- package/fesm2022/cute-widgets-base-divider.mjs.map +1 -0
- package/fesm2022/cute-widgets-base-expansion.mjs +623 -0
- package/fesm2022/cute-widgets-base-expansion.mjs.map +1 -0
- package/fesm2022/cute-widgets-base-form-field.mjs +969 -0
- package/fesm2022/cute-widgets-base-form-field.mjs.map +1 -0
- package/fesm2022/cute-widgets-base-grid-list.mjs +715 -0
- package/fesm2022/cute-widgets-base-grid-list.mjs.map +1 -0
- package/fesm2022/cute-widgets-base-icon.mjs +1105 -0
- package/fesm2022/cute-widgets-base-icon.mjs.map +1 -0
- package/fesm2022/cute-widgets-base-input.mjs +726 -0
- package/fesm2022/cute-widgets-base-input.mjs.map +1 -0
- package/fesm2022/cute-widgets-base-layout-container.mjs +95 -0
- package/fesm2022/cute-widgets-base-layout-container.mjs.map +1 -0
- package/fesm2022/cute-widgets-base-layout-stack.mjs +166 -0
- package/fesm2022/cute-widgets-base-layout-stack.mjs.map +1 -0
- package/fesm2022/cute-widgets-base-layout.mjs +250 -0
- package/fesm2022/cute-widgets-base-layout.mjs.map +1 -0
- package/fesm2022/cute-widgets-base-list.mjs +1557 -0
- package/fesm2022/cute-widgets-base-list.mjs.map +1 -0
- package/fesm2022/cute-widgets-base-menu.mjs +1283 -0
- package/fesm2022/cute-widgets-base-menu.mjs.map +1 -0
- package/fesm2022/cute-widgets-base-navbar.mjs +359 -0
- package/fesm2022/cute-widgets-base-navbar.mjs.map +1 -0
- package/fesm2022/cute-widgets-base-paginator.mjs +485 -0
- package/fesm2022/cute-widgets-base-paginator.mjs.map +1 -0
- package/fesm2022/cute-widgets-base-progress.mjs +321 -0
- package/fesm2022/cute-widgets-base-progress.mjs.map +1 -0
- package/fesm2022/cute-widgets-base-radio.mjs +637 -0
- package/fesm2022/cute-widgets-base-radio.mjs.map +1 -0
- package/fesm2022/cute-widgets-base-select.mjs +1208 -0
- package/fesm2022/cute-widgets-base-select.mjs.map +1 -0
- package/fesm2022/cute-widgets-base-sidenav.mjs +1095 -0
- package/fesm2022/cute-widgets-base-sidenav.mjs.map +1 -0
- package/fesm2022/cute-widgets-base-slider.mjs +99 -0
- package/fesm2022/cute-widgets-base-slider.mjs.map +1 -0
- package/fesm2022/cute-widgets-base-snack-bar.mjs +897 -0
- package/fesm2022/cute-widgets-base-snack-bar.mjs.map +1 -0
- package/fesm2022/cute-widgets-base-sort.mjs +639 -0
- package/fesm2022/cute-widgets-base-sort.mjs.map +1 -0
- package/fesm2022/cute-widgets-base-spinner.mjs +154 -0
- package/fesm2022/cute-widgets-base-spinner.mjs.map +1 -0
- package/fesm2022/cute-widgets-base-stepper.mjs +673 -0
- package/fesm2022/cute-widgets-base-stepper.mjs.map +1 -0
- package/fesm2022/cute-widgets-base-table.mjs +1023 -0
- package/fesm2022/cute-widgets-base-table.mjs.map +1 -0
- package/fesm2022/cute-widgets-base-tabs.mjs +729 -0
- package/fesm2022/cute-widgets-base-tabs.mjs.map +1 -0
- package/fesm2022/cute-widgets-base-timepicker.mjs +965 -0
- package/fesm2022/cute-widgets-base-timepicker.mjs.map +1 -0
- package/fesm2022/cute-widgets-base-toolbar.mjs +120 -0
- package/fesm2022/cute-widgets-base-toolbar.mjs.map +1 -0
- package/fesm2022/cute-widgets-base-tooltip.mjs +947 -0
- package/fesm2022/cute-widgets-base-tooltip.mjs.map +1 -0
- package/fesm2022/cute-widgets-base-tree.mjs +598 -0
- package/fesm2022/cute-widgets-base-tree.mjs.map +1 -0
- package/fesm2022/cute-widgets-base.mjs +68 -0
- package/fesm2022/cute-widgets-base.mjs.map +1 -0
- package/form-field/index.d.ts +401 -0
- package/grid-list/index.d.ts +361 -0
- package/icon/index.d.ts +477 -0
- package/index.d.ts +3 -0
- package/input/index.d.ts +256 -0
- package/layout/container/index.d.ts +31 -0
- package/layout/index.d.ts +78 -0
- package/layout/stack/index.d.ts +52 -0
- package/list/index.d.ts +659 -0
- package/menu/index.d.ts +497 -0
- package/navbar/index.d.ts +91 -0
- package/package.json +279 -0
- package/paginator/index.d.ts +216 -0
- package/progress/index.d.ts +130 -0
- package/radio/index.d.ts +259 -0
- package/select/index.d.ts +426 -0
- package/sidenav/index.d.ts +369 -0
- package/slider/index.d.ts +48 -0
- package/snack-bar/index.d.ts +374 -0
- package/sort/index.d.ts +334 -0
- package/spinner/index.d.ts +70 -0
- package/stepper/index.d.ts +295 -0
- package/table/index.d.ts +395 -0
- package/tabs/index.d.ts +307 -0
- package/timepicker/index.d.ts +350 -0
- package/toolbar/index.d.ts +36 -0
- package/tooltip/index.d.ts +299 -0
- package/tree/index.d.ts +314 -0
|
@@ -0,0 +1,1283 @@
|
|
|
1
|
+
import * as i0 from '@angular/core';
|
|
2
|
+
import { InjectionToken, inject, ElementRef, DOCUMENT, ChangeDetectorRef, booleanAttribute, Input, ViewEncapsulation, ChangeDetectionStrategy, Component, TemplateRef, ApplicationRef, Injector, ViewContainerRef, Directive, isDevMode, QueryList, EventEmitter, afterNextRender, Output, ContentChild, ContentChildren, ViewChild, Inject, Optional, Self, NgModule } from '@angular/core';
|
|
3
|
+
import * as i4 from '@angular/cdk/a11y';
|
|
4
|
+
import { FocusMonitor, FocusKeyManager, isFakeTouchstartFromScreenReader, isFakeMousedownFromScreenReader } from '@angular/cdk/a11y';
|
|
5
|
+
import { UP_ARROW, DOWN_ARROW, RIGHT_ARROW, LEFT_ARROW, ESCAPE, hasModifierKey, ENTER, SPACE } from '@angular/cdk/keycodes';
|
|
6
|
+
import { Subject, merge, Subscription, of, asapScheduler } from 'rxjs';
|
|
7
|
+
import { startWith, switchMap, takeUntil, filter, take, delay } from 'rxjs/operators';
|
|
8
|
+
import { TemplatePortal, DomPortalOutlet } from '@angular/cdk/portal';
|
|
9
|
+
import { trigger, state, transition, style, animate } from '@angular/animations';
|
|
10
|
+
import * as i1 from '@angular/cdk/menu';
|
|
11
|
+
import { CdkMenu } from '@angular/cdk/menu';
|
|
12
|
+
import * as i1$1 from '@angular/cdk/overlay';
|
|
13
|
+
import { Overlay, OverlayConfig } from '@angular/cdk/overlay';
|
|
14
|
+
import { normalizePassiveListenerOptions } from '@angular/cdk/platform';
|
|
15
|
+
import * as i3 from '@angular/cdk/bidi';
|
|
16
|
+
import { CommonModule } from '@angular/common';
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* @license Apache-2.0
|
|
20
|
+
*
|
|
21
|
+
* Copyright (c) 2025 CuteWidgets Team. All Rights Reserved.
|
|
22
|
+
*
|
|
23
|
+
* You may not use this file except in compliance with the License
|
|
24
|
+
* that can be found at http://www.apache.org/licenses/LICENSE-2.0
|
|
25
|
+
*
|
|
26
|
+
* This code is a modification of the `@angular/material` original
|
|
27
|
+
* code licensed under MIT-style License (https://angular.dev/license).
|
|
28
|
+
*/
|
|
29
|
+
/**
|
|
30
|
+
* Injection token used to provide the parent menu to menu-specific components.
|
|
31
|
+
*/
|
|
32
|
+
const CUTE_MENU_PANEL = new InjectionToken('CUTE_MENU_PANEL');
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* @license Apache-2.0
|
|
36
|
+
*
|
|
37
|
+
* Copyright (c) 2025 CuteWidgets Team. All Rights Reserved.
|
|
38
|
+
*
|
|
39
|
+
* You may not use this file except in compliance with the License
|
|
40
|
+
* that can be found at http://www.apache.org/licenses/LICENSE-2.0
|
|
41
|
+
*
|
|
42
|
+
* This code is a modification of the `@angular/material` original
|
|
43
|
+
* code licensed under MIT-style License (https://angular.dev/license).
|
|
44
|
+
*/
|
|
45
|
+
/**
|
|
46
|
+
* Single item inside a `cute-menu`. Provides the menu item styling and accessibility treatment.
|
|
47
|
+
*/
|
|
48
|
+
class CuteMenuItem {
|
|
49
|
+
constructor() {
|
|
50
|
+
this._elementRef = inject(ElementRef);
|
|
51
|
+
this._document = inject(DOCUMENT);
|
|
52
|
+
this._focusMonitor = inject(FocusMonitor);
|
|
53
|
+
this._parentMenu = inject(CUTE_MENU_PANEL, { optional: true });
|
|
54
|
+
this._changeDetectorRef = inject(ChangeDetectorRef);
|
|
55
|
+
/** ARIA role for the menu item. */
|
|
56
|
+
this.role = 'menuitem';
|
|
57
|
+
/** Whether the menu item is disabled. */
|
|
58
|
+
this.disabled = false;
|
|
59
|
+
/** Whether ripples are disabled on the menu item. */
|
|
60
|
+
this.disableRipple = false;
|
|
61
|
+
/** Stream that emits when the menu item is hovered. */
|
|
62
|
+
this._hovered = new Subject();
|
|
63
|
+
/** Stream that emits when the menu item is focused. */
|
|
64
|
+
this._focused = new Subject();
|
|
65
|
+
/** Whether the menu item is highlighted. */
|
|
66
|
+
this._highlighted = false;
|
|
67
|
+
/** Whether the menu item acts as a trigger for a submenu. */
|
|
68
|
+
this._triggersSubmenu = false;
|
|
69
|
+
this._parentMenu?.addItem?.(this);
|
|
70
|
+
}
|
|
71
|
+
/** Focuses the menu item. */
|
|
72
|
+
focus(origin, options) {
|
|
73
|
+
if (this._focusMonitor && origin) {
|
|
74
|
+
this._focusMonitor.focusVia(this._getHostElement(), origin, options);
|
|
75
|
+
}
|
|
76
|
+
else {
|
|
77
|
+
this._getHostElement().focus(options);
|
|
78
|
+
}
|
|
79
|
+
this._focused.next(this);
|
|
80
|
+
}
|
|
81
|
+
ngAfterViewInit() {
|
|
82
|
+
// Start monitoring the element, so it gets the appropriate focused classes. We want
|
|
83
|
+
// to show the focus style for menu items only when the focus was not caused by a
|
|
84
|
+
// mouse or touch interaction.
|
|
85
|
+
this._focusMonitor?.monitor(this._elementRef, false);
|
|
86
|
+
}
|
|
87
|
+
ngOnDestroy() {
|
|
88
|
+
this._focusMonitor?.stopMonitoring(this._elementRef);
|
|
89
|
+
if (this._parentMenu && this._parentMenu.removeItem) {
|
|
90
|
+
this._parentMenu.removeItem(this);
|
|
91
|
+
}
|
|
92
|
+
this._hovered.complete();
|
|
93
|
+
this._focused.complete();
|
|
94
|
+
}
|
|
95
|
+
/** Used to set the `tabindex`. */
|
|
96
|
+
_getTabIndex() {
|
|
97
|
+
return this.disabled ? '-1' : '0';
|
|
98
|
+
}
|
|
99
|
+
/** Returns the host DOM element. */
|
|
100
|
+
_getHostElement() {
|
|
101
|
+
return this._elementRef.nativeElement;
|
|
102
|
+
}
|
|
103
|
+
/** Prevents the default element actions if it is disabled. */
|
|
104
|
+
_checkDisabled(event) {
|
|
105
|
+
if (this.disabled) {
|
|
106
|
+
event.preventDefault();
|
|
107
|
+
event.stopPropagation();
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
/** Emits to the hover stream. */
|
|
111
|
+
_handleMouseEnter() {
|
|
112
|
+
this._hovered.next(this);
|
|
113
|
+
}
|
|
114
|
+
/** Gets the label to be used when determining whether the option should be focused. */
|
|
115
|
+
getLabel() {
|
|
116
|
+
const clone = this._elementRef.nativeElement.cloneNode(true);
|
|
117
|
+
const icons = clone.querySelectorAll('cute-icon, .material-icons');
|
|
118
|
+
// Strip away icons, so they don't show up in the text.
|
|
119
|
+
for (let i = 0; i < icons.length; i++) {
|
|
120
|
+
icons[i].remove();
|
|
121
|
+
}
|
|
122
|
+
return clone.textContent?.trim() || '';
|
|
123
|
+
}
|
|
124
|
+
_setHighlighted(isHighlighted) {
|
|
125
|
+
// We need to mark this for check for the case where the content is coming from a
|
|
126
|
+
// `cuteMenuContent` whose change detection tree is at the declaration position,
|
|
127
|
+
// not the insertion position. See #23175.
|
|
128
|
+
this._highlighted = isHighlighted;
|
|
129
|
+
this._changeDetectorRef.markForCheck();
|
|
130
|
+
}
|
|
131
|
+
_setTriggersSubmenu(triggersSubmenu) {
|
|
132
|
+
this._triggersSubmenu = triggersSubmenu;
|
|
133
|
+
this._changeDetectorRef.markForCheck();
|
|
134
|
+
}
|
|
135
|
+
_hasFocus() {
|
|
136
|
+
return this._document && this._document.activeElement === this._getHostElement();
|
|
137
|
+
}
|
|
138
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.15", ngImport: i0, type: CuteMenuItem, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
|
139
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "20.3.15", type: CuteMenuItem, isStandalone: true, selector: "[cute-menu-item]", inputs: { role: "role", disabled: ["disabled", "disabled", booleanAttribute], disableRipple: ["disableRipple", "disableRipple", booleanAttribute] }, host: { listeners: { "click": "_checkDisabled($event)", "mouseenter": "_handleMouseEnter()" }, properties: { "attr.role": "role", "class.active": "_highlighted", "class.cute-menu-item-submenu-trigger": "_triggersSubmenu", "attr.tabindex": "_getTabIndex()", "attr.aria-disabled": "disabled", "disabled": "disabled || null" }, classAttribute: "cute-menu-item" }, exportAs: ["cuteMenuItem"], ngImport: i0, template: `
|
|
140
|
+
<ng-content select="cute-icon, i[class], [cuteMenuItemIcon]"></ng-content>
|
|
141
|
+
<span class="cute-menu-item-text"><ng-content></ng-content></span>
|
|
142
|
+
@if (_triggersSubmenu) {
|
|
143
|
+
<svg class="cute-menu-item-submenu-icon"
|
|
144
|
+
viewBox="0 0 5 10"
|
|
145
|
+
focusable="false"
|
|
146
|
+
aria-hidden="true">
|
|
147
|
+
<polygon points="0,0 5,5 0,10"/>
|
|
148
|
+
</svg>
|
|
149
|
+
}
|
|
150
|
+
`, isInline: true, styles: [".cute-menu-item{display:flex;position:relative;justify-content:flex-start;cursor:pointer;width:100%;text-align:start;text-overflow:ellipsis;text-decoration:none;box-sizing:border-box;font-size:inherit;margin:0;padding:.25rem 1rem;align-items:center;white-space:nowrap;overflow:hidden;-webkit-user-select:none;user-select:none;border:none;outline:none;background:none;pointer-events:auto}.cute-menu-item:hover,.cute-menu-item.active{outline:none;background-color:rgba(var(--bs-body-color-rgb),.04)}.cute-menu-item[disabled]{opacity:.38;color:var(--bs-body-color);cursor:default}.cute-menu-item[disabled]:hover,.cute-menu-item[disabled]:focus{outline:none;background-color:var(--bs-body-bg)}.cute-menu-item[disabled]:after{display:block;position:absolute;content:\"\";inset:0}.cute-menu-item:not([disabled]).cdk-keyboard-focused{background-color:rgba(var(--bs-body-color-rgb),.04)}.cute-menu-item>[role=img],.cute-menu-item i[class]{position:absolute;left:4px;width:24px;height:24px;line-height:24px;background-repeat:no-repeat;display:inline-block;fill:currentColor;text-align:center;overflow:hidden;-webkit-user-select:none;user-select:none;-webkit-font-smoothing:antialiased}[dir=rtl] .cute-menu-item>[role=img],[dir=rtl] .cute-menu-item i[class]{right:4px;left:auto}.cute-menu-item .cute-menu-item-text{margin-left:1rem}[dir=rtl] .cute-menu-item .cute-menu-item-text{margin-right:1rem;margin-left:auto}.cute-menu-item .cute-menu-item-submenu-icon{position:absolute;top:50%;right:12px;transform:translateY(-50%);width:5px;height:10px;fill:currentColor;opacity:.75}[dir=rtl] .cute-menu-item .cute-menu-item-submenu-icon{left:12px;right:auto;transform:translateY(-50%) rotate(180deg)}.cute-menu-item-submenu-trigger{padding-right:2rem}[dir=rtl] .cute-menu-item-submenu-trigger{padding-right:1rem;padding-left:2rem}\n"], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None }); }
|
|
151
|
+
}
|
|
152
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.15", ngImport: i0, type: CuteMenuItem, decorators: [{
|
|
153
|
+
type: Component,
|
|
154
|
+
args: [{ selector: '[cute-menu-item]', exportAs: 'cuteMenuItem', template: `
|
|
155
|
+
<ng-content select="cute-icon, i[class], [cuteMenuItemIcon]"></ng-content>
|
|
156
|
+
<span class="cute-menu-item-text"><ng-content></ng-content></span>
|
|
157
|
+
@if (_triggersSubmenu) {
|
|
158
|
+
<svg class="cute-menu-item-submenu-icon"
|
|
159
|
+
viewBox="0 0 5 10"
|
|
160
|
+
focusable="false"
|
|
161
|
+
aria-hidden="true">
|
|
162
|
+
<polygon points="0,0 5,5 0,10"/>
|
|
163
|
+
</svg>
|
|
164
|
+
}
|
|
165
|
+
`, host: {
|
|
166
|
+
'[attr.role]': 'role',
|
|
167
|
+
'class': 'cute-menu-item',
|
|
168
|
+
'[class.active]': '_highlighted',
|
|
169
|
+
'[class.cute-menu-item-submenu-trigger]': '_triggersSubmenu',
|
|
170
|
+
//'[class.disabled]': 'disabled',
|
|
171
|
+
'[attr.tabindex]': '_getTabIndex()',
|
|
172
|
+
'[attr.aria-disabled]': 'disabled',
|
|
173
|
+
'[disabled]': 'disabled || null',
|
|
174
|
+
'(click)': '_checkDisabled($event)',
|
|
175
|
+
'(mouseenter)': '_handleMouseEnter()',
|
|
176
|
+
}, changeDetection: ChangeDetectionStrategy.OnPush, encapsulation: ViewEncapsulation.None, styles: [".cute-menu-item{display:flex;position:relative;justify-content:flex-start;cursor:pointer;width:100%;text-align:start;text-overflow:ellipsis;text-decoration:none;box-sizing:border-box;font-size:inherit;margin:0;padding:.25rem 1rem;align-items:center;white-space:nowrap;overflow:hidden;-webkit-user-select:none;user-select:none;border:none;outline:none;background:none;pointer-events:auto}.cute-menu-item:hover,.cute-menu-item.active{outline:none;background-color:rgba(var(--bs-body-color-rgb),.04)}.cute-menu-item[disabled]{opacity:.38;color:var(--bs-body-color);cursor:default}.cute-menu-item[disabled]:hover,.cute-menu-item[disabled]:focus{outline:none;background-color:var(--bs-body-bg)}.cute-menu-item[disabled]:after{display:block;position:absolute;content:\"\";inset:0}.cute-menu-item:not([disabled]).cdk-keyboard-focused{background-color:rgba(var(--bs-body-color-rgb),.04)}.cute-menu-item>[role=img],.cute-menu-item i[class]{position:absolute;left:4px;width:24px;height:24px;line-height:24px;background-repeat:no-repeat;display:inline-block;fill:currentColor;text-align:center;overflow:hidden;-webkit-user-select:none;user-select:none;-webkit-font-smoothing:antialiased}[dir=rtl] .cute-menu-item>[role=img],[dir=rtl] .cute-menu-item i[class]{right:4px;left:auto}.cute-menu-item .cute-menu-item-text{margin-left:1rem}[dir=rtl] .cute-menu-item .cute-menu-item-text{margin-right:1rem;margin-left:auto}.cute-menu-item .cute-menu-item-submenu-icon{position:absolute;top:50%;right:12px;transform:translateY(-50%);width:5px;height:10px;fill:currentColor;opacity:.75}[dir=rtl] .cute-menu-item .cute-menu-item-submenu-icon{left:12px;right:auto;transform:translateY(-50%) rotate(180deg)}.cute-menu-item-submenu-trigger{padding-right:2rem}[dir=rtl] .cute-menu-item-submenu-trigger{padding-right:1rem;padding-left:2rem}\n"] }]
|
|
177
|
+
}], ctorParameters: () => [], propDecorators: { role: [{
|
|
178
|
+
type: Input
|
|
179
|
+
}], disabled: [{
|
|
180
|
+
type: Input,
|
|
181
|
+
args: [{ transform: booleanAttribute }]
|
|
182
|
+
}], disableRipple: [{
|
|
183
|
+
type: Input,
|
|
184
|
+
args: [{ transform: booleanAttribute }]
|
|
185
|
+
}] } });
|
|
186
|
+
|
|
187
|
+
/**
|
|
188
|
+
* @license Apache-2.0
|
|
189
|
+
*
|
|
190
|
+
* Copyright (c) 2025 CuteWidgets Team. All Rights Reserved.
|
|
191
|
+
*
|
|
192
|
+
* You may not use this file except in compliance with the License
|
|
193
|
+
* that can be found at http://www.apache.org/licenses/LICENSE-2.0
|
|
194
|
+
*
|
|
195
|
+
* This code is a modification of the `@angular/material` original
|
|
196
|
+
* code licensed under MIT-style License (https://angular.dev/license).
|
|
197
|
+
*/
|
|
198
|
+
/**
|
|
199
|
+
* Throws an exception for the case when menu's x-position value isn't valid.
|
|
200
|
+
* In other words, it doesn't match 'before' or 'after'.
|
|
201
|
+
*/
|
|
202
|
+
function throwCuteMenuInvalidPositionX() {
|
|
203
|
+
throw Error(`xPosition value must be either 'before' or after'.
|
|
204
|
+
Example: <cute-menu xPosition="before"></cute-menu>`);
|
|
205
|
+
}
|
|
206
|
+
/**
|
|
207
|
+
* Throws an exception for the case when menu's y-position value isn't valid.
|
|
208
|
+
* In other words, it doesn't match 'above' or 'below'.
|
|
209
|
+
*/
|
|
210
|
+
function throwCuteMenuInvalidPositionY() {
|
|
211
|
+
throw Error(`yPosition value must be either 'above' or below'.
|
|
212
|
+
Example: <cute-menu yPosition="above"></cute-menu>`);
|
|
213
|
+
}
|
|
214
|
+
/**
|
|
215
|
+
* Throws an exception for the case when a menu is assigned
|
|
216
|
+
* to a trigger that is placed inside the same menu.
|
|
217
|
+
*/
|
|
218
|
+
function throwCuteMenuRecursiveError() {
|
|
219
|
+
throw Error(`cuteMenuTriggerFor: menu cannot contain its own trigger. Assign a menu that is ` +
|
|
220
|
+
`not a parent of the trigger or move the trigger outside of the menu.`);
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
/**
|
|
224
|
+
* @license Apache-2.0
|
|
225
|
+
*
|
|
226
|
+
* Copyright (c) 2025 CuteWidgets Team. All Rights Reserved.
|
|
227
|
+
*
|
|
228
|
+
* You may not use this file except in compliance with the License
|
|
229
|
+
* that can be found at http://www.apache.org/licenses/LICENSE-2.0
|
|
230
|
+
*
|
|
231
|
+
* This code is a modification of the `@angular/material` original
|
|
232
|
+
* code licensed under MIT-style License (https://angular.dev/license).
|
|
233
|
+
*/
|
|
234
|
+
/**
|
|
235
|
+
* Injection token that can be used to reference instances of `CuteMenuContent`. It serves
|
|
236
|
+
* as an alternative token to the actual `CuteMenuContent` class, which could cause unnecessary
|
|
237
|
+
* retention of the class and its directive metadata.
|
|
238
|
+
*/
|
|
239
|
+
const CUTE_MENU_CONTENT = new InjectionToken('CuteMenuContent');
|
|
240
|
+
/** Menu content that will be rendered lazily once the menu is opened. */
|
|
241
|
+
class CuteMenuContent {
|
|
242
|
+
constructor() {
|
|
243
|
+
this._template = inject(TemplateRef);
|
|
244
|
+
this._appRef = inject(ApplicationRef);
|
|
245
|
+
this._injector = inject(Injector);
|
|
246
|
+
this._viewContainerRef = inject(ViewContainerRef);
|
|
247
|
+
this._document = inject(DOCUMENT);
|
|
248
|
+
this._changeDetectorRef = inject(ChangeDetectorRef);
|
|
249
|
+
/** Emits when the menu content has been attached. */
|
|
250
|
+
this._attached = new Subject();
|
|
251
|
+
}
|
|
252
|
+
/**
|
|
253
|
+
* Attaches the content with a particular context.
|
|
254
|
+
*/
|
|
255
|
+
attach(context = {}) {
|
|
256
|
+
if (!this._portal) {
|
|
257
|
+
this._portal = new TemplatePortal(this._template, this._viewContainerRef);
|
|
258
|
+
}
|
|
259
|
+
this.detach();
|
|
260
|
+
if (!this._outlet) {
|
|
261
|
+
this._outlet = new DomPortalOutlet(this._document.createElement('div'), this._appRef, this._injector);
|
|
262
|
+
}
|
|
263
|
+
const element = this._template.elementRef.nativeElement;
|
|
264
|
+
// Because we support opening the same menu from different triggers (which in turn have their
|
|
265
|
+
// own `OverlayRef` panel), we have to re-insert the host element every time, otherwise we
|
|
266
|
+
// risk it staying attached to a pane that's no longer in the DOM.
|
|
267
|
+
element.parentNode.insertBefore(this._outlet.outletElement, element);
|
|
268
|
+
// When `CuteMenuContent` is used in an `OnPush` component, the insertion of the menu
|
|
269
|
+
// content via `createEmbeddedView` does not cause the content to be seen as "dirty"
|
|
270
|
+
// by Angular. This causes the `@ContentChildren` for menu items within the menu to
|
|
271
|
+
// not be updated by Angular. By explicitly marking for check here, we tell Angular that
|
|
272
|
+
// it needs to check for new menu items and update the `@ContentChild` in `CuteMenu`.
|
|
273
|
+
// @breaking-change 9.0.0 Make change detector ref required
|
|
274
|
+
this._changeDetectorRef.markForCheck();
|
|
275
|
+
this._portal.attach(this._outlet, context);
|
|
276
|
+
this._attached.next();
|
|
277
|
+
}
|
|
278
|
+
/**
|
|
279
|
+
* Detaches the content.
|
|
280
|
+
*/
|
|
281
|
+
detach() {
|
|
282
|
+
if (this._portal?.isAttached) {
|
|
283
|
+
this._portal.detach();
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
ngOnDestroy() {
|
|
287
|
+
this.detach();
|
|
288
|
+
this._outlet?.dispose();
|
|
289
|
+
}
|
|
290
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.15", ngImport: i0, type: CuteMenuContent, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
291
|
+
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "20.3.15", type: CuteMenuContent, isStandalone: true, selector: "ng-template[cuteMenuContent]", providers: [{ provide: CUTE_MENU_CONTENT, useExisting: CuteMenuContent }], ngImport: i0 }); }
|
|
292
|
+
}
|
|
293
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.15", ngImport: i0, type: CuteMenuContent, decorators: [{
|
|
294
|
+
type: Directive,
|
|
295
|
+
args: [{
|
|
296
|
+
selector: 'ng-template[cuteMenuContent]',
|
|
297
|
+
providers: [{ provide: CUTE_MENU_CONTENT, useExisting: CuteMenuContent }],
|
|
298
|
+
standalone: true,
|
|
299
|
+
}]
|
|
300
|
+
}], ctorParameters: () => [] });
|
|
301
|
+
|
|
302
|
+
/**
|
|
303
|
+
* @license Apache-2.0
|
|
304
|
+
*
|
|
305
|
+
* Copyright (c) 2025 CuteWidgets Team. All Rights Reserved.
|
|
306
|
+
*
|
|
307
|
+
* You may not use this file except in compliance with the License
|
|
308
|
+
* that can be found at http://www.apache.org/licenses/LICENSE-2.0
|
|
309
|
+
*
|
|
310
|
+
* This code is a modification of the `@angular/material` original
|
|
311
|
+
* code licensed under MIT-style License (https://angular.dev/license).
|
|
312
|
+
*/
|
|
313
|
+
/**
|
|
314
|
+
* Animations used by the cute-menu component.
|
|
315
|
+
* Animation duration and timing values are based on:
|
|
316
|
+
* https://material.io/guidelines/components/menus.html#menus-usage
|
|
317
|
+
* @docs-private
|
|
318
|
+
*/
|
|
319
|
+
const cuteMenuAnimations = {
|
|
320
|
+
/**
|
|
321
|
+
* This animation controls the menu panel's entry and exit from the page.
|
|
322
|
+
*
|
|
323
|
+
* When the menu panel is added to the DOM, it scales in and fades in its border.
|
|
324
|
+
*
|
|
325
|
+
* When the menu panel is removed from the DOM, it simply fades out after a brief
|
|
326
|
+
* delay to display the ripple.
|
|
327
|
+
*/
|
|
328
|
+
transformMenu: trigger('transformMenu', [
|
|
329
|
+
state('void', style({
|
|
330
|
+
opacity: 0,
|
|
331
|
+
transform: 'scale(0.8)',
|
|
332
|
+
})),
|
|
333
|
+
transition('void => enter', animate('120ms cubic-bezier(0, 0, 0.2, 1)', style({
|
|
334
|
+
opacity: 1,
|
|
335
|
+
transform: 'scale(1)',
|
|
336
|
+
}))),
|
|
337
|
+
transition('* => void', animate('100ms 25ms linear', style({ opacity: 0 }))),
|
|
338
|
+
]),
|
|
339
|
+
/**
|
|
340
|
+
* This animation fades in the background color and content of the menu panel
|
|
341
|
+
* after its containing element is scaled in.
|
|
342
|
+
*/
|
|
343
|
+
fadeInItems: trigger('fadeInItems', [
|
|
344
|
+
// TODO(crisbeto): this is inside the `transformMenu`
|
|
345
|
+
// now. Remove next time we do breaking changes.
|
|
346
|
+
state('showing', style({ opacity: 1 })),
|
|
347
|
+
transition('void => *', [
|
|
348
|
+
style({ opacity: 0 }),
|
|
349
|
+
animate('400ms 100ms cubic-bezier(0.55, 0, 0.55, 0.2)'),
|
|
350
|
+
]),
|
|
351
|
+
]),
|
|
352
|
+
};
|
|
353
|
+
/**
|
|
354
|
+
* @deprecated
|
|
355
|
+
* @breaking-change 8.0.0
|
|
356
|
+
* @docs-private
|
|
357
|
+
*/
|
|
358
|
+
//export const fadeInItems = cuteMenuAnimations.fadeInItems;
|
|
359
|
+
/**
|
|
360
|
+
* @deprecated
|
|
361
|
+
* @breaking-change 8.0.0
|
|
362
|
+
* @docs-private
|
|
363
|
+
*/
|
|
364
|
+
//export const transformMenu = cuteMenuAnimations.transformMenu;
|
|
365
|
+
|
|
366
|
+
/**
|
|
367
|
+
* @license Apache-2.0
|
|
368
|
+
*
|
|
369
|
+
* Copyright (c) 2025 CuteWidgets Team. All Rights Reserved.
|
|
370
|
+
*
|
|
371
|
+
* You may not use this file except in compliance with the License
|
|
372
|
+
* that can be found at http://www.apache.org/licenses/LICENSE-2.0
|
|
373
|
+
*
|
|
374
|
+
* This code is a modification of the `@angular/material` original
|
|
375
|
+
* code licensed under MIT-style License (https://angular.dev/license).
|
|
376
|
+
*/
|
|
377
|
+
let menuPanelUid = 0;
|
|
378
|
+
/** Injection token to be used to override the default options for `mat-menu`. */
|
|
379
|
+
const CUTE_MENU_DEFAULT_OPTIONS = new InjectionToken('cute-menu-default-options', {
|
|
380
|
+
providedIn: 'root',
|
|
381
|
+
factory: CUTE_MENU_DEFAULT_OPTIONS_FACTORY,
|
|
382
|
+
});
|
|
383
|
+
/**
|
|
384
|
+
* @docs-private
|
|
385
|
+
* @deprecated No longer used, will be removed.
|
|
386
|
+
* @breaking-change 21.0.0
|
|
387
|
+
*/
|
|
388
|
+
function CUTE_MENU_DEFAULT_OPTIONS_FACTORY() {
|
|
389
|
+
return {
|
|
390
|
+
overlapTrigger: false,
|
|
391
|
+
xPosition: 'after',
|
|
392
|
+
yPosition: 'below',
|
|
393
|
+
backdropClass: 'cdk-overlay-transparent-backdrop',
|
|
394
|
+
};
|
|
395
|
+
}
|
|
396
|
+
class CuteMenu {
|
|
397
|
+
/** Position of the menu in the X axis. */
|
|
398
|
+
get xPosition() { return this._xPosition; }
|
|
399
|
+
set xPosition(value) {
|
|
400
|
+
if (value !== 'before' &&
|
|
401
|
+
value !== 'after' &&
|
|
402
|
+
isDevMode()) {
|
|
403
|
+
throwCuteMenuInvalidPositionX();
|
|
404
|
+
}
|
|
405
|
+
this._xPosition = value;
|
|
406
|
+
this.setPositionClasses();
|
|
407
|
+
}
|
|
408
|
+
/** Position of the menu in the Y axis. */
|
|
409
|
+
get yPosition() { return this._yPosition; }
|
|
410
|
+
set yPosition(value) {
|
|
411
|
+
if (value !== 'above' && value !== 'below' && isDevMode()) {
|
|
412
|
+
throwCuteMenuInvalidPositionY();
|
|
413
|
+
}
|
|
414
|
+
this._yPosition = value;
|
|
415
|
+
this.setPositionClasses();
|
|
416
|
+
}
|
|
417
|
+
/**
|
|
418
|
+
* This method takes classes set on the host mat-menu element and applies them on the
|
|
419
|
+
* menu template that displays in the overlay container. Otherwise, it's difficult
|
|
420
|
+
* to style the containing menu from outside the component.
|
|
421
|
+
* @param classes list of class names
|
|
422
|
+
*/
|
|
423
|
+
set panelClass(classes) {
|
|
424
|
+
const previousPanelClass = this._previousPanelClass;
|
|
425
|
+
const newClassList = { ...this._classList };
|
|
426
|
+
if (previousPanelClass && previousPanelClass.length) {
|
|
427
|
+
previousPanelClass.split(' ').forEach((className) => {
|
|
428
|
+
newClassList[className] = false;
|
|
429
|
+
});
|
|
430
|
+
}
|
|
431
|
+
this._previousPanelClass = classes;
|
|
432
|
+
if (classes && classes.length) {
|
|
433
|
+
classes.split(' ').forEach((className) => {
|
|
434
|
+
newClassList[className] = true;
|
|
435
|
+
});
|
|
436
|
+
this._elementRef.nativeElement.className = '';
|
|
437
|
+
}
|
|
438
|
+
this._classList = newClassList;
|
|
439
|
+
}
|
|
440
|
+
constructor() {
|
|
441
|
+
this._elementRef = inject(ElementRef);
|
|
442
|
+
this._changeDetectorRef = inject(ChangeDetectorRef);
|
|
443
|
+
this._injector = inject(Injector);
|
|
444
|
+
this._elevationPrefix = 'shadow';
|
|
445
|
+
this._baseElevation = 1;
|
|
446
|
+
/** Config object to be passed into the menu's ngClass */
|
|
447
|
+
this._classList = {};
|
|
448
|
+
/** Current state of the panel animation. */
|
|
449
|
+
this._panelAnimationState = 'void';
|
|
450
|
+
/** Only the direct descendant menu items. */
|
|
451
|
+
this._directDescendantItems = new QueryList();
|
|
452
|
+
/** Emits whenever an animation on the menu completes. */
|
|
453
|
+
this._animationDone = new Subject();
|
|
454
|
+
/** Event emitted when the menu is closed. */
|
|
455
|
+
this.closed = new EventEmitter();
|
|
456
|
+
this.panelId = `cute-menu-panel-${menuPanelUid++}`;
|
|
457
|
+
const defaultOptions = inject(CUTE_MENU_DEFAULT_OPTIONS);
|
|
458
|
+
this.overlayPanelClass = defaultOptions.overlayPanelClass || '';
|
|
459
|
+
this._xPosition = defaultOptions.xPosition;
|
|
460
|
+
this._yPosition = defaultOptions.yPosition;
|
|
461
|
+
this.backdropClass = defaultOptions.backdropClass;
|
|
462
|
+
this.overlapTrigger = defaultOptions.overlapTrigger;
|
|
463
|
+
this.hasBackdrop = defaultOptions.hasBackdrop;
|
|
464
|
+
}
|
|
465
|
+
ngOnInit() {
|
|
466
|
+
this.setPositionClasses();
|
|
467
|
+
}
|
|
468
|
+
ngAfterContentInit() {
|
|
469
|
+
this._updateDirectDescendants();
|
|
470
|
+
this._keyManager = new FocusKeyManager(this._directDescendantItems)
|
|
471
|
+
.withWrap()
|
|
472
|
+
.withTypeAhead()
|
|
473
|
+
.withHomeAndEnd();
|
|
474
|
+
this._keyManager.tabOut.subscribe(() => this.closed.emit('tab'));
|
|
475
|
+
// If a user manually (programmatically) focuses a menu item, we need to reflect that focus
|
|
476
|
+
// change back to the key manager. Note that we don't need to unsubscribe here because _focused
|
|
477
|
+
// is internal, and we know that it gets completed on destroying.
|
|
478
|
+
this._directDescendantItems.changes
|
|
479
|
+
.pipe(startWith(this._directDescendantItems), switchMap(items => merge(...items.map((item) => item._focused))))
|
|
480
|
+
.subscribe(focusedItem => this._keyManager?.updateActiveItem(focusedItem));
|
|
481
|
+
this._directDescendantItems.changes.subscribe((itemsList) => {
|
|
482
|
+
// Move focus to another item if the active item is removed from the list.
|
|
483
|
+
// We need to debounce the callback because multiple items might be removed
|
|
484
|
+
// in quick succession.
|
|
485
|
+
const manager = this._keyManager;
|
|
486
|
+
if (manager && this._panelAnimationState === 'enter' && manager.activeItem?._hasFocus()) {
|
|
487
|
+
const items = itemsList.toArray();
|
|
488
|
+
const index = Math.max(0, Math.min(items.length - 1, manager.activeItemIndex || 0));
|
|
489
|
+
if (items[index] && !items[index].disabled) {
|
|
490
|
+
manager.setActiveItem(index);
|
|
491
|
+
}
|
|
492
|
+
else {
|
|
493
|
+
manager.setNextItemActive();
|
|
494
|
+
}
|
|
495
|
+
}
|
|
496
|
+
});
|
|
497
|
+
}
|
|
498
|
+
ngOnDestroy() {
|
|
499
|
+
this._keyManager?.destroy();
|
|
500
|
+
this._directDescendantItems.destroy();
|
|
501
|
+
this.closed.complete();
|
|
502
|
+
this._firstItemFocusRef?.destroy();
|
|
503
|
+
clearTimeout(this._exitFallbackTimeout);
|
|
504
|
+
}
|
|
505
|
+
/** Stream that emits whenever the hovered menu item changes. */
|
|
506
|
+
_hovered() {
|
|
507
|
+
// Coerce the `changes` property because Angular types it as `Observable<any>`
|
|
508
|
+
const itemChanges = this._directDescendantItems.changes;
|
|
509
|
+
return itemChanges.pipe(startWith(this._directDescendantItems), switchMap(items => merge(...items.map((item) => item._hovered))));
|
|
510
|
+
}
|
|
511
|
+
/** Handle a keyboard event from the menu, delegating to the appropriate action. */
|
|
512
|
+
_handleKeydown(event) {
|
|
513
|
+
const keyCode = event.keyCode;
|
|
514
|
+
const manager = this._keyManager;
|
|
515
|
+
switch (keyCode) {
|
|
516
|
+
case ESCAPE:
|
|
517
|
+
if (!hasModifierKey(event)) {
|
|
518
|
+
event.preventDefault();
|
|
519
|
+
this.closed.emit('keydown');
|
|
520
|
+
}
|
|
521
|
+
break;
|
|
522
|
+
case LEFT_ARROW:
|
|
523
|
+
if (this.parentMenu && this.direction === 'ltr') {
|
|
524
|
+
this.closed.emit('keydown');
|
|
525
|
+
}
|
|
526
|
+
break;
|
|
527
|
+
case RIGHT_ARROW:
|
|
528
|
+
if (this.parentMenu && this.direction === 'rtl') {
|
|
529
|
+
this.closed.emit('keydown');
|
|
530
|
+
}
|
|
531
|
+
break;
|
|
532
|
+
default:
|
|
533
|
+
if (keyCode === UP_ARROW || keyCode === DOWN_ARROW) {
|
|
534
|
+
manager?.setFocusOrigin('keyboard');
|
|
535
|
+
}
|
|
536
|
+
manager?.onKeydown(event);
|
|
537
|
+
return;
|
|
538
|
+
}
|
|
539
|
+
// Don't allow the event to propagate if we've already handled it, or it may
|
|
540
|
+
// end up reaching other overlays that were opened earlier (see #22694).
|
|
541
|
+
event.stopPropagation();
|
|
542
|
+
}
|
|
543
|
+
/**
|
|
544
|
+
* Handle a mouse event from the menu, delegating to the appropriate action.
|
|
545
|
+
* @param event
|
|
546
|
+
*/
|
|
547
|
+
onClick(event) {
|
|
548
|
+
// Prevent menu closing if a user clicks on a divider/separator or beyond of any menu item (margins, for example)
|
|
549
|
+
const el = event.target;
|
|
550
|
+
if (el.classList.contains("cute-menu-content") || el.role == "separator") {
|
|
551
|
+
event.preventDefault();
|
|
552
|
+
event.stopPropagation();
|
|
553
|
+
return;
|
|
554
|
+
}
|
|
555
|
+
this.closed.emit('click');
|
|
556
|
+
}
|
|
557
|
+
/**
|
|
558
|
+
* Focus the first item in the menu.
|
|
559
|
+
* @param origin Action from which the focus originated. Used to set the correct styling.
|
|
560
|
+
*/
|
|
561
|
+
focusFirstItem(origin = 'program') {
|
|
562
|
+
// Wait for `afterNextRender` to ensure iOS VoiceOver screen reader focuses the first item (#24735).
|
|
563
|
+
this._firstItemFocusRef?.destroy();
|
|
564
|
+
this._firstItemFocusRef = afterNextRender(() => {
|
|
565
|
+
const menuPanel = this._resolvePanel();
|
|
566
|
+
// If an item in the menuPanel is already focused, avoid overriding the focus.
|
|
567
|
+
if (!menuPanel || !menuPanel.contains(document.activeElement)) {
|
|
568
|
+
const manager = this._keyManager;
|
|
569
|
+
if (manager) {
|
|
570
|
+
manager.setFocusOrigin(origin).setFirstItemActive();
|
|
571
|
+
// If there's no active item at this point, it means that all the items are disabled.
|
|
572
|
+
// Move focus to the menuPanel panel so keyboard events like Escape still work. Also this will
|
|
573
|
+
// give _some_ feedback to screen readers.
|
|
574
|
+
if (!manager.activeItem && menuPanel) {
|
|
575
|
+
menuPanel.focus();
|
|
576
|
+
}
|
|
577
|
+
}
|
|
578
|
+
}
|
|
579
|
+
}, { injector: this._injector });
|
|
580
|
+
}
|
|
581
|
+
/**
|
|
582
|
+
* Resets the active item in the menu. This is used when the menu is opened, allowing
|
|
583
|
+
* the user to start from the first option when pressing the down arrow.
|
|
584
|
+
*/
|
|
585
|
+
resetActiveItem() {
|
|
586
|
+
this._keyManager?.setActiveItem(-1);
|
|
587
|
+
}
|
|
588
|
+
/**
|
|
589
|
+
* Sets the menu panel elevation.
|
|
590
|
+
* @param depth Number of parent menus that come before the menu.
|
|
591
|
+
*/
|
|
592
|
+
setElevation(depth) {
|
|
593
|
+
// The elevation starts at the base and increases by one for each level.
|
|
594
|
+
// Capped at 3 because that's the maximum elevation defined in the Bootstrap design spec.
|
|
595
|
+
const elevation = Math.min(this._baseElevation + depth, 3);
|
|
596
|
+
let suffix = "";
|
|
597
|
+
if (elevation == 0) {
|
|
598
|
+
suffix = "-none";
|
|
599
|
+
}
|
|
600
|
+
else if (elevation == 1) {
|
|
601
|
+
suffix = "-sm";
|
|
602
|
+
}
|
|
603
|
+
else if (elevation == 3) {
|
|
604
|
+
suffix = "-lg";
|
|
605
|
+
}
|
|
606
|
+
const newElevation = `${this._elevationPrefix}${suffix}`;
|
|
607
|
+
const customElevation = Object.keys(this._classList).find(className => {
|
|
608
|
+
return className.startsWith(this._elevationPrefix);
|
|
609
|
+
});
|
|
610
|
+
if (!customElevation || customElevation === this._previousElevation) {
|
|
611
|
+
if (this._previousElevation) {
|
|
612
|
+
this._classList[this._previousElevation] = false;
|
|
613
|
+
}
|
|
614
|
+
this._classList[newElevation] = true;
|
|
615
|
+
this._previousElevation = newElevation;
|
|
616
|
+
this._classList = { ...this._classList };
|
|
617
|
+
}
|
|
618
|
+
}
|
|
619
|
+
/**
|
|
620
|
+
* Adds classes to the menu panel based on its position. Can be used by
|
|
621
|
+
* consumers to add specific styling based on the position.
|
|
622
|
+
* @param posX Position of the menu along the x axis.
|
|
623
|
+
* @param posY Position of the menu along the y axis.
|
|
624
|
+
*/
|
|
625
|
+
setPositionClasses(posX = this.xPosition, posY = this.yPosition) {
|
|
626
|
+
const classes = this._classList;
|
|
627
|
+
classes['cute-menu-before'] = posX === 'before';
|
|
628
|
+
classes['cute-menu-after'] = posX === 'after';
|
|
629
|
+
classes['cute-menu-above'] = posY === 'above';
|
|
630
|
+
classes['cute-menu-below'] = posY === 'below';
|
|
631
|
+
this._changeDetectorRef.markForCheck();
|
|
632
|
+
}
|
|
633
|
+
/** Starts the entered animation. */
|
|
634
|
+
_startAnimation() {
|
|
635
|
+
// @breaking-change 8.0.0 Combine with _resetAnimation.
|
|
636
|
+
this._panelAnimationState = 'enter';
|
|
637
|
+
}
|
|
638
|
+
/** Resets the panel animation to its initial state. */
|
|
639
|
+
_resetAnimation() {
|
|
640
|
+
// @breaking-change 8.0.0 Combine with _startAnimation.
|
|
641
|
+
this._panelAnimationState = 'void';
|
|
642
|
+
}
|
|
643
|
+
/** Callback that is invoked when the panel animation completes. */
|
|
644
|
+
_onAnimationDone(event) {
|
|
645
|
+
this._animationDone.next(event);
|
|
646
|
+
this._isAnimating = false;
|
|
647
|
+
}
|
|
648
|
+
_onAnimationStart(event) {
|
|
649
|
+
this._isAnimating = true;
|
|
650
|
+
// Scroll the content element to the top as soon as the animation starts. This is necessary,
|
|
651
|
+
// because we move focus to the first item while it's still being animated, which can throw
|
|
652
|
+
// the browser off when it determines the scroll position. Alternatively, we can move focus
|
|
653
|
+
// when the animation is done, however, moving focus asynchronously will interrupt screen
|
|
654
|
+
// readers which are in the process of reading out the menu already. We take the `element`
|
|
655
|
+
// from the `event` since we can't use a `ViewChild` to access the pane.
|
|
656
|
+
if (event.toState === 'enter' && this._keyManager?.activeItemIndex === 0) {
|
|
657
|
+
event.element.scrollTop = 0;
|
|
658
|
+
}
|
|
659
|
+
}
|
|
660
|
+
/**
|
|
661
|
+
* Sets up a stream that will keep track of any newly-added menu items and will update the list
|
|
662
|
+
* of direct descendants. We collect the descendants this way, because `_allItems` can include
|
|
663
|
+
* items that are part of child menus, and using a custom way of registering items is unreliable
|
|
664
|
+
* when it comes to maintaining the item order.
|
|
665
|
+
*/
|
|
666
|
+
_updateDirectDescendants() {
|
|
667
|
+
this._allItems?.changes
|
|
668
|
+
.pipe(startWith(this._allItems))
|
|
669
|
+
.subscribe((items) => {
|
|
670
|
+
this._directDescendantItems.reset(items.filter(item => item._parentMenu === this));
|
|
671
|
+
this._directDescendantItems.notifyOnChanges();
|
|
672
|
+
});
|
|
673
|
+
}
|
|
674
|
+
/** Gets the menu panel DOM node. */
|
|
675
|
+
_resolvePanel() {
|
|
676
|
+
let menuPanel = null;
|
|
677
|
+
if (this._directDescendantItems.length) {
|
|
678
|
+
// Because the `mat-menuPanel` is at the DOM insertion point, not inside the overlay, we don't
|
|
679
|
+
// have a nice way of getting a hold of the menuPanel panel. We can't use a `ViewChild` either
|
|
680
|
+
// because the panel is inside an `ng-template`. We work around it by starting from one of
|
|
681
|
+
// the items and walking up the DOM.
|
|
682
|
+
menuPanel = this._directDescendantItems.first._getHostElement().closest('[role="menu"]');
|
|
683
|
+
}
|
|
684
|
+
return menuPanel;
|
|
685
|
+
}
|
|
686
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.15", ngImport: i0, type: CuteMenu, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
|
687
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "16.1.0", version: "20.3.15", type: CuteMenu, isStandalone: true, selector: "cute-menu", inputs: { backdropClass: "backdropClass", ariaLabel: ["aria-label", "ariaLabel"], ariaLabelledby: ["aria-labelledby", "ariaLabelledby"], ariaDescribedby: ["aria-describedby", "ariaDescribedby"], xPosition: "xPosition", yPosition: "yPosition", overlapTrigger: ["overlapTrigger", "overlapTrigger", booleanAttribute], hasBackdrop: ["hasBackdrop", "hasBackdrop", (value) => (value == null ? null : booleanAttribute(value))], panelClass: ["class", "panelClass"] }, outputs: { closed: "closed" }, host: { properties: { "attr.aria-label": "null", "attr.aria-labelledby": "null", "attr.aria-describedby": "null" }, classAttribute: "cute-menu" }, providers: [{ provide: CUTE_MENU_PANEL, useExisting: CuteMenu }], queries: [{ propertyName: "lazyContent", first: true, predicate: CUTE_MENU_CONTENT, descendants: true }, { propertyName: "_allItems", predicate: CuteMenuItem, descendants: true }, { propertyName: "items", predicate: CuteMenuItem }], viewQueries: [{ propertyName: "templateRef", first: true, predicate: TemplateRef, descendants: true }], exportAs: ["cuteMenu"], hostDirectives: [{ directive: i1.CdkMenu }], ngImport: i0, template: "<ng-template>\r\n <div\r\n class=\"cute-menu-panel\"\r\n [id]=\"panelId\"\r\n [class]=\"_classList\"\r\n (keydown)=\"_handleKeydown($event)\"\r\n (click)=\"onClick($event)\"\r\n [@transformMenu]=\"_panelAnimationState\"\r\n (@transformMenu.start)=\"_onAnimationStart($event)\"\r\n (@transformMenu.done)=\"_onAnimationDone($event)\"\r\n tabindex=\"-1\"\r\n role=\"menu\"\r\n [attr.aria-label]=\"ariaLabel || null\"\r\n [attr.aria-labelledby]=\"ariaLabelledby || null\"\r\n [attr.aria-describedby]=\"ariaDescribedby || null\">\r\n <div class=\"cute-menu-content\">\r\n <ng-content></ng-content>\r\n </div>\r\n </div>\r\n</ng-template>\r\n", styles: [".cute-menu{display:block}.cute-menu-panel{min-width:112px;max-width:280px;overflow:hidden;-webkit-overflow-scrolling:touch;box-sizing:border-box;outline:0;will-change:transform,opacity}.cute-menu-panel .cute-menu-content{display:block;width:100%;padding:.5rem 0;font-size:1rem;color:var(--bs-body-color);text-align:start;list-style:none;background-color:var(--bs-body-bg);border:var(--bs-border-width) solid var(--bs-border-color-translucent);border-radius:var(--bs-border-radius)}.cute-menu-panel .cute-menu-content [role=separator]{margin:.5rem 0!important;max-height:1px}\n"], animations: [cuteMenuAnimations.transformMenu, cuteMenuAnimations.fadeInItems], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None }); }
|
|
688
|
+
}
|
|
689
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.15", ngImport: i0, type: CuteMenu, decorators: [{
|
|
690
|
+
type: Component,
|
|
691
|
+
args: [{ selector: 'cute-menu', exportAs: 'cuteMenu', host: {
|
|
692
|
+
'class': 'cute-menu',
|
|
693
|
+
'[attr.aria-label]': 'null',
|
|
694
|
+
'[attr.aria-labelledby]': 'null',
|
|
695
|
+
'[attr.aria-describedby]': 'null',
|
|
696
|
+
}, animations: [cuteMenuAnimations.transformMenu, cuteMenuAnimations.fadeInItems], providers: [{ provide: CUTE_MENU_PANEL, useExisting: CuteMenu }], standalone: true, changeDetection: ChangeDetectionStrategy.OnPush, encapsulation: ViewEncapsulation.None, hostDirectives: [CdkMenu], template: "<ng-template>\r\n <div\r\n class=\"cute-menu-panel\"\r\n [id]=\"panelId\"\r\n [class]=\"_classList\"\r\n (keydown)=\"_handleKeydown($event)\"\r\n (click)=\"onClick($event)\"\r\n [@transformMenu]=\"_panelAnimationState\"\r\n (@transformMenu.start)=\"_onAnimationStart($event)\"\r\n (@transformMenu.done)=\"_onAnimationDone($event)\"\r\n tabindex=\"-1\"\r\n role=\"menu\"\r\n [attr.aria-label]=\"ariaLabel || null\"\r\n [attr.aria-labelledby]=\"ariaLabelledby || null\"\r\n [attr.aria-describedby]=\"ariaDescribedby || null\">\r\n <div class=\"cute-menu-content\">\r\n <ng-content></ng-content>\r\n </div>\r\n </div>\r\n</ng-template>\r\n", styles: [".cute-menu{display:block}.cute-menu-panel{min-width:112px;max-width:280px;overflow:hidden;-webkit-overflow-scrolling:touch;box-sizing:border-box;outline:0;will-change:transform,opacity}.cute-menu-panel .cute-menu-content{display:block;width:100%;padding:.5rem 0;font-size:1rem;color:var(--bs-body-color);text-align:start;list-style:none;background-color:var(--bs-body-bg);border:var(--bs-border-width) solid var(--bs-border-color-translucent);border-radius:var(--bs-border-radius)}.cute-menu-panel .cute-menu-content [role=separator]{margin:.5rem 0!important;max-height:1px}\n"] }]
|
|
697
|
+
}], ctorParameters: () => [], propDecorators: { backdropClass: [{
|
|
698
|
+
type: Input
|
|
699
|
+
}], ariaLabel: [{
|
|
700
|
+
type: Input,
|
|
701
|
+
args: ['aria-label']
|
|
702
|
+
}], ariaLabelledby: [{
|
|
703
|
+
type: Input,
|
|
704
|
+
args: ['aria-labelledby']
|
|
705
|
+
}], ariaDescribedby: [{
|
|
706
|
+
type: Input,
|
|
707
|
+
args: ['aria-describedby']
|
|
708
|
+
}], xPosition: [{
|
|
709
|
+
type: Input
|
|
710
|
+
}], yPosition: [{
|
|
711
|
+
type: Input
|
|
712
|
+
}], overlapTrigger: [{
|
|
713
|
+
type: Input,
|
|
714
|
+
args: [{ transform: booleanAttribute }]
|
|
715
|
+
}], hasBackdrop: [{
|
|
716
|
+
type: Input,
|
|
717
|
+
args: [{ transform: (value) => (value == null ? null : booleanAttribute(value)) }]
|
|
718
|
+
}], templateRef: [{
|
|
719
|
+
type: ViewChild,
|
|
720
|
+
args: [TemplateRef]
|
|
721
|
+
}], _allItems: [{
|
|
722
|
+
type: ContentChildren,
|
|
723
|
+
args: [CuteMenuItem, { descendants: true }]
|
|
724
|
+
}], items: [{
|
|
725
|
+
type: ContentChildren,
|
|
726
|
+
args: [CuteMenuItem, { descendants: false }]
|
|
727
|
+
}], lazyContent: [{
|
|
728
|
+
type: ContentChild,
|
|
729
|
+
args: [CUTE_MENU_CONTENT]
|
|
730
|
+
}], panelClass: [{
|
|
731
|
+
type: Input,
|
|
732
|
+
args: ['class']
|
|
733
|
+
}], closed: [{
|
|
734
|
+
type: Output
|
|
735
|
+
}] } });
|
|
736
|
+
|
|
737
|
+
/**
|
|
738
|
+
* @license Apache-2.0
|
|
739
|
+
*
|
|
740
|
+
* Copyright (c) 2025 CuteWidgets Team. All Rights Reserved.
|
|
741
|
+
*
|
|
742
|
+
* You may not use this file except in compliance with the License
|
|
743
|
+
* that can be found at http://www.apache.org/licenses/LICENSE-2.0
|
|
744
|
+
*
|
|
745
|
+
* This code is a modification of the `@angular/material` original
|
|
746
|
+
* code licensed under MIT-style License (https://angular.dev/license).
|
|
747
|
+
*/
|
|
748
|
+
|
|
749
|
+
/**
|
|
750
|
+
* @license Apache-2.0
|
|
751
|
+
*
|
|
752
|
+
* Copyright (c) 2025 CuteWidgets Team. All Rights Reserved.
|
|
753
|
+
*
|
|
754
|
+
* You may not use this file except in compliance with the License
|
|
755
|
+
* that can be found at http://www.apache.org/licenses/LICENSE-2.0
|
|
756
|
+
*
|
|
757
|
+
* This code is a modification of the `@angular/material` original
|
|
758
|
+
* code licensed under MIT-style License (https://angular.dev/license).
|
|
759
|
+
*/
|
|
760
|
+
/** Injection token that determines the scroll handling while the menu is open. */
|
|
761
|
+
const CUTE_MENU_SCROLL_STRATEGY = new InjectionToken('cute-menu-scroll-strategy');
|
|
762
|
+
/** @docs-private */
|
|
763
|
+
function CUTE_MENU_SCROLL_STRATEGY_FACTORY(overlay) {
|
|
764
|
+
return () => overlay.scrollStrategies.reposition();
|
|
765
|
+
}
|
|
766
|
+
/** @docs-private */
|
|
767
|
+
const CUTE_MENU_SCROLL_STRATEGY_FACTORY_PROVIDER = {
|
|
768
|
+
provide: CUTE_MENU_SCROLL_STRATEGY,
|
|
769
|
+
deps: [Overlay],
|
|
770
|
+
useFactory: CUTE_MENU_SCROLL_STRATEGY_FACTORY,
|
|
771
|
+
};
|
|
772
|
+
/** Options for binding a passive event listener. */
|
|
773
|
+
const passiveEventListenerOptions = normalizePassiveListenerOptions({ passive: true });
|
|
774
|
+
/** Directive applied to an element that should trigger a `cute-menu`. */
|
|
775
|
+
class CuteMenuTrigger {
|
|
776
|
+
/** References the menu instance that the trigger is associated with. */
|
|
777
|
+
get menu() { return this._menu; }
|
|
778
|
+
set menu(menu) {
|
|
779
|
+
if (menu === this._menu) {
|
|
780
|
+
return;
|
|
781
|
+
}
|
|
782
|
+
this._menu = menu;
|
|
783
|
+
this._menuCloseSubscription.unsubscribe();
|
|
784
|
+
if (menu) {
|
|
785
|
+
if (menu === this._parentCuteMenu && isDevMode()) {
|
|
786
|
+
throwCuteMenuRecursiveError();
|
|
787
|
+
}
|
|
788
|
+
this._menuCloseSubscription = menu.closed.subscribe((reason) => {
|
|
789
|
+
this._destroyMenu(reason);
|
|
790
|
+
// If a click closed the menu, we should close the entire chain of nested menus.
|
|
791
|
+
if ((reason === 'click' || reason === 'tab') && this._parentCuteMenu) {
|
|
792
|
+
this._parentCuteMenu.closed.emit(reason);
|
|
793
|
+
}
|
|
794
|
+
});
|
|
795
|
+
}
|
|
796
|
+
this._menuItemInstance?._setTriggersSubmenu(this.triggersSubmenu());
|
|
797
|
+
}
|
|
798
|
+
constructor(_overlay, _element, _viewContainerRef, scrollStrategy, parentMenu,
|
|
799
|
+
// `CuteMenuTrigger` is commonly used in combination with a `CuteMenuItem`.
|
|
800
|
+
// tslint:disable-next-line: lightweight-tokens
|
|
801
|
+
_menuItemInstance, _dir, _focusMonitor, _ngZone) {
|
|
802
|
+
this._overlay = _overlay;
|
|
803
|
+
this._element = _element;
|
|
804
|
+
this._viewContainerRef = _viewContainerRef;
|
|
805
|
+
this._menuItemInstance = _menuItemInstance;
|
|
806
|
+
this._dir = _dir;
|
|
807
|
+
this._focusMonitor = _focusMonitor;
|
|
808
|
+
this._ngZone = _ngZone;
|
|
809
|
+
this._portal = null;
|
|
810
|
+
this._overlayRef = null;
|
|
811
|
+
this._menuOpen = false;
|
|
812
|
+
this._closingActionsSubscription = Subscription.EMPTY;
|
|
813
|
+
this._hoverSubscription = Subscription.EMPTY;
|
|
814
|
+
this._menuCloseSubscription = Subscription.EMPTY;
|
|
815
|
+
this._changeDetectorRef = inject(ChangeDetectorRef);
|
|
816
|
+
/**
|
|
817
|
+
* Handles touch start events on the trigger.
|
|
818
|
+
* Needs to be an arrow function, so we can easily use addEventListener and removeEventListener.
|
|
819
|
+
*/
|
|
820
|
+
this._handleTouchStart = (event) => {
|
|
821
|
+
if (!isFakeTouchstartFromScreenReader(event)) {
|
|
822
|
+
this._openedBy = 'touch';
|
|
823
|
+
}
|
|
824
|
+
};
|
|
825
|
+
// Tracking input type is necessary, so it's possible to only autofocus
|
|
826
|
+
// the first item of the list when the menu is opened via the keyboard
|
|
827
|
+
this._openedBy = undefined;
|
|
828
|
+
this._menu = null;
|
|
829
|
+
/**
|
|
830
|
+
* Whether focus should be restored when the menu is closed.
|
|
831
|
+
* Note that disabling this option can have accessibility implications, and
|
|
832
|
+
* it's up to you to manage focus if you decide to turn it off.
|
|
833
|
+
*/
|
|
834
|
+
this.restoreFocus = true;
|
|
835
|
+
/** Event emitted when the associated menu is opened. */
|
|
836
|
+
this.menuOpened = new EventEmitter();
|
|
837
|
+
/** Event emitted when the associated menu is closed. */
|
|
838
|
+
this.menuClosed = new EventEmitter();
|
|
839
|
+
this._scrollStrategy = scrollStrategy;
|
|
840
|
+
this._parentCuteMenu = parentMenu instanceof CuteMenu ? parentMenu : undefined;
|
|
841
|
+
_element.nativeElement.addEventListener('touchstart', this._handleTouchStart, passiveEventListenerOptions);
|
|
842
|
+
}
|
|
843
|
+
ngAfterContentInit() {
|
|
844
|
+
this._handleHover();
|
|
845
|
+
}
|
|
846
|
+
ngOnDestroy() {
|
|
847
|
+
if (this._overlayRef) {
|
|
848
|
+
this._overlayRef.dispose();
|
|
849
|
+
this._overlayRef = null;
|
|
850
|
+
}
|
|
851
|
+
this._element.nativeElement.removeEventListener('touchstart', this._handleTouchStart, passiveEventListenerOptions);
|
|
852
|
+
this._menuCloseSubscription.unsubscribe();
|
|
853
|
+
this._closingActionsSubscription.unsubscribe();
|
|
854
|
+
this._hoverSubscription.unsubscribe();
|
|
855
|
+
}
|
|
856
|
+
/** Whether the menu is open. */
|
|
857
|
+
get menuOpen() {
|
|
858
|
+
return this._menuOpen;
|
|
859
|
+
}
|
|
860
|
+
/** The text direction of the containing app. */
|
|
861
|
+
get dir() {
|
|
862
|
+
return this._dir && this._dir.value === 'rtl' ? 'rtl' : 'ltr';
|
|
863
|
+
}
|
|
864
|
+
get elementRef() {
|
|
865
|
+
return this._element;
|
|
866
|
+
}
|
|
867
|
+
/** Whether the menu triggers a submenu or a top-level one. */
|
|
868
|
+
triggersSubmenu() {
|
|
869
|
+
return !!(this._menuItemInstance && this._parentCuteMenu && this.menu);
|
|
870
|
+
}
|
|
871
|
+
/** Toggles the menu between the open and closed states. */
|
|
872
|
+
toggleMenu() {
|
|
873
|
+
return this._menuOpen ? this.closeMenu() : this.openMenu();
|
|
874
|
+
}
|
|
875
|
+
/** Opens the menu. */
|
|
876
|
+
openMenu() {
|
|
877
|
+
const menu = this.menu;
|
|
878
|
+
if (this._menuOpen || !menu) {
|
|
879
|
+
return;
|
|
880
|
+
}
|
|
881
|
+
const overlayRef = this._createOverlay(menu);
|
|
882
|
+
const overlayConfig = overlayRef.getConfig();
|
|
883
|
+
const positionStrategy = overlayConfig.positionStrategy;
|
|
884
|
+
this._setPosition(menu, positionStrategy);
|
|
885
|
+
overlayConfig.hasBackdrop =
|
|
886
|
+
menu.hasBackdrop == null ? !this.triggersSubmenu() : menu.hasBackdrop;
|
|
887
|
+
overlayRef.attach(this._getPortal(menu));
|
|
888
|
+
if (menu.lazyContent) {
|
|
889
|
+
menu.lazyContent.attach(this.menuData);
|
|
890
|
+
}
|
|
891
|
+
this._closingActionsSubscription = this._menuClosingActions().subscribe(() => this.closeMenu());
|
|
892
|
+
this._initMenu(menu);
|
|
893
|
+
if (menu instanceof CuteMenu) {
|
|
894
|
+
menu._startAnimation();
|
|
895
|
+
menu._directDescendantItems.changes.pipe(takeUntil(menu.closed)).subscribe(() => {
|
|
896
|
+
// Re-adjust the position without locking when the number of items
|
|
897
|
+
// changes so that the overlay is allowed to pick a new optimal position.
|
|
898
|
+
positionStrategy.withLockedPosition(false).reapplyLastPosition();
|
|
899
|
+
positionStrategy.withLockedPosition(true);
|
|
900
|
+
});
|
|
901
|
+
}
|
|
902
|
+
}
|
|
903
|
+
/** Closes the menu. */
|
|
904
|
+
closeMenu() {
|
|
905
|
+
this.menu?.closed.emit();
|
|
906
|
+
}
|
|
907
|
+
/**
|
|
908
|
+
* Focuses the menu trigger.
|
|
909
|
+
* @param origin Source of the menu trigger's focus.
|
|
910
|
+
* @param options Focus options
|
|
911
|
+
*/
|
|
912
|
+
focus(origin, options) {
|
|
913
|
+
if (this._focusMonitor && origin) {
|
|
914
|
+
this._focusMonitor.focusVia(this._element, origin, options);
|
|
915
|
+
}
|
|
916
|
+
else {
|
|
917
|
+
this._element.nativeElement.focus(options);
|
|
918
|
+
}
|
|
919
|
+
}
|
|
920
|
+
/**
|
|
921
|
+
* Updates the position of the menu to ensure that it fits all options within the viewport.
|
|
922
|
+
*/
|
|
923
|
+
updatePosition() {
|
|
924
|
+
this._overlayRef?.updatePosition();
|
|
925
|
+
}
|
|
926
|
+
/** Closes the menu and does the necessary cleanup. */
|
|
927
|
+
_destroyMenu(reason) {
|
|
928
|
+
if (!this._overlayRef || !this.menuOpen) {
|
|
929
|
+
return;
|
|
930
|
+
}
|
|
931
|
+
const menu = this.menu;
|
|
932
|
+
this._closingActionsSubscription.unsubscribe();
|
|
933
|
+
this._overlayRef.detach();
|
|
934
|
+
// Always restore focus if the user is navigating using the keyboard or the menu was opened
|
|
935
|
+
// programmatically. We don't restore for non-root triggers, because it can prevent focus
|
|
936
|
+
// from making it back to the root trigger when closing a long chain of menus by clicking
|
|
937
|
+
// on the backdrop.
|
|
938
|
+
if (this.restoreFocus && (reason === 'keydown' || !this._openedBy || !this.triggersSubmenu())) {
|
|
939
|
+
this.focus(this._openedBy);
|
|
940
|
+
}
|
|
941
|
+
this._openedBy = undefined;
|
|
942
|
+
if (menu instanceof CuteMenu) {
|
|
943
|
+
menu._resetAnimation();
|
|
944
|
+
if (menu.lazyContent) {
|
|
945
|
+
// Wait for the exit animation to finish before detaching the content.
|
|
946
|
+
menu._animationDone
|
|
947
|
+
.pipe(filter(event => event.toState === 'void'), take(1),
|
|
948
|
+
// Interrupt if the content got re-attached.
|
|
949
|
+
takeUntil(menu.lazyContent._attached))
|
|
950
|
+
.subscribe({
|
|
951
|
+
next: () => menu.lazyContent.detach(),
|
|
952
|
+
// No matter whether the content got re-attached, reset the menu.
|
|
953
|
+
complete: () => this._setIsMenuOpen(false),
|
|
954
|
+
});
|
|
955
|
+
}
|
|
956
|
+
else {
|
|
957
|
+
this._setIsMenuOpen(false);
|
|
958
|
+
}
|
|
959
|
+
}
|
|
960
|
+
else {
|
|
961
|
+
this._setIsMenuOpen(false);
|
|
962
|
+
menu?.lazyContent?.detach();
|
|
963
|
+
}
|
|
964
|
+
}
|
|
965
|
+
/**
|
|
966
|
+
* This method sets the menu state to open and focuses the first item if
|
|
967
|
+
* the menu was opened via the keyboard.
|
|
968
|
+
*/
|
|
969
|
+
_initMenu(menu) {
|
|
970
|
+
menu.parentMenu = this.triggersSubmenu() ? this._parentCuteMenu : undefined;
|
|
971
|
+
menu.direction = this.dir;
|
|
972
|
+
this._setMenuElevation(menu);
|
|
973
|
+
menu.focusFirstItem(this._openedBy || 'program');
|
|
974
|
+
this._setIsMenuOpen(true);
|
|
975
|
+
}
|
|
976
|
+
/** Updates the menu elevation based on the amount of parent menus that it has. */
|
|
977
|
+
_setMenuElevation(menu) {
|
|
978
|
+
if (menu.setElevation) {
|
|
979
|
+
let depth = 0;
|
|
980
|
+
let parentMenu = menu.parentMenu;
|
|
981
|
+
while (parentMenu) {
|
|
982
|
+
depth++;
|
|
983
|
+
parentMenu = parentMenu.parentMenu;
|
|
984
|
+
}
|
|
985
|
+
menu.setElevation(depth);
|
|
986
|
+
}
|
|
987
|
+
}
|
|
988
|
+
// set state rather than toggle to support triggers sharing a menu
|
|
989
|
+
_setIsMenuOpen(isOpen) {
|
|
990
|
+
if (isOpen !== this._menuOpen) {
|
|
991
|
+
this._menuOpen = isOpen;
|
|
992
|
+
this._menuOpen ? this.menuOpened.emit() : this.menuClosed.emit();
|
|
993
|
+
if (this.triggersSubmenu()) {
|
|
994
|
+
this._menuItemInstance._setHighlighted(isOpen);
|
|
995
|
+
}
|
|
996
|
+
this._changeDetectorRef.markForCheck();
|
|
997
|
+
}
|
|
998
|
+
}
|
|
999
|
+
/**
|
|
1000
|
+
* This method creates the overlay from the provided menu's template and saves its
|
|
1001
|
+
* OverlayRef so that it can be attached to the DOM when openMenu is called.
|
|
1002
|
+
*/
|
|
1003
|
+
_createOverlay(menu) {
|
|
1004
|
+
if (!this._overlayRef) {
|
|
1005
|
+
const config = this._getOverlayConfig(menu);
|
|
1006
|
+
this._subscribeToPositions(menu, config.positionStrategy);
|
|
1007
|
+
this._overlayRef = this._overlay.create(config);
|
|
1008
|
+
// Consume the `keydownEvents` in order to prevent them from going to another overlay.
|
|
1009
|
+
// Ideally we'd also have our keyboard event logic in here, however doing so will
|
|
1010
|
+
// break anybody that may have implemented the `CuteMenuPanel` themselves.
|
|
1011
|
+
this._overlayRef.keydownEvents().subscribe();
|
|
1012
|
+
}
|
|
1013
|
+
return this._overlayRef;
|
|
1014
|
+
}
|
|
1015
|
+
/**
|
|
1016
|
+
* This method builds the configuration object needed to create the overlay, the OverlayState.
|
|
1017
|
+
* @returns OverlayConfig
|
|
1018
|
+
*/
|
|
1019
|
+
_getOverlayConfig(menu) {
|
|
1020
|
+
return new OverlayConfig({
|
|
1021
|
+
positionStrategy: this._overlay
|
|
1022
|
+
.position()
|
|
1023
|
+
.flexibleConnectedTo(this._element)
|
|
1024
|
+
.withLockedPosition()
|
|
1025
|
+
.withGrowAfterOpen()
|
|
1026
|
+
.withTransformOriginOn('.cute-menu-panel'),
|
|
1027
|
+
backdropClass: menu.backdropClass || 'cdk-overlay-transparent-backdrop',
|
|
1028
|
+
panelClass: menu.overlayPanelClass,
|
|
1029
|
+
scrollStrategy: this._scrollStrategy(),
|
|
1030
|
+
direction: this._dir,
|
|
1031
|
+
});
|
|
1032
|
+
}
|
|
1033
|
+
/**
|
|
1034
|
+
* Listens to changes in the position of the overlay and sets the correct classes
|
|
1035
|
+
* on the menu based on the new position. This ensures the animation origin is always
|
|
1036
|
+
* correct, even if a fallback position is used for the overlay.
|
|
1037
|
+
*/
|
|
1038
|
+
_subscribeToPositions(menu, position) {
|
|
1039
|
+
if (menu.setPositionClasses) {
|
|
1040
|
+
position.positionChanges.subscribe(change => {
|
|
1041
|
+
const posX = change.connectionPair.overlayX === 'start' ? 'after' : 'before';
|
|
1042
|
+
const posY = change.connectionPair.overlayY === 'top' ? 'below' : 'above';
|
|
1043
|
+
// @breaking-change 15.0.0 Remove null check for `ngZone`.
|
|
1044
|
+
// `positionChanges` fires outside of the `ngZone` and `setPositionClasses` might be
|
|
1045
|
+
// updating something in the view, so we need to bring it back in.
|
|
1046
|
+
if (this._ngZone) {
|
|
1047
|
+
this._ngZone.run(() => menu.setPositionClasses(posX, posY));
|
|
1048
|
+
}
|
|
1049
|
+
else {
|
|
1050
|
+
menu.setPositionClasses(posX, posY);
|
|
1051
|
+
}
|
|
1052
|
+
});
|
|
1053
|
+
}
|
|
1054
|
+
}
|
|
1055
|
+
/**
|
|
1056
|
+
* Sets the appropriate positions on a position strategy
|
|
1057
|
+
* so the overlay connects with the trigger correctly.
|
|
1058
|
+
* @param menu Menu panel
|
|
1059
|
+
* @param positionStrategy Strategy whose position is to update.
|
|
1060
|
+
*/
|
|
1061
|
+
_setPosition(menu, positionStrategy) {
|
|
1062
|
+
let [originX, originFallbackX] = menu.xPosition === 'before' ? ['end', 'start'] : ['start', 'end'];
|
|
1063
|
+
let [overlayY, overlayFallbackY] = menu.yPosition === 'above' ? ['bottom', 'top'] : ['top', 'bottom'];
|
|
1064
|
+
let [originY, originFallbackY] = [overlayY, overlayFallbackY];
|
|
1065
|
+
let [overlayX, overlayFallbackX] = [originX, originFallbackX];
|
|
1066
|
+
let offsetY = 0;
|
|
1067
|
+
if (this.triggersSubmenu()) {
|
|
1068
|
+
// When the menu is a submenu, it should always align itself
|
|
1069
|
+
// to the edges of the trigger, instead of overlapping it.
|
|
1070
|
+
overlayFallbackX = originX = menu.xPosition === 'before' ? 'start' : 'end';
|
|
1071
|
+
originFallbackX = overlayX = originX === 'end' ? 'start' : 'end';
|
|
1072
|
+
if (this._parentCuteMenu) {
|
|
1073
|
+
if (this._parentInnerPadding == null) {
|
|
1074
|
+
const firstItem = this._parentCuteMenu.items?.first;
|
|
1075
|
+
this._parentInnerPadding = firstItem ? firstItem._getHostElement().offsetTop : 0;
|
|
1076
|
+
}
|
|
1077
|
+
offsetY = overlayY === 'bottom' ? this._parentInnerPadding : -this._parentInnerPadding;
|
|
1078
|
+
}
|
|
1079
|
+
}
|
|
1080
|
+
else if (!menu.overlapTrigger) {
|
|
1081
|
+
offsetY = 4;
|
|
1082
|
+
originY = overlayY === 'top' ? 'bottom' : 'top';
|
|
1083
|
+
originFallbackY = overlayFallbackY === 'top' ? 'bottom' : 'top';
|
|
1084
|
+
}
|
|
1085
|
+
positionStrategy.withPositions([
|
|
1086
|
+
{ originX, originY, overlayX, overlayY, offsetY },
|
|
1087
|
+
{ originX: originFallbackX, originY, overlayX: overlayFallbackX, overlayY, offsetY },
|
|
1088
|
+
{
|
|
1089
|
+
originX,
|
|
1090
|
+
originY: originFallbackY,
|
|
1091
|
+
overlayX,
|
|
1092
|
+
overlayY: overlayFallbackY,
|
|
1093
|
+
offsetY: -offsetY,
|
|
1094
|
+
},
|
|
1095
|
+
{
|
|
1096
|
+
originX: originFallbackX,
|
|
1097
|
+
originY: originFallbackY,
|
|
1098
|
+
overlayX: overlayFallbackX,
|
|
1099
|
+
overlayY: overlayFallbackY,
|
|
1100
|
+
offsetY: -offsetY,
|
|
1101
|
+
},
|
|
1102
|
+
]);
|
|
1103
|
+
}
|
|
1104
|
+
/** Returns a stream that emits whenever an action that should close the menu occurs. */
|
|
1105
|
+
_menuClosingActions() {
|
|
1106
|
+
const backdrop = this._overlayRef.backdropClick();
|
|
1107
|
+
const detachments = this._overlayRef.detachments();
|
|
1108
|
+
const parentClose = this._parentCuteMenu ? this._parentCuteMenu.closed : of();
|
|
1109
|
+
const hover = this._parentCuteMenu
|
|
1110
|
+
? this._parentCuteMenu._hovered().pipe(filter(active => active !== this._menuItemInstance), filter(() => this._menuOpen))
|
|
1111
|
+
: of();
|
|
1112
|
+
return merge(backdrop, parentClose, hover, detachments);
|
|
1113
|
+
}
|
|
1114
|
+
/** Handles mouse presses on the trigger. */
|
|
1115
|
+
_handleMousedown(event) {
|
|
1116
|
+
if (!isFakeMousedownFromScreenReader(event)) {
|
|
1117
|
+
// Since right or middle button clicks won't trigger the `click` event,
|
|
1118
|
+
// we shouldn't consider the menu as opened by mouse in those cases.
|
|
1119
|
+
this._openedBy = event.button === 0 ? 'mouse' : undefined;
|
|
1120
|
+
// Since clicking on the trigger won't close the menu if it opens a submenu,
|
|
1121
|
+
// we should prevent focus from moving onto it via click to avoid the
|
|
1122
|
+
// highlight from lingering on the menu item.
|
|
1123
|
+
if (this.triggersSubmenu()) {
|
|
1124
|
+
event.preventDefault();
|
|
1125
|
+
}
|
|
1126
|
+
}
|
|
1127
|
+
}
|
|
1128
|
+
/** Handles key presses on the trigger. */
|
|
1129
|
+
_handleKeydown(event) {
|
|
1130
|
+
const keyCode = event.keyCode;
|
|
1131
|
+
// Pressing enter on the trigger will trigger the click handler later.
|
|
1132
|
+
if (keyCode === ENTER || keyCode === SPACE) {
|
|
1133
|
+
this._openedBy = 'keyboard';
|
|
1134
|
+
}
|
|
1135
|
+
if (this.triggersSubmenu() &&
|
|
1136
|
+
((keyCode === RIGHT_ARROW && this.dir === 'ltr') ||
|
|
1137
|
+
(keyCode === LEFT_ARROW && this.dir === 'rtl'))) {
|
|
1138
|
+
this._openedBy = 'keyboard';
|
|
1139
|
+
this.openMenu();
|
|
1140
|
+
}
|
|
1141
|
+
}
|
|
1142
|
+
/** Handles click events on the trigger. */
|
|
1143
|
+
_handleClick(event) {
|
|
1144
|
+
if (this.triggersSubmenu()) {
|
|
1145
|
+
// Stop event propagation to avoid closing the parent menu.
|
|
1146
|
+
event.stopPropagation();
|
|
1147
|
+
this.openMenu();
|
|
1148
|
+
}
|
|
1149
|
+
else {
|
|
1150
|
+
this.toggleMenu();
|
|
1151
|
+
}
|
|
1152
|
+
}
|
|
1153
|
+
/** Handles the cases where the user hovers over the trigger. */
|
|
1154
|
+
_handleHover() {
|
|
1155
|
+
// Subscribe to changes in the hovered item in order to toggle the panel.
|
|
1156
|
+
if (!this.triggersSubmenu() || !this._parentCuteMenu) {
|
|
1157
|
+
return;
|
|
1158
|
+
}
|
|
1159
|
+
this._hoverSubscription = this._parentCuteMenu
|
|
1160
|
+
._hovered()
|
|
1161
|
+
// Since we might have multiple competing triggers for the same menu (e.g. a sub-menu
|
|
1162
|
+
// with different data and triggers), we have to delay it by a tick to ensure that
|
|
1163
|
+
// it won't be closed immediately after it is opened.
|
|
1164
|
+
.pipe(filter(active => active === this._menuItemInstance && !active.disabled), delay(0, asapScheduler))
|
|
1165
|
+
.subscribe(() => {
|
|
1166
|
+
this._openedBy = 'mouse';
|
|
1167
|
+
// If the same menu is used between multiple triggers, it might still be animating
|
|
1168
|
+
// while the new trigger tries to re-open it. Wait for the animation to finish
|
|
1169
|
+
// before doing so. Also interrupt if the user moves to another item.
|
|
1170
|
+
if (this.menu instanceof CuteMenu && this.menu._isAnimating) {
|
|
1171
|
+
// We need the `delay(0)` here in order to avoid
|
|
1172
|
+
// 'changed after checked' errors in some cases. See #12194.
|
|
1173
|
+
this.menu._animationDone
|
|
1174
|
+
.pipe(take(1), delay(0, asapScheduler), takeUntil(this._parentCuteMenu._hovered()))
|
|
1175
|
+
.subscribe(() => this.openMenu());
|
|
1176
|
+
}
|
|
1177
|
+
else {
|
|
1178
|
+
this.openMenu();
|
|
1179
|
+
}
|
|
1180
|
+
});
|
|
1181
|
+
}
|
|
1182
|
+
/** Gets the portal that should be attached to the overlay. */
|
|
1183
|
+
_getPortal(menu) {
|
|
1184
|
+
// Note that we can avoid this check by keeping the portal on the menu panel.
|
|
1185
|
+
// While it would be cleaner, we'd have to introduce another required method on
|
|
1186
|
+
// `CuteMenuPanel`, making it harder to consume.
|
|
1187
|
+
if (!this._portal || this._portal.templateRef !== menu.templateRef) {
|
|
1188
|
+
this._portal = new TemplatePortal(menu.templateRef, this._viewContainerRef);
|
|
1189
|
+
}
|
|
1190
|
+
return this._portal;
|
|
1191
|
+
}
|
|
1192
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.15", ngImport: i0, type: CuteMenuTrigger, deps: [{ token: i1$1.Overlay }, { token: i0.ElementRef }, { token: i0.ViewContainerRef }, { token: CUTE_MENU_SCROLL_STRATEGY }, { token: CUTE_MENU_PANEL, optional: true }, { token: CuteMenuItem, optional: true, self: true }, { token: i3.Directionality, optional: true }, { token: i4.FocusMonitor }, { token: i0.NgZone }], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
1193
|
+
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "20.3.15", type: CuteMenuTrigger, isStandalone: true, selector: "[cuteMenuTriggerFor]", inputs: { menu: ["cuteMenuTriggerFor", "menu"], menuData: ["cuteMenuTriggerData", "menuData"], restoreFocus: ["cuteMenuTriggerRestoreFocus", "restoreFocus"] }, outputs: { menuOpened: "menuOpened", menuClosed: "menuClosed" }, host: { listeners: { "click": "_handleClick($event)", "mousedown": "_handleMousedown($event)", "keydown": "_handleKeydown($event)" }, properties: { "attr.aria-haspopup": "menu ? \"menu\" : null", "attr.aria-expanded": "menuOpen", "attr.aria-controls": "menuOpen ? menu.panelId : null" }, classAttribute: "cute-menu-trigger" }, exportAs: ["cuteMenuTrigger"], ngImport: i0 }); }
|
|
1194
|
+
}
|
|
1195
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.15", ngImport: i0, type: CuteMenuTrigger, decorators: [{
|
|
1196
|
+
type: Directive,
|
|
1197
|
+
args: [{
|
|
1198
|
+
selector: `[cuteMenuTriggerFor]`,
|
|
1199
|
+
exportAs: 'cuteMenuTrigger',
|
|
1200
|
+
host: {
|
|
1201
|
+
'class': 'cute-menu-trigger',
|
|
1202
|
+
'[attr.aria-haspopup]': 'menu ? "menu" : null',
|
|
1203
|
+
'[attr.aria-expanded]': 'menuOpen',
|
|
1204
|
+
'[attr.aria-controls]': 'menuOpen ? menu.panelId : null',
|
|
1205
|
+
'(click)': '_handleClick($event)',
|
|
1206
|
+
'(mousedown)': '_handleMousedown($event)',
|
|
1207
|
+
'(keydown)': '_handleKeydown($event)',
|
|
1208
|
+
},
|
|
1209
|
+
standalone: true,
|
|
1210
|
+
}]
|
|
1211
|
+
}], ctorParameters: () => [{ type: i1$1.Overlay }, { type: i0.ElementRef }, { type: i0.ViewContainerRef }, { type: undefined, decorators: [{
|
|
1212
|
+
type: Inject,
|
|
1213
|
+
args: [CUTE_MENU_SCROLL_STRATEGY]
|
|
1214
|
+
}] }, { type: undefined, decorators: [{
|
|
1215
|
+
type: Inject,
|
|
1216
|
+
args: [CUTE_MENU_PANEL]
|
|
1217
|
+
}, {
|
|
1218
|
+
type: Optional
|
|
1219
|
+
}] }, { type: CuteMenuItem, decorators: [{
|
|
1220
|
+
type: Optional
|
|
1221
|
+
}, {
|
|
1222
|
+
type: Self
|
|
1223
|
+
}] }, { type: i3.Directionality, decorators: [{
|
|
1224
|
+
type: Optional
|
|
1225
|
+
}] }, { type: i4.FocusMonitor }, { type: i0.NgZone }], propDecorators: { menu: [{
|
|
1226
|
+
type: Input,
|
|
1227
|
+
args: ['cuteMenuTriggerFor']
|
|
1228
|
+
}], menuData: [{
|
|
1229
|
+
type: Input,
|
|
1230
|
+
args: ['cuteMenuTriggerData']
|
|
1231
|
+
}], restoreFocus: [{
|
|
1232
|
+
type: Input,
|
|
1233
|
+
args: ['cuteMenuTriggerRestoreFocus']
|
|
1234
|
+
}], menuOpened: [{
|
|
1235
|
+
type: Output
|
|
1236
|
+
}], menuClosed: [{
|
|
1237
|
+
type: Output
|
|
1238
|
+
}] } });
|
|
1239
|
+
|
|
1240
|
+
/**
|
|
1241
|
+
* @license Apache-2.0
|
|
1242
|
+
*
|
|
1243
|
+
* Copyright (c) 2025 CuteWidgets Team. All Rights Reserved.
|
|
1244
|
+
*
|
|
1245
|
+
* You may not use this file except in compliance with the License
|
|
1246
|
+
* that can be found at http://www.apache.org/licenses/LICENSE-2.0
|
|
1247
|
+
*/
|
|
1248
|
+
const TYPES = [
|
|
1249
|
+
CommonModule,
|
|
1250
|
+
CuteMenu,
|
|
1251
|
+
CuteMenuItem,
|
|
1252
|
+
CuteMenuContent,
|
|
1253
|
+
CuteMenuTrigger,
|
|
1254
|
+
];
|
|
1255
|
+
class CuteMenuModule {
|
|
1256
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.15", ngImport: i0, type: CuteMenuModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
|
|
1257
|
+
static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "20.3.15", ngImport: i0, type: CuteMenuModule, imports: [CommonModule, CommonModule,
|
|
1258
|
+
CuteMenu,
|
|
1259
|
+
CuteMenuItem,
|
|
1260
|
+
CuteMenuContent,
|
|
1261
|
+
CuteMenuTrigger], exports: [CommonModule,
|
|
1262
|
+
CuteMenu,
|
|
1263
|
+
CuteMenuItem,
|
|
1264
|
+
CuteMenuContent,
|
|
1265
|
+
CuteMenuTrigger] }); }
|
|
1266
|
+
static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "20.3.15", ngImport: i0, type: CuteMenuModule, providers: [CUTE_MENU_SCROLL_STRATEGY_FACTORY_PROVIDER], imports: [CommonModule, CommonModule, CommonModule] }); }
|
|
1267
|
+
}
|
|
1268
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.15", ngImport: i0, type: CuteMenuModule, decorators: [{
|
|
1269
|
+
type: NgModule,
|
|
1270
|
+
args: [{
|
|
1271
|
+
imports: [CommonModule, ...TYPES],
|
|
1272
|
+
exports: TYPES,
|
|
1273
|
+
declarations: [],
|
|
1274
|
+
providers: [CUTE_MENU_SCROLL_STRATEGY_FACTORY_PROVIDER],
|
|
1275
|
+
}]
|
|
1276
|
+
}] });
|
|
1277
|
+
|
|
1278
|
+
/**
|
|
1279
|
+
* Generated bundle index. Do not edit.
|
|
1280
|
+
*/
|
|
1281
|
+
|
|
1282
|
+
export { CUTE_MENU_CONTENT, CUTE_MENU_DEFAULT_OPTIONS, CUTE_MENU_DEFAULT_OPTIONS_FACTORY, CUTE_MENU_SCROLL_STRATEGY, CUTE_MENU_SCROLL_STRATEGY_FACTORY, CUTE_MENU_SCROLL_STRATEGY_FACTORY_PROVIDER, CuteMenu, CuteMenuContent, CuteMenuItem, CuteMenuModule, CuteMenuTrigger };
|
|
1283
|
+
//# sourceMappingURL=cute-widgets-base-menu.mjs.map
|