@skyux/ag-grid 14.2.2 → 14.3.0

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,6 +1,6 @@
1
1
  import { NgClass, CommonModule, NgTemplateOutlet, AsyncPipe } from '@angular/common';
2
2
  import * as i0 from '@angular/core';
3
- import { NgModule, Injectable, signal, input, booleanAttribute, numberAttribute, viewChild, inject, DestroyRef, ElementRef, DOCUMENT, computed, effect, ContentChild, ChangeDetectionStrategy, Component, contentChildren, linkedSignal, ChangeDetectorRef, untracked, Directive, InjectionToken, model, output, contentChild, EnvironmentInjector, HostListener, ViewChild, ViewEncapsulation, HostBinding, isSignal, Input, CSP_NONCE } from '@angular/core';
3
+ import { NgModule, Injectable, signal, input, booleanAttribute, numberAttribute, viewChild, inject, DestroyRef, ElementRef, DOCUMENT, computed, effect, ContentChild, ChangeDetectionStrategy, Component, contentChildren, linkedSignal, ChangeDetectorRef, untracked, Directive, InjectionToken, model, output, contentChild, EnvironmentInjector, HostListener, ViewChild, ViewEncapsulation, HostBinding, isSignal, Input, RendererFactory2, CSP_NONCE } from '@angular/core';
4
4
  import { AgGridAngular } from 'ag-grid-angular';
5
5
  import * as i3 from '@skyux/i18n';
6
6
  import { SkyLibResourcesService, SkyI18nModule } from '@skyux/i18n';
@@ -2791,6 +2791,9 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.0", ngImpor
2791
2791
  }] } });
2792
2792
 
2793
2793
  class SkyAgGridHeaderRowSelectorComponent {
2794
+ #api;
2795
+ #subscriptions;
2796
+ #renderer;
2794
2797
  constructor() {
2795
2798
  this.checked = model(false, ...(ngDevMode ? [{ debugName: "checked" }] : []));
2796
2799
  this.indeterminate = signal(false, ...(ngDevMode ? [{ debugName: "indeterminate" }] : []));
@@ -2800,22 +2803,22 @@ class SkyAgGridHeaderRowSelectorComponent {
2800
2803
  const params = this.params();
2801
2804
  return params?.displayName || params?.column.getColDef().field;
2802
2805
  }, ...(ngDevMode ? [{ debugName: "label" }] : []));
2803
- this.#destroyRef = inject(DestroyRef);
2806
+ this.#subscriptions = new Subscription();
2807
+ this.#renderer = inject(RendererFactory2).createRenderer(undefined, null);
2808
+ inject(DestroyRef).onDestroy(() => this.#subscriptions.unsubscribe());
2804
2809
  }
2805
- #api;
2806
- #destroyRef;
2807
2810
  agInit(params) {
2808
2811
  this.params.set(params);
2809
2812
  this.#api = params.api;
2813
+ this.#subscriptions.unsubscribe();
2814
+ this.#subscriptions = new Subscription();
2810
2815
  // Row selection behavior can only be set when the grid is created.
2811
2816
  // It only changes if the grid is recreated.
2812
2817
  const rowSelection = params.api.getGridOption('rowSelection');
2813
2818
  this.multiSelect.set(rowSelection === 'multiple' ||
2814
2819
  (typeof rowSelection === 'object' && rowSelection?.mode === 'multiRow'));
2815
2820
  if (this.multiSelect()) {
2816
- fromGridEvent(params.api, 'selectionChanged')
2817
- .pipe(takeUntilDestroyed(this.#destroyRef))
2818
- .subscribe((change) => {
2821
+ this.#subscriptions.add(fromGridEvent(params.api, 'selectionChanged').subscribe((change) => {
2819
2822
  if (change.source.match(/selectall/i)) {
2820
2823
  // Either select all or clear selection.
2821
2824
  this.indeterminate.set(false);
@@ -2825,13 +2828,29 @@ class SkyAgGridHeaderRowSelectorComponent {
2825
2828
  this.indeterminate.set(!!change.selectedNodes?.length);
2826
2829
  this.checked.set(false);
2827
2830
  }
2828
- });
2829
- fromGridEvent(params.api, 'rowDataUpdated')
2830
- .pipe(takeUntilDestroyed(this.#destroyRef))
2831
- .subscribe(() => {
2831
+ }));
2832
+ this.#subscriptions.add(fromGridEvent(params.api, 'rowDataUpdated').subscribe(() => {
2832
2833
  this.indeterminate.set(!!this.#api?.getSelectedNodes().length);
2833
2834
  this.checked.set(false);
2834
- });
2835
+ }));
2836
+ const el = params.eGridHeader;
2837
+ if (el) {
2838
+ this.#renderer.setAttribute(el, 'aria-keyshortcuts', 'Enter Space');
2839
+ this.#subscriptions.add(this.#renderer.listen(el, 'keydown', (evt) => {
2840
+ if (!['Enter', ' '].includes(evt.key) || evt.repeat) {
2841
+ return;
2842
+ }
2843
+ if (evt.key === ' ') {
2844
+ evt.preventDefault();
2845
+ }
2846
+ if (this.checked()) {
2847
+ this.#api?.deselectAll();
2848
+ }
2849
+ else {
2850
+ this.#api?.selectAll();
2851
+ }
2852
+ }));
2853
+ }
2835
2854
  }
2836
2855
  }
2837
2856
  refresh() {
@@ -2854,7 +2873,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.0", ngImpor
2854
2873
  '[attr.title]': 'label()',
2855
2874
  '[attr.role]': '"note"',
2856
2875
  }, template: "@if (multiSelect()) {\n <sky-checkbox\n labelHidden\n data-sky-id=\"header-row-selector\"\n [checked]=\"checked()\"\n [labelText]=\"label()\"\n [indeterminate]=\"indeterminate()\"\n (change)=\"toggleCheckbox($event)\"\n />\n}\n" }]
2857
- }], propDecorators: { checked: [{ type: i0.Input, args: [{ isSignal: true, alias: "checked", required: false }] }, { type: i0.Output, args: ["checkedChange"] }] } });
2876
+ }], ctorParameters: () => [], propDecorators: { checked: [{ type: i0.Input, args: [{ isSignal: true, alias: "checked", required: false }] }, { type: i0.Output, args: ["checkedChange"] }] } });
2858
2877
 
2859
2878
  /**
2860
2879
  * To display a help button beside the column header, create a component containing