@ngrdt/menu 0.0.11 → 0.0.14

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.
@@ -5,7 +5,7 @@ import { RdtShortcut, RdtShortcutService } from '@ngrdt/shortcuts';
5
5
  import { RdtHorizontalDirection, RdtVerticalDirection } from '@ngrdt/utils';
6
6
  import { Subscription } from 'rxjs';
7
7
  import { RdtMenuOverlayComponent } from '../menu-overlay/rdt-menu-overlay.component';
8
- import { ParsedRdtMenuItem } from '../private-models';
8
+ import { ParsedRdtMenuItem, RdtMenuExpandedChild, RdtMenuExpandSource } from '../private-models';
9
9
  import { ParsedRdtMenuItemWithShortcut, Size } from '../utils';
10
10
  import * as i0 from "@angular/core";
11
11
  export declare abstract class RdtMenuBaseComponent implements OnInit, OnChanges, AfterViewInit {
@@ -14,6 +14,7 @@ export declare abstract class RdtMenuBaseComponent implements OnInit, OnChanges,
14
14
  shortcutMode: 'focus-item' | 'open-submenu';
15
15
  closeOnFocusOut: boolean;
16
16
  openOnHover: boolean;
17
+ hitboxMargin: number;
17
18
  readonly cd: ChangeDetectorRef;
18
19
  readonly destroyRef: DestroyRef;
19
20
  protected readonly rdtRouter: RdtRouterService;
@@ -25,8 +26,9 @@ export declare abstract class RdtMenuBaseComponent implements OnInit, OnChanges,
25
26
  protected readonly injector: EnvironmentInjector;
26
27
  protected children: QueryList<RdtMenuOverlayComponent>;
27
28
  protected focusableElements: QueryList<ElementRef<HTMLElement>>;
29
+ abstract get buttonContainer(): HTMLElement | undefined;
28
30
  classes: string;
29
- protected expanded: ParsedRdtMenuItem | null;
31
+ expandedChild: RdtMenuExpandedChild | null;
30
32
  protected autofocusSubmenuItem: 'first' | 'last' | null;
31
33
  protected parsedItems: ParsedRdtMenuItem[];
32
34
  get clientSize(): Size;
@@ -38,6 +40,8 @@ export declare abstract class RdtMenuBaseComponent implements OnInit, OnChanges,
38
40
  right: number;
39
41
  };
40
42
  private _bodyMargin;
43
+ get buttonContainerRect(): DOMRect | undefined;
44
+ private _buttonContainerRect?;
41
45
  protected allParsedItems: ParsedRdtMenuItem[];
42
46
  protected childRoutesMap: Map<ParsedRdtMenuItem, string[][]>;
43
47
  protected shortcutSub: Subscription;
@@ -53,7 +57,6 @@ export declare abstract class RdtMenuBaseComponent implements OnInit, OnChanges,
53
57
  closeSubmenus(focusExpanded?: boolean): void;
54
58
  protected onItemClick(item: ParsedRdtMenuItem): void;
55
59
  protected onItemPointerEnter(item: ParsedRdtMenuItem): void;
56
- protected onItemPointerLeave(item: ParsedRdtMenuItem): void;
57
60
  protected onKeyDown(itemIndex: number, event: KeyboardEvent): void;
58
61
  protected invokeItemClick(item: ParsedRdtMenuItem): void;
59
62
  protected filterItems(): void;
@@ -62,24 +65,39 @@ export declare abstract class RdtMenuBaseComponent implements OnInit, OnChanges,
62
65
  params: Record<string, any>;
63
66
  }): ParsedRdtMenuItem[];
64
67
  protected invokeItemClickByIndex(itemIndex: number): void;
65
- protected openSubmenu(itemIndex: number, visibleFocus: 'first' | 'last'): void;
68
+ protected openSubmenu(itemIndex: number, visibleFocus: 'first' | 'last', src: RdtMenuExpandSource): void;
66
69
  protected focusItem(item: number | ParsedRdtMenuItem): void;
67
70
  protected focusNextItem(itemIndex: number): void;
68
71
  protected focusPrevItem(itemIndex: number): void;
69
72
  protected blurAllFocusable(): void;
70
73
  protected focusFocusable(itemIndex: number): void;
74
+ protected onPointerMove(event: PointerEvent): void;
71
75
  protected checkActiveElement(event: FocusEvent): void;
72
76
  protected onDocumentClick(event: PointerEvent): void;
73
77
  protected measure(): void;
74
78
  protected readMargin(): void;
75
79
  protected measureClientSize(): void;
80
+ protected measureButtonContainer(): void;
76
81
  protected listenWindowResize(): void;
77
82
  protected listenShortcuts(): void;
78
83
  protected getShortcutMap(itemsWithShortcuts: ParsedRdtMenuItemWithShortcut[]): Record<string, ParsedRdtMenuItem[]>;
