@skyux/ag-grid 6.9.0 → 6.10.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.
@@ -11,13 +11,13 @@ import { SkyInlineDeleteModule } from '@skyux/layout';
11
11
  import { AgGridAngular, AgGridModule } from 'ag-grid-angular';
12
12
  import { Subject, fromEvent } from 'rxjs';
13
13
  import { takeUntil, filter, first } from 'rxjs/operators';
14
+ import { __classPrivateFieldSet, __classPrivateFieldGet } from 'tslib';
14
15
  import * as i1$4 from '@angular/forms';
15
16
  import { FormGroup, FormControl, ReactiveFormsModule, FormsModule } from '@angular/forms';
16
17
  import * as i1$3 from '@skyux/lookup';
17
18
  import { SkyAutocompleteModule, SkyLookupModule } from '@skyux/lookup';
18
19
  import * as i3$1 from '@skyux/i18n';
19
20
  import { getLibStringForLocale, SkyI18nModule, SKY_LIB_RESOURCES_PROVIDERS } from '@skyux/i18n';
20
- import { __classPrivateFieldSet, __classPrivateFieldGet } from 'tslib';
21
21
  import { KeyCode, PopupComponent, Events, RowNode } from 'ag-grid-community';
22
22
  import * as i2 from '@skyux/autonumeric';
23
23
  import { SkyAutonumericModule } from '@skyux/autonumeric';
@@ -172,13 +172,70 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.2", ngImpor
172
172
  }]
173
173
  }] } });
174
174
 
175
+ var _SkyAgGridTopScrollService_mutationObserver, _SkyAgGridTopScrollService_mutationObserverSvc;
176
+ // css class selectors
177
+ const HEADER_SELECTOR = '.ag-header';
178
+ const SCROLL_SELECTOR = '.ag-body-horizontal-scroll';
179
+ const SCROLL_VIEWPORT_SELECTOR = '.ag-body-horizontal-scroll-viewport';
180
+ const SCROLL_CONTAINER_SELECTOR = '.ag-body-horizontal-scroll-container';
181
+ class SkyAgGridTopScrollService {
182
+ constructor(mutationObserverSvc) {
183
+ _SkyAgGridTopScrollService_mutationObserver.set(this, void 0);
184
+ _SkyAgGridTopScrollService_mutationObserverSvc.set(this, void 0);
185
+ __classPrivateFieldSet(this, _SkyAgGridTopScrollService_mutationObserverSvc, mutationObserverSvc, "f");
186
+ }
187
+ ngOnDestroy() {
188
+ if (__classPrivateFieldGet(this, _SkyAgGridTopScrollService_mutationObserver, "f")) {
189
+ __classPrivateFieldGet(this, _SkyAgGridTopScrollService_mutationObserver, "f").disconnect();
190
+ }
191
+ }
192
+ appendTopScrollbarToGrid(elementRef) {
193
+ // get scrollbar elements
194
+ const scrollElement = elementRef.nativeElement.querySelector(SCROLL_SELECTOR);
195
+ const scrollViewportElement = elementRef.nativeElement.querySelector(SCROLL_VIEWPORT_SELECTOR);
196
+ const scrollContainerElement = elementRef.nativeElement.querySelector(SCROLL_CONTAINER_SELECTOR);
197
+ // create scrollbar clones
198
+ const cloneElement = scrollElement.cloneNode(true);
199
+ const cloneViewportElement = cloneElement.querySelector(SCROLL_VIEWPORT_SELECTOR);
200
+ const cloneContainerElement = cloneElement.querySelector(SCROLL_CONTAINER_SELECTOR);
201
+ // insert scrollbar clone
202
+ const headerElement = elementRef.nativeElement.querySelector(HEADER_SELECTOR);
203
+ headerElement.insertAdjacentElement('afterend', cloneElement);
204
+ // add event listeners to keep scroll position synchronized
205
+ scrollViewportElement.addEventListener('scroll', () => cloneViewportElement.scrollTo({ left: scrollViewportElement.scrollLeft }));
206
+ cloneViewportElement.addEventListener('scroll', () => scrollViewportElement.scrollTo({ left: cloneViewportElement.scrollLeft }));
207
+ __classPrivateFieldSet(this, _SkyAgGridTopScrollService_mutationObserver, __classPrivateFieldGet(this, _SkyAgGridTopScrollService_mutationObserverSvc, "f").create(() => {
208
+ // Maintain viewkeeper scroll position when the grid is resized, but update the scrollbar size
209
+ cloneElement.style.width = `${scrollElement.style.width}`;
210
+ cloneViewportElement.setAttribute('style', scrollViewportElement.getAttribute('style'));
211
+ cloneContainerElement.setAttribute('style', scrollContainerElement.getAttribute('style'));
212
+ }), "f");
213
+ // start observing the scroll elements for `style` attribute changes
214
+ __classPrivateFieldGet(this, _SkyAgGridTopScrollService_mutationObserver, "f").observe(scrollElement, {
215
+ attributeFilter: ['style'],
216
+ subtree: true,
217
+ });
218
+ }
219
+ }
220
+ _SkyAgGridTopScrollService_mutationObserver = new WeakMap(), _SkyAgGridTopScrollService_mutationObserverSvc = new WeakMap();
221
+ SkyAgGridTopScrollService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.2", ngImport: i0, type: SkyAgGridTopScrollService, deps: [{ token: i1.MutationObserverService }], target: i0.ɵɵFactoryTarget.Injectable });
222
+ SkyAgGridTopScrollService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.3.2", ngImport: i0, type: SkyAgGridTopScrollService, providedIn: 'root' });
223
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.2", ngImport: i0, type: SkyAgGridTopScrollService, decorators: [{
224
+ type: Injectable,
225
+ args: [{
226
+ providedIn: 'root',
227
+ }]
228
+ }], ctorParameters: function () { return [{ type: i1.MutationObserverService }]; } });
229
+
175
230
  /**
176
231
  * @internal
177
232
  */
