@energycap/components 0.39.16 → 0.39.17-ECAP-23124-menu-item-divider-improvements.20240523-1609

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.
@@ -212,6 +212,11 @@ export declare class ComboboxComponent extends FormControlBase implements OnInit
212
212
  * Number of filtered options to display in the footer. Excludes headings.
213
213
  */
214
214
  filteredOptionCount: number;
215
+ /**
216
+ * Flat list of selectable items in the combobox.
217
+ * Does not include headings or divider-section items.
218
+ */
219
+ private selectableItems;
215
220
  /**
216
221
  * Index of the currently-selected options
217
222
  */
@@ -1,4 +1,4 @@
1
- import { AfterContentInit, ElementRef, EventEmitter, OnDestroy, Renderer2, TemplateRef } from '@angular/core';
1
+ import { AfterContentInit, ElementRef, EventEmitter, OnChanges, OnDestroy, Renderer2, SimpleChanges, TemplateRef } from '@angular/core';
2
2
  import { ScrollService } from '../../core/scroll.service';
3
3
  import { WindowService } from '../../core/window.service';
4
4
  import { LinkTarget } from '../../display/tags/tag';
@@ -11,7 +11,7 @@ export interface MenuItem<TValue = any, SItems = any> extends NavItem {
11
11
  caption?: string;
12
12
  items?: MenuItem<SItems>[];
13
13
  checked?: boolean;
14
- display?: 'default' | 'heading' | 'divider';
14
+ display?: 'default' | 'heading' | 'divider' | 'divided-section';
15
15
  value?: TValue;
16
16
  classList?: string;
17
17
  disabled?: boolean;
@@ -21,6 +21,7 @@ export interface MenuItem<TValue = any, SItems = any> extends NavItem {
21
21
  externalLink?: boolean;
22
22
  /** Optional text to display in-place of the default label when the MenuItem is selected. */
23
23
  selectedLabel?: string;
24
+ hideIfNoItems?: boolean;
24
25
  }
25
26
  export declare const menuAnimationSpeed = 350;
26
27
  /**
@@ -28,7 +29,7 @@ export declare const menuAnimationSpeed = 350;
28
29
  *
29
30
  * @export
30
31
  */
31
- export declare class MenuComponent implements AfterContentInit, OnDestroy {
32
+ export declare class MenuComponent implements AfterContentInit, OnDestroy, OnChanges {
32
33
  private el;
33
34
  private renderer;
34
35
  private windowService;
@@ -161,7 +162,29 @@ export declare class MenuComponent implements AfterContentInit, OnDestroy {
161
162
  * This allows us to prevent double-calls to selectItem() with the same input.
162
163
  */
163
164
  private lastSelected;
165
+ /**
166
+ * Flattened array of all selectable items in the menu. Makes it easier to keep track of the currently highlighted item for keyboard navigation.
167
+ */
168
+ private selectableItems;
169
+ /**
170
+ * Helper function to return a flat list of all selectable items in the provided menu items. Filters out headings and divided-sections.
171
+ * This makes it much easier to keep track of currently highlighted items for keyboard navigation.
172
+ */
173
+ static getSelectableItems(items: MenuItem[]): MenuItem[];
174
+ /**
175
+ * Returns an ID for the provided item based on its index in the provided items array. This mimics the behavior of the MenuComponent's
176
+ * generated IDs for items that don't have provided IDs. This is used in MenuComponent and ComboboxComponent to scroll to specific items.
177
+ * NOTE: If the items array does not match what is displayed in the menu, this function will not return the correct ID.
178
+ *
179
+ * Returns null if the not found
180
+ * @param items The MenuItems array to search through.
181
+ * @param item The item to generate the ID for.
182
+ * @param menuComponentId Used to prefix the generated ID. This should be the ID of the menu component the item is present in.
183
+ * @memberof MenuComponent
184
+ */
185
+ static getIndexedItemId(items: MenuItem[], item?: MenuItem | null, menuComponentId?: string): string | null;
164
186
  constructor(el: ElementRef, renderer: Renderer2, windowService: WindowService, scrollService: ScrollService);
187
+ ngOnChanges(changes: SimpleChanges): void;
165
188
  /**
166
189
  * Sets & displays the interalized template based on
167
190
  * the set template.
@@ -215,14 +238,6 @@ export declare class MenuComponent implements AfterContentInit, OnDestroy {
215
238
  */
216
239
  private scrollMenu;
217
240
  private scrollToHighlightedItem;
218
- /**
219
- * Find a given item's index in the filtered items array.
220
- *
221
- * Returns -1 if not found
222
- * @param itemToFind The matching item to find in the items array.
223
- * @memberof MenuComponent
224
- */
225
- private findItemIndex;
226
241
  private addKeydownListener;
227
242
  /**
228
243
  * Sets the menu item ids using its index if item doesn't already have one
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@energycap/components",
3
- "version": "0.39.16",
3
+ "version": "0.39.17-ECAP-23124-menu-item-divider-improvements.20240523-1609",
4
4
  "dependencies": {
5
5
  "tslib": "^2.0.0"
6
6
  },