79
84
  protected onShortcut(shortcut: RdtShortcut): void;
80
- protected activateItemRecursively(path: ParsedRdtMenuItem[]): void;
85
+ protected activateItemRecursively(path: ParsedRdtMenuItem[], src: RdtMenuExpandSource): void;
86
+ isPointerInsideHitbox(hitbox: DOMRect, event: PointerEvent): boolean;
87
+ getHitboxes(): {
88
+ rect: DOMRect;
89
+ fixed: boolean;
90
+ close: () => void;
91
+ }[];
92
+ getOpenMenuBoundingBoxes(): {
93
+ rect: DOMRect;
94
+ fixed: boolean;
95
+ close: () => void;
96
+ }[];
97
+ private getOpenMenuBoundingBoxesRec;
81
98
  static ɵfac: i0.ɵɵFactoryDeclaration<RdtMenuBaseComponent, never>;
82
- static ɵdir: i0.ɵɵDirectiveDeclaration<RdtMenuBaseComponent, never, never, { "preferredVerticalDir": { "alias": "preferredVerticalDir"; "required": false; }; "preferredHorizontalDir": { "alias": "preferredHorizontalDir"; "required": false; }; "shortcutMode": { "alias": "shortcutMode"; "required": false; }; "closeOnFocusOut": { "alias": "closeOnFocusOut"; "required": false; }; "openOnHover": { "alias": "openOnHover"; "required": false; }; }, {}, never, never, false, never>;
99
+ static ɵdir: i0.ɵɵDirectiveDeclaration<RdtMenuBaseComponent, never, never, { "preferredVerticalDir": { "alias": "preferredVerticalDir"; "required": false; }; "preferredHorizontalDir": { "alias": "preferredHorizontalDir"; "required": false; }; "shortcutMode": { "alias": "shortcutMode"; "required": false; }; "closeOnFocusOut": { "alias": "closeOnFocusOut"; "required": false; }; "openOnHover": { "alias": "openOnHover"; "required": false; }; "hitboxMargin": { "alias": "hitboxMargin"; "required": false; }; }, {}, never, never, false, never>;
83
100
  static ngAcceptInputType_closeOnFocusOut: unknown;
84
101
  static ngAcceptInputType_openOnHover: unknown;
102
+ static ngAcceptInputType_hitboxMargin: unknown;
85
103
  }
@@ -1,6 +1,6 @@
1
- import { AfterViewInit, DestroyRef, ElementRef, OnChanges, OnInit, SimpleChanges } from '@angular/core';
1
+ import { AfterViewInit, DestroyRef, ElementRef, OnChanges, OnInit, QueryList, SimpleChanges } from '@angular/core';
2
2
  import { RdtHorizontalDirection, RdtVerticalDirection } from '@ngrdt/utils';
3
- import { ParsedRdtMenuItem, ParsedRdtMenuItemWithChildren } from '../private-models';
3
+ import { ParsedRdtMenuItem, ParsedRdtMenuItemWithChildren, RdtMenuExpandSource } from '../private-models';
4
4
  import { HorDirWithOffset, VertDirWithOffset } from '../utils';
5
5
  import * as i0 from "@angular/core";
