@skyux/ag-grid 14.2.2 → 14.3.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.
@@ -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, afterNextRender, 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';
@@ -1227,41 +1227,39 @@ class SkyAgGridRowDeleteDirective {
1227
1227
  .subscribe((evt) => {
1228
1228
  this.rowDeleteIds.update((rowIds) => (rowIds ?? []).filter((id) => !!evt.api.getRowNode(id)));
1229
1229
  });
1230
- }
1231
- ngAfterContentInit() {
1232
- this.#overlay = this.#overlayService.create({
1233
- enableScroll: true,
1234
- environmentInjector: this.#environmentInjector,
1235
- showBackdrop: false,
1236
- closeOnNavigation: true,
1237
- enableClose: false,
1238
- enablePointerEvents: true,
1239
- });
1240
- this.#overlay.attachComponent(SkyAgGridRowDeleteComponent, [
1241
- {
1242
- provide: SKY_AG_GRID_ROW_DELETE_CONTEXT,
1243
- useValue: this.#rowDeleteSvc,
1244
- },
1245
- ]);
1246
- this.#zIndex
1247
- .pipe(takeUntil(this.#ngUnsubscribe), takeUntil(this.#overlay.closed), distinctUntilChanged())
1248
- .subscribe((zIndex) => {
1249
- if (this.#overlay) {
1250
- this.#overlay.componentRef.instance.zIndex = zIndex.toString(10);
1251
- }
1252
- });
1253
- this.#clipPath
1254
- .pipe(takeUntil(this.#ngUnsubscribe), takeUntil(this.#overlay.closed), distinctUntilChanged())
1255
- .subscribe((clipPath) => {
1256
- this.#overlay?.componentRef.instance.updateClipPath(clipPath);
1257
- });
1258
- }
1259
- ngAfterViewInit() {
1260
- this.#scrollableHostService
1261
- .watchScrollableHostClipPathChanges(this.#elementRef, this.#agGridBodyClipElements.asObservable())
1262
- .pipe(takeUntil(this.#ngUnsubscribe))
1263
- .subscribe((clipPath) => {
1264
- this.#clipPath.next(clipPath);
1230
+ afterNextRender(() => {
1231
+ this.#overlay = this.#overlayService.create({
1232
+ enableScroll: true,
1233
+ environmentInjector: this.#environmentInjector,
1234
+ showBackdrop: false,
1235
+ closeOnNavigation: false,
1236
+ enableClose: false,
1237
+ enablePointerEvents: true,
1238
+ });
1239
+ this.#overlay.attachComponent(SkyAgGridRowDeleteComponent, [
1240
+ {
1241
+ provide: SKY_AG_GRID_ROW_DELETE_CONTEXT,
1242
+ useValue: this.#rowDeleteSvc,
1243
+ },
1244
+ ]);
1245
+ this.#zIndex
1246
+ .pipe(takeUntil(this.#ngUnsubscribe), takeUntil(this.#overlay.closed), distinctUntilChanged())
1247
+ .subscribe((zIndex) => {
1248
+ if (this.#overlay) {
1249
+ this.#overlay.componentRef.instance.zIndex = zIndex.toString(10);
1250
+ }
1251
+ });
1252
+ this.#clipPath
1253
+ .pipe(takeUntil(this.#ngUnsubscribe), takeUntil(this.#overlay.closed), distinctUntilChanged())
1254
+ .subscribe((clipPath) => {
1255
+ this.#overlay?.componentRef.instance.updateClipPath(clipPath);
1256
+ });
1257
+ this.#scrollableHostService
1258
+ .watchScrollableHostClipPathChanges(this.#elementRef, this.#agGridBodyClipElements.asObservable())
1259
+ .pipe(takeUntil(this.#ngUnsubscribe))
1260
+ .subscribe((clipPath) => {
1261
+ this.#clipPath.next(clipPath);
1262
+ });
1265
1263
  });
1266
1264
  }
1267
1265
  ngOnDestroy() {
@@ -2275,8 +2273,8 @@ class SkyAgGridCellRendererCurrencyComponent {
2275
2273
  this.value = params.value;
2276
2274
  this.skyComponentProperties = params.skyComponentProperties || {};
2277
2275
  this.skyComponentProperties.format = 'currency';
2278
- this.skyComponentProperties.minDigits = 2;
2279
- this.skyComponentProperties.truncate = false;
2276
+ this.skyComponentProperties.minDigits ??= 2;
2277
+ this.skyComponentProperties.truncate ??= false;
2280
2278
  }
2281
2279
  static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.0", ngImport: i0, type: SkyAgGridCellRendererCurrencyComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
2282
2280
  static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "21.2.0", type: SkyAgGridCellRendererCurrencyComponent, isStandalone: true, selector: "sky-ag-grid-cell-renderer-currency", inputs: { params: "params" }, ngImport: i0, template: "{{\n value === undefined ? undefined : (value | skyNumeric: skyComponentProperties)\n}}\n", styles: [""], dependencies: [{ kind: "ngmodule", type: SkyNumericModule }, { kind: "pipe", type: i1.SkyNumericPipe, name: "skyNumeric" }], changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
@@ -2791,6 +2789,9 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.0", ngImpor
2791
2789
  }] } });
2792
2790
 
2793
2791
  class SkyAgGridHeaderRowSelectorComponent {
2792
+ #api;
2793
+ #subscriptions;
2794
+ #renderer;
2794
2795
  constructor() {
2795
2796
  this.checked = model(false, ...(ngDevMode ? [{ debugName: "checked" }] : []));
2796
2797
  this.indeterminate = signal(false, ...(ngDevMode ? [{ debugName: "indeterminate" }] : []));
@@ -2800,22 +2801,22 @@ class SkyAgGridHeaderRowSelectorComponent {
2800
2801
  const params = this.params();
2801
2802
  return params?.displayName || params?.column.getColDef().field;
2802
2803
  }, ...(ngDevMode ? [{ debugName: "label" }] : []));
2803
- this.#destroyRef = inject(DestroyRef);
2804
+ this.#subscriptions = new Subscription();
2805
+ this.#renderer = inject(RendererFactory2).createRenderer(undefined, null);
2806
+ inject(DestroyRef).onDestroy(() => this.#subscriptions.unsubscribe());
2804
2807
  }
2805
- #api;
2806
- #destroyRef;
2807
2808
  agInit(params) {
2808
2809
  this.params.set(params);
2809
2810
  this.#api = params.api;
2811
+ this.#subscriptions.unsubscribe();
2812
+ this.#subscriptions = new Subscription();
2810
2813
  // Row selection behavior can only be set when the grid is created.
2811
2814
  // It only changes if the grid is recreated.
2812
2815
  const rowSelection = params.api.getGridOption('rowSelection');
2813
2816
  this.multiSelect.set(rowSelection === 'multiple' ||
2814
2817
  (typeof rowSelection === 'object' && rowSelection?.mode === 'multiRow'));
2815
2818
  if (this.multiSelect()) {
2816
- fromGridEvent(params.api, 'selectionChanged')
2817
- .pipe(takeUntilDestroyed(this.#destroyRef))
2818
- .subscribe((change) => {
2819
+ this.#subscriptions.add(fromGridEvent(params.api, 'selectionChanged').subscribe((change) => {
2819
2820
  if (change.source.match(/selectall/i)) {
2820
2821
  // Either select all or clear selection.
2821
2822
  this.indeterminate.set(false);
@@ -2825,13 +2826,29 @@ class SkyAgGridHeaderRowSelectorComponent {
2825
2826
  this.indeterminate.set(!!change.selectedNodes?.length);
2826
2827
  this.checked.set(false);
2827
2828
  }
2828
- });
2829
- fromGridEvent(params.api, 'rowDataUpdated')
2830
- .pipe(takeUntilDestroyed(this.#destroyRef))
2831
- .subscribe(() => {
2829
+ }));
2830
+ this.#subscriptions.add(fromGridEvent(params.api, 'rowDataUpdated').subscribe(() => {
2832
2831
  this.indeterminate.set(!!this.#api?.getSelectedNodes().length);
2833
2832
  this.checked.set(false);
2834
- });
2833
+ }));
2834
+ const el = params.eGridHeader;
2835
+ if (el) {
2836
+ this.#renderer.setAttribute(el, 'aria-keyshortcuts', 'Enter Space');
2837
+ this.#subscriptions.add(this.#renderer.listen(el, 'keydown', (evt) => {
2838
+ if (!['Enter', ' '].includes(evt.key) || evt.repeat) {
2839
+ return;
2840
+ }
2841
+ if (evt.key === ' ') {
2842
+ evt.preventDefault();
2843
+ }
2844
+ if (this.checked()) {
2845
+ this.#api?.deselectAll();
2846
+ }
2847
+ else {
2848
+ this.#api?.selectAll();
2849
+ }
2850
+ }));
2851
+ }
2835
2852
  }
2836
2853
  }
2837
2854
  refresh() {
@@ -2854,7 +2871,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.0", ngImpor
2854
2871
  '[attr.title]': 'label()',
2855
2872
  '[attr.role]': '"note"',
2856
2873
  }, 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"] }] } });
2874
+ }], ctorParameters: () => [], propDecorators: { checked: [{ type: i0.Input, args: [{ isSignal: true, alias: "checked", required: false }] }, { type: i0.Output, args: ["checkedChange"] }] } });
2858
2875
 
2859
2876
  /**
2860
2877
  * To display a help button beside the column header, create a component containing