178
233
  class SkyAgGridDataManagerAdapterDirective {
179
- constructor(changeDetector, dataManagerSvc) {
234
+ constructor(changeDetector, dataManagerSvc, elementRef, topScrollSvc) {
180
235
  this.changeDetector = changeDetector;
181
236
  this.dataManagerSvc = dataManagerSvc;
237
+ this.elementRef = elementRef;
238
+ this.topScrollSvc = topScrollSvc;
182
239
  this.ngUnsubscribe = new Subject();
183
240
  }
184
241
  ngAfterContentInit() {
@@ -257,6 +314,13 @@ class SkyAgGridDataManagerAdapterDirective {
257
314
  this.currentDataState = dataState;
258
315
  this.displayColumns(dataState);
259
316
  });
317
+ if (agGrid.gridOptions.context?.enableTopScroll) {
318
+ this.topScrollSvc.appendTopScrollbarToGrid(this.elementRef);
319
+ this.dataManagerSvc.setViewkeeperClasses(this.viewId, [
320
+ '.ag-header',
321
+ '.ag-body-horizontal-scroll',
322
+ ]);
323
+ }
260
324
  agGrid.api.sizeColumnsToFit();
261
325
  });
262
326
  agGrid.columnMoved
@@ -356,14 +420,14 @@ class SkyAgGridDataManagerAdapterDirective {
356
420
  agGrid.api.deselectAll();
357
421
  }
358
422
  }
359
- SkyAgGridDataManagerAdapterDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.2", ngImport: i0, type: SkyAgGridDataManagerAdapterDirective, deps: [{ token: i0.ChangeDetectorRef }, { token: i1$1.SkyDataManagerService }], target: i0.ɵɵFactoryTarget.Directive });
423
+ SkyAgGridDataManagerAdapterDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.2", ngImport: i0, type: SkyAgGridDataManagerAdapterDirective, deps: [{ token: i0.ChangeDetectorRef }, { token: i1$1.SkyDataManagerService }, { token: i0.ElementRef }, { token: SkyAgGridTopScrollService }], target: i0.ɵɵFactoryTarget.Directive });
360
424
  SkyAgGridDataManagerAdapterDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.3.2", type: SkyAgGridDataManagerAdapterDirective, selector: "[skyAgGridDataManagerAdapter]", inputs: { viewId: "viewId" }, queries: [{ propertyName: "agGridList", predicate: AgGridAngular, descendants: true }, { propertyName: "skyAgGridWrapperList", predicate: SkyAgGridWrapperComponent, descendants: true }], ngImport: i0 });
361
425
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.2", ngImport: i0, type: SkyAgGridDataManagerAdapterDirective, decorators: [{
362
426
  type: Directive,
363
427
  args: [{
364
428
  selector: '[skyAgGridDataManagerAdapter]',
365
429
  }]
366
- }], ctorParameters: function () { return [{ type: i0.ChangeDetectorRef }, { type: i1$1.SkyDataManagerService }]; }, propDecorators: { viewId: [{
430
+ }], ctorParameters: function () { return [{ type: i0.ChangeDetectorRef }, { type: i1$1.SkyDataManagerService }, { type: i0.ElementRef }, { type: SkyAgGridTopScrollService }]; }, propDecorators: { viewId: [{
367
431
  type: Input
368
432
  }], agGridList: [{
369
433
  type: ContentChildren,