ngx-core-components 0.3.26 → 0.3.28

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.
@@ -1,3 +1,4 @@
1
+ import { ElementRef } from '@angular/core';
1
2
  import * as i0 from "@angular/core";
2
3
  export type ExportFormat = 'json' | 'csv' | 'svg' | 'pdf';
3
4
  /**
@@ -16,9 +17,14 @@ export declare class ChartExportMenuComponent {
16
17
  formats: import("@angular/core").InputSignal<ExportFormat[]>;
17
18
  exportClicked: import("@angular/core").OutputEmitterRef<ExportFormat>;
18
19
  isOpen: import("@angular/core").WritableSignal<boolean>;
20
+ focusedIndex: import("@angular/core").WritableSignal<number>;
21
+ menuBtns: import("@angular/core").Signal<readonly ElementRef<HTMLButtonElement>[]>;
19
22
  toggle(event: MouseEvent): void;
20
23
  select(fmt: ExportFormat): void;
21
24
  formatIcon(fmt: ExportFormat): string;
25
+ onArrowDown(event: Event): void;
26
+ onArrowUp(event: Event): void;
27
+ private navigate;
22
28
  closeOnOutsideClick(): void;
23
29
  closeOnEscape(): void;
24
30
  static ɵfac: i0.ɵɵFactoryDeclaration<ChartExportMenuComponent, never>;
@@ -1,5 +1,5 @@
1
1
  import * as i0 from '@angular/core';
2
- import { inject, PLATFORM_ID, Injectable, input, output, signal, HostListener, ChangeDetectionStrategy, Component, viewChild, computed, ElementRef, DestroyRef, effect } from '@angular/core';
2
+ import { inject, PLATFORM_ID, Injectable, input, output, signal, viewChildren, HostListener, ChangeDetectionStrategy, Component, viewChild, computed, ElementRef, DestroyRef, effect } from '@angular/core';
3
3
  import * as i1 from '@angular/common';
4
4
  import { DOCUMENT, isPlatformBrowser, NgTemplateOutlet, CommonModule, DecimalPipe, UpperCasePipe } from '@angular/common';
5
5
  import { NGX_CORE_I18N } from 'ngx-core-components/i18n';
@@ -149,12 +149,17 @@ class ChartExportMenuComponent {
149
149
  formats = input(['json', 'csv', 'svg', 'pdf']);
150
150
  exportClicked = output();
151
151
  isOpen = signal(false);
152
+ focusedIndex = signal(-1);
153
+ menuBtns = viewChildren('menuBtn');
152
154
  toggle(event) {
153
155
  event.stopPropagation();
154
- this.isOpen.update(v => !v);
156
+ const nextVal = !this.isOpen();
157
+ this.isOpen.set(nextVal);
158
+ this.focusedIndex.set(-1);
155
159
  }
156
160
  select(fmt) {
157
161
  this.isOpen.set(false);
162
+ this.focusedIndex.set(-1);
158
163
  this.exportClicked.emit(fmt);
159
164
  }
160
165
  formatIcon(fmt) {
@@ -166,15 +171,40 @@ class ChartExportMenuComponent {
166
171
  };
167
172
  return icons[fmt] ?? '📁';
168
173
  }
174
+ onArrowDown(event) {
175
+ if (!this.isOpen())
176
+ return;
177
+ event.preventDefault();
178
+ this.navigate(1);
179
+ }
180
+ onArrowUp(event) {
181
+ if (!this.isOpen())
182
+ return;
183
+ event.preventDefault();
184
+ this.navigate(-1);
185
+ }
186
+ navigate(direction) {
187
+ const list = this.formats();
188
+ if (list.length === 0)
189
+ return;
190
+ const nextIdx = (this.focusedIndex() + direction + list.length) % list.length;
191
+ this.focusedIndex.set(nextIdx);
192
+ const buttons = this.menuBtns();
193
+ if (buttons && buttons[nextIdx]) {
194
+ buttons[nextIdx].nativeElement.focus();
195
+ }
196
+ }
169
197
  closeOnOutsideClick() {
170
198
  this.isOpen.set(false);
199
+ this.focusedIndex.set(-1);
171
200
  }
172
201
  closeOnEscape() {
173
202
  this.isOpen.set(false);
203
+ this.focusedIndex.set(-1);
174
204
  }
175
205
  static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.20", ngImport: i0, type: ChartExportMenuComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
176
- static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.2.20", type: ChartExportMenuComponent, isStandalone: true, selector: "ngx-chart-export-menu", inputs: { formats: { classPropertyName: "formats", publicName: "formats", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { exportClicked: "exportClicked" }, host: { listeners: { "document:click": "closeOnOutsideClick()", "document:keydown.escape": "closeOnEscape()" } }, ngImport: i0, template: `
177
- <div class="chart-export-menu">
206
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.2.20", type: ChartExportMenuComponent, isStandalone: true, selector: "ngx-chart-export-menu", inputs: { formats: { classPropertyName: "formats", publicName: "formats", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { exportClicked: "exportClicked" }, host: { listeners: { "document:click": "closeOnOutsideClick()", "document:keydown.escape": "closeOnEscape()" } }, viewQueries: [{ propertyName: "menuBtns", predicate: ["menuBtn"], descendants: true, isSignal: true }], ngImport: i0, template: `
207
+ <div class="chart-export-menu" (keydown.arrowdown)="onArrowDown($event)" (keydown.arrowup)="onArrowUp($event)">
178
208
  <button
179
209
  class="export-trigger"
180
210
  (click)="toggle($event)"
@@ -188,8 +218,9 @@ class ChartExportMenuComponent {
188
218
 
189
219
  @if (isOpen()) {
190
220
  <div class="export-dropdown" role="menu">
191
- @for (fmt of formats(); track fmt) {
221
+ @for (fmt of formats(); track fmt; let i = $index) {
192
222
  <button
223
+ #menuBtn
193
224
  type="button"
194
225
  role="menuitem"
195
226
  (click)="select(fmt)"
@@ -205,7 +236,7 @@ class ChartExportMenuComponent {
205
236
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.20", ngImport: i0, type: ChartExportMenuComponent, decorators: [{
206
237
  type: Component,
207
238
  args: [{ selector: 'ngx-chart-export-menu', standalone: true, imports: [], changeDetection: ChangeDetectionStrategy.OnPush, template: `
208
- <div class="chart-export-menu">
239
+ <div class="chart-export-menu" (keydown.arrowdown)="onArrowDown($event)" (keydown.arrowup)="onArrowUp($event)">
209
240
  <button
210
241
  class="export-trigger"
211
242
  (click)="toggle($event)"
@@ -219,8 +250,9 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.20", ngImpo
219
250
 
220
251
  @if (isOpen()) {
221
252
  <div class="export-dropdown" role="menu">
222
- @for (fmt of formats(); track fmt) {
253
+ @for (fmt of formats(); track fmt; let i = $index) {
223
254
  <button
255
+ #menuBtn
224
256
  type="button"
225
257
  role="menuitem"
226
258
  (click)="select(fmt)"
@@ -35451,7 +35483,7 @@ class AgenticCognitiveTopologyComponent {
35451
35483
  if (!links.length)
35452
35484
  return;
35453
35485
  const headers = ['Source', 'Target', 'Active'];
35454
- const rows = links.map(l => [l.source, l.target, !!l.active ? 'true' : 'false']);
35486
+ const rows = links.map(l => [l.source, l.target, l.active ? 'true' : 'false']);
35455
35487
  this.exportSvc.downloadCsv(headers, rows, 'topology-flow-data.csv');
35456
35488
  }
35457
35489
  exportToSvg() {