6
6
  export declare class RdtMenuOverlayComponent implements OnInit, OnChanges, AfterViewInit {
@@ -13,7 +13,7 @@ export declare class RdtMenuOverlayComponent implements OnInit, OnChanges, After
13
13
  private readonly router;
14
14
  private readonly document;
15
15
  private readonly shortcutService;
16
- private children;
16
+ readonly children: QueryList<RdtMenuOverlayComponent>;
17
17
  private focusableElements;
18
18
  private menuItemContainer;
19
19
  item: ParsedRdtMenuItemWithChildren;
@@ -34,11 +34,15 @@ export declare class RdtMenuOverlayComponent implements OnInit, OnChanges, After
34
34
  private _viewWasInit;
35
35
  protected verticalDir: VertDirWithOffset | null;
36
36
  protected horizontalDir: HorDirWithOffset | null;
37
- protected expandedChild: ParsedRdtMenuItem | null;
37
+ protected expandedChild: {
38
+ item: ParsedRdtMenuItem;
39
+ src: RdtMenuExpandSource;
40
+ } | null;
38
41
  protected autofocusSubmenuItem: 'first' | 'last' | null;
39
42
  readonly keyActions: {
40
43
  [x: string]: (index: number) => void;
41
44
  };
45
+ get selfExpandSrc(): RdtMenuExpandSource | undefined;
42
46
  ngOnInit(): void;
43
47
  ngOnChanges(changes: SimpleChanges): void;
44
48
  ngAfterViewInit(): void;
@@ -48,7 +52,6 @@ export declare class RdtMenuOverlayComponent implements OnInit, OnChanges, After
48
52
  private getMaxOffsetTop;
49
53
  recalculatePosition(preferredHorizontalDir: RdtHorizontalDirection, preferredVerticalDir: RdtVerticalDirection): void;
50
54
  onItemPointerEnter(item: ParsedRdtMenuItem): void;
51
- onItemPointerLeave(item: ParsedRdtMenuItem): void;
52
55
  onItemClick(item: ParsedRdtMenuItem): void;
53
56
  invokeItemClick(item: ParsedRdtMenuItem): void;
54
57
  getChildRoutes(item: ParsedRdtMenuItem): string[][];
@@ -64,7 +67,7 @@ export declare class RdtMenuOverlayComponent implements OnInit, OnChanges, After
64
67
  private focusNextItem;
65
68
  private focusPrevItem;
66
69
  private openSubmenu;
67
- private closeSelf;
70
+ closeSelf(focusExpanded?: boolean): void;
68
71
  private checkActiveElement;
69
72
  private getRealHorizontalDir;
70
73
  private getNarrowScreenHorizontalDir;
@@ -1,8 +1,8 @@
1
+ import { Injector } from '@angular/core';
1
2
  import { RdtRoute } from '@ngrdt/router';
2
3
  import { RdtShortcut } from '@ngrdt/shortcuts';
3
4
  import { WindowOpenTargetType } from '@ngrdt/utils';
4
5
  import { RdtMenuItem } from './models';
5
- import { Injector } from '@angular/core';
6
6
  export interface RdtMenuItemBase<TIcon = string> {
7
7
  label: string;
8
8
  icon?: TIcon;
@@ -15,24 +15,24 @@ export interface RdtMenuItemBase<TIcon = string> {
15
15
  requiredParent?: RdtRoute;
16
16
  dataTestId?: string;
17
17
  }
18
- export interface ParsedRdtMenuItemWithChildren<TIcon = string> extends RdtMenuItemBase<TIcon> {
19
- items: ParsedRdtMenuItem[];
18
+ export interface ParsedRdtMenuItemBase<TIcon = string> extends RdtMenuItemBase<TIcon> {
20
19
  dataTestId: string;
20
+ }
21
+ export interface ParsedRdtMenuItemWithChildren<TIcon = string> extends ParsedRdtMenuItemBase<TIcon> {
22
+ items: ParsedRdtMenuItem[];
21
23
  routerLink?: never;
22
24
  externalLink?: never;
23
25
  icon?: never;
24
26
  target?: never;
25
27
  }
26
- export interface ParsedRdtMenuItemWithRoute<TIcon = string> extends RdtMenuItemBase<TIcon> {
27
- dataTestId: string;
28
+ export interface ParsedRdtMenuItemWithRoute<TIcon = string> extends ParsedRdtMenuItemBase<TIcon> {
28
29
  items?: never;
29
30
  routerLink?: string[];
30
31
  externalLink?: never;
31
32
  icon?: TIcon;
32
33
  target: WindowOpenTargetType;
33
34
  }
34
- export interface ParsedRdtMenuItemWithLink<TIcon = string> extends RdtMenuItemBase<TIcon> {
35
- dataTestId: string;
35
+ export interface ParsedRdtMenuItemWithLink<TIcon = string> extends ParsedRdtMenuItemBase<TIcon> {
36
36
  items?: never;
37
37
  routerLink?: never;
38
38
  externalLink?: string;
@@ -41,3 +41,13 @@ export interface ParsedRdtMenuItemWithLink<TIcon = string> extends RdtMenuItemBa
41
41
  }
42
42
  export type ParsedRdtMenuItem = ParsedRdtMenuItemWithRoute | ParsedRdtMenuItemWithChildren | ParsedRdtMenuItemWithLink;
43
43
  export declare function parseMenuItems(items: RdtMenuItem[], injector: Injector, prefix?: string): ParsedRdtMenuItem[];
44
+ export declare enum RdtMenuExpandSource {
45
+ Click = 0,
46
+ Hover = 1,
47
+ Shortcut = 2,
48
+ Focus = 3
49
+ }
50
+ export interface RdtMenuExpandedChild {
51
+ item: ParsedRdtMenuItem;
52
+ src: RdtMenuExpandSource;
53
+ }
package/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@ngrdt/menu",
3
- "version": "0.0.11",
3
+ "version": "0.0.14",
4
4
  "peerDependencies": {
5
5
  "@angular/common": ">=18.2.0",
6
6
  "@angular/core": ">=18.2.0",
7
7
  "@angular/router": ">=18.2.0",
8
8
  "rxjs": ">=7.0.0",
9
- "@ngrdt/router": ">=0.0.12",
9
+ "@ngrdt/router": ">=0.0.13",
10
10
  "@ngrdt/utils": ">=0.0.8",
11
11
  "@ngrdt/button": ">=0.0.2",
12
12
  "@ngrdt/shortcuts": ">=0.0.7"