Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(components/ag-grid): support AG Grid 32.2 #2759

Merged
merged 6 commits into from
Sep 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
inject,
} from '@angular/core';
import { SkySkipLinkService } from '@skyux/a11y';
import { FontLoadingService } from '@skyux/storybook';
import { FontLoadingService } from '@skyux/storybook/font-loading';

import { BehaviorSubject, Subscription } from 'rxjs';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Component, Input, OnDestroy, inject } from '@angular/core';
import { SkyModalInstance, SkyModalService } from '@skyux/modals';
import { FontLoadingService } from '@skyux/storybook';
import { FontLoadingService } from '@skyux/storybook/font-loading';

import { SummaryActionBarModalComponent } from './summary-action-bar-modal.component';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ import {
inject,
} from '@angular/core';
import { SkyAgGridModule, SkyAgGridService, SkyCellType } from '@skyux/ag-grid';
import { FontLoadingService, PreviewWrapperModule } from '@skyux/storybook';
import { PreviewWrapperModule } from '@skyux/storybook/components';
import { FontLoadingService } from '@skyux/storybook/font-loading';
import {
SkyTheme,
SkyThemeMode,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import {
SkyCellType,
} from '@skyux/ag-grid';
import { SkyDockLocation, SkyDockService } from '@skyux/core';
import { FontLoadingService } from '@skyux/storybook';
import { FontLoadingService } from '@skyux/storybook/font-loading';
import { SkyThemeService, SkyThemeSettings } from '@skyux/theme';

import { ColDef, GridOptions, RowSelectedEvent } from 'ag-grid-community';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { RouterModule, Routes } from '@angular/router';
import { SkyAgGridModule } from '@skyux/ag-grid';
import { SkyBackToTopModule } from '@skyux/layout';
import { SkyDropdownModule } from '@skyux/popovers';
import { PreviewWrapperModule } from '@skyux/storybook';
import { PreviewWrapperModule } from '@skyux/storybook/components';
import { SkyThemeModule } from '@skyux/theme';

import { AgGridModule } from 'ag-grid-angular';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
ViewEncapsulation,
} from '@angular/core';
import { SkyAgGridService, SkyCellType } from '@skyux/ag-grid';
import { FontLoadingService } from '@skyux/storybook';
import { FontLoadingService } from '@skyux/storybook/font-loading';
import {
SkyTheme,
SkyThemeMode,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { CommonModule } from '@angular/common';
import { NgModule } from '@angular/core';
import { RouterModule, Routes } from '@angular/router';
import { SkyAgGridModule } from '@skyux/ag-grid';
import { PreviewWrapperModule } from '@skyux/storybook';
import { PreviewWrapperModule } from '@skyux/storybook/components';
import { SkyThemeModule } from '@skyux/theme';

import { AgGridModule } from 'ag-grid-angular';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import {
SkyDataManagerService,
SkyDataManagerState,
} from '@skyux/data-manager';
import { FontLoadingService } from '@skyux/storybook';
import { FontLoadingService } from '@skyux/storybook/font-loading';

import { FirstDataRenderedEvent, GridOptions } from 'ag-grid-community';
import {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Component, inject } from '@angular/core';
import { FontLoadingService } from '@skyux/storybook';
import { FontLoadingService } from '@skyux/storybook/font-loading';

import { delay } from 'rxjs';

Expand Down
2 changes: 1 addition & 1 deletion apps/e2e/core-storybook/src/app/affix/affix.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {
SkyAffixPosition,
SkyAffixVerticalAlignment,
} from '@skyux/core';
import { FontLoadingService } from '@skyux/storybook';
import { FontLoadingService } from '@skyux/storybook/font-loading';

@Component({
selector: 'app-affix',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {
SkyDataManagerService,
SkyDataManagerState,
} from '@skyux/data-manager';
import { FontLoadingService } from '@skyux/storybook';
import { FontLoadingService } from '@skyux/storybook/font-loading';

import { BehaviorSubject, Subscription } from 'rxjs';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {
SkyDateRangeCalculation,
SkyDateRangeCalculatorId,
} from '@skyux/datetime';
import { FontLoadingService } from '@skyux/storybook';
import { FontLoadingService } from '@skyux/storybook/font-loading';

@Component({
selector: 'app-date-range-picker',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {
SkyDatepickerCalendarChange,
SkyDatepickerCustomDate,
} from '@skyux/datetime';
import { FontLoadingService } from '@skyux/storybook';
import { FontLoadingService } from '@skyux/storybook/font-loading';

import { of } from 'rxjs';
import { delay, distinctUntilChanged } from 'rxjs/operators';
Expand Down
2 changes: 1 addition & 1 deletion apps/e2e/errors-storybook/src/app/error/error.component.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { AfterViewInit, Component, OnDestroy, inject } from '@angular/core';
import { SkyErrorType } from '@skyux/errors';
import { FontLoadingService } from '@skyux/storybook';
import { FontLoadingService } from '@skyux/storybook/font-loading';

import { BehaviorSubject, Subscription } from 'rxjs';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {
SkyFlyoutPermalink,
SkyFlyoutService,
} from '@skyux/flyout';
import { FontLoadingService } from '@skyux/storybook';
import { FontLoadingService } from '@skyux/storybook/font-loading';

import { BehaviorSubject, Subscription } from 'rxjs';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { AfterViewInit, Component, OnDestroy, inject } from '@angular/core';
import { FormBuilder, FormControl, FormGroup } from '@angular/forms';
import { FontLoadingService } from '@skyux/storybook';
import { FontLoadingService } from '@skyux/storybook/font-loading';

import { BehaviorSubject, Subscription } from 'rxjs';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { AfterViewInit, Component, OnDestroy, inject } from '@angular/core';
import { SkyIconManifestGlyph, getIconManifest } from '@skyux/icons';
import { FontLoadingService } from '@skyux/storybook';
import { FontLoadingService } from '@skyux/storybook/font-loading';

import { BehaviorSubject, Subscription } from 'rxjs';

Expand Down
2 changes: 1 addition & 1 deletion apps/e2e/layout-storybook/src/app/box/box.component.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Component, inject } from '@angular/core';
import { FontLoadingService } from '@skyux/storybook';
import { FontLoadingService } from '@skyux/storybook/font-loading';

@Component({
selector: 'app-box',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { AfterViewInit, Component, OnDestroy, inject } from '@angular/core';
import { FontLoadingService } from '@skyux/storybook';
import { FontLoadingService } from '@skyux/storybook/font-loading';

import { BehaviorSubject, Subscription } from 'rxjs';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Component, inject } from '@angular/core';
import { FontLoadingService } from '@skyux/storybook';
import { FontLoadingService } from '@skyux/storybook/font-loading';

@Component({
selector: 'app-autocomplete',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {
UntypedFormGroup,
Validators,
} from '@angular/forms';
import { FontLoadingService } from '@skyux/storybook';
import { FontLoadingService } from '@skyux/storybook/font-loading';

@Component({
selector: 'app-country-field',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Component, Input, inject } from '@angular/core';
import { FormBuilder, FormControl, FormGroup } from '@angular/forms';
import { FontLoadingService } from '@skyux/storybook';
import { FontLoadingService } from '@skyux/storybook/font-loading';

export interface Names {
name: string;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Component, inject } from '@angular/core';
import { FontLoadingService } from '@skyux/storybook';
import { FontLoadingService } from '@skyux/storybook/font-loading';

@Component({
selector: 'app-search',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { AfterViewInit, Component, OnDestroy, inject } from '@angular/core';
import { FontLoadingService } from '@skyux/storybook';
import { FontLoadingService } from '@skyux/storybook/font-loading';

import { BehaviorSubject, Subscription } from 'rxjs';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { AfterViewInit, Component, OnDestroy, inject } from '@angular/core';
import { FontLoadingService } from '@skyux/storybook';
import { FontLoadingService } from '@skyux/storybook/font-loading';

import { BehaviorSubject, Subscription } from 'rxjs';

Expand Down
4 changes: 2 additions & 2 deletions libs/components/ag-grid/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@
"@skyux/lookup": "0.0.0-PLACEHOLDER",
"@skyux/popovers": "0.0.0-PLACEHOLDER",
"@skyux/theme": "0.0.0-PLACEHOLDER",
"ag-grid-angular": "^32.1.0",
"ag-grid-community": "^32.1.0"
"ag-grid-angular": "^32.2.0",
"ag-grid-community": "^32.2.0"
},
"dependencies": {
"tslib": "^2.6.3"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,16 @@ describe('SkyAgGridService', () => {
});

it('should set icons for modern theme', () => {
const options = agGridService.getGridOptions({
gridOptions: {},
});

expect(typeof options.icons?.['sortDescending']).toBe('function');

expect((options.icons?.['sortDescending'] as () => string)()).toBe(
`<i aria-hidden="true" class="fa fa-caret-down"></i>`,
);

// Trigger change to modern theme
mockThemeSvc.settingsChange.next({
currentSettings: new SkyThemeSettings(
Expand All @@ -217,20 +227,18 @@ describe('SkyAgGridService', () => {
mockThemeSvc.settingsChange.getValue().currentSettings,
});

const modernThemeGridOptions = agGridService.getGridOptions({
gridOptions: {},
});

expect(typeof modernThemeGridOptions.icons?.['sortDescending']).toBe(
'function',
expect((options.icons?.['sortDescending'] as () => string)()).toBe(
`<i aria-hidden="true" class="sky-i-chevron-down"></i>`,
);
expect(
(modernThemeGridOptions.icons?.['sortDescending'] as () => string)(),
).toBe(`<i aria-hidden="true" class="sky-i-chevron-down"></i>`);
});

it('should unsubscribe from the theme service when destroyed', () => {
expect(agGridService.getHeaderHeight()).toBe(37);
expect(
agGridService.getGridOptions({ gridOptions: {} }).columnTypes?.[
SkyCellType.Date
].minWidth,
).toBe(160);

// Trigger change to modern theme
mockThemeSvc.settingsChange.next({
Expand All @@ -244,6 +252,11 @@ describe('SkyAgGridService', () => {

// Get new grid options after theme change
expect(agGridService.getHeaderHeight()).toBe(60);
expect(
agGridService.getGridOptions({ gridOptions: {} }).columnTypes?.[
SkyCellType.Date
].minWidth,
).toBe(180);

// Destroy subscription
agGridService.ngOnDestroy();
Expand All @@ -260,6 +273,11 @@ describe('SkyAgGridService', () => {

// Get new grid options after theme change, but expect heights have not changed
expect(agGridService.getHeaderHeight()).toBe(60);
expect(
agGridService.getGridOptions({ gridOptions: {} }).columnTypes?.[
SkyCellType.Date
].minWidth,
).toBe(180);
});

it('should not overwrite default component definitions', () => {
Expand Down
4 changes: 4 additions & 0 deletions libs/components/ag-grid/src/lib/styles/_base.scss
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,10 @@ $modernDarkThemeCompact: map.merge($modernDarkThemeBase, $modernThemeCompact);
outline-style: solid;
outline-offset: 0;
}

.ag-ltr .ag-header-cell-resize {
right: -4px;
}
}

.ag-theme-sky-data-grid-default,
Expand Down
28 changes: 27 additions & 1 deletion libs/components/ag-grid/src/lib/styles/_modern.scss
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,19 @@
--ag-header-column-resize-handle-width: 3px;
}

.ag-header-cell.sky-ag-grid-header-resizable.ag-column-resizing
.ag-header-cell-resize::after {
height: 100%;
top: 0;
}

.ag-header-cell.sky-ag-grid-header-resizable:not(.ag-column-resizing)
> .ag-header-cell-resize:hover {
&::after {
position: relative;
left: 2px;
top: 0;
height: 100%;
}
}

Expand All @@ -58,9 +66,19 @@

@for $i from 1 through 100 {
.ag-root:has(
.ag-header-cell.sky-ag-grid-header-resizable:nth-child(#{$i})
.ag-header-cell.sky-ag-grid-header-resizable:not(
.ag-column-resizing
):nth-child(#{$i})
> .ag-header-cell-resize:hover
) {
.ag-header-cell.ag-floating-filter:nth-child(#{$i})::before {
top: 0;
--ag-header-column-separator-color: var(
--sky-text-color-action-primary
);
--ag-header-column-separator-height: 100%;
--ag-header-column-separator-width: 1px;
}
.ag-cell:nth-child(#{$i}) {
--ag-cell-horizontal-border: 1px
solid
Expand All @@ -73,6 +91,14 @@
#{$i}
)
) {
.ag-header-cell.ag-floating-filter:nth-child(#{$i})::before {
top: 0;
--ag-header-column-separator-color: var(
--sky-text-color-action-primary
);
--ag-header-column-separator-height: 100%;
--ag-header-column-separator-width: 3px;
}
.ag-cell:nth-child(#{$i}) {
--ag-cell-horizontal-border: 3px
solid
Expand Down
4 changes: 2 additions & 2 deletions libs/components/packages/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,8 @@
"@skyux/tiles": "0.0.0-PLACEHOLDER",
"@skyux/toast": "0.0.0-PLACEHOLDER",
"@skyux/validation": "0.0.0-PLACEHOLDER",
"ag-grid-angular": "^32.1.0",
"ag-grid-community": "^32.1.0",
"ag-grid-angular": "^32.2.0",
"ag-grid-community": "^32.2.0",
"ag-grid-enterprise": "^32.1.0",
"autonumeric": "^4.10.5"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ interface TestSetup {
schematic: (options: Schema) => Rule;
}

const UPDATE_TO_VERSION = '32.1.0';
const UPDATE_TO_VERSION = '32.2.0';
const UPDATE_TO_MIGRATION = '32.0.7';

describe('ag-grid-migrate.schematic', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { platform } from 'os';
import { Schema } from './schema';

const AG_GRID_MIGRATION = '32.0.7';
const AG_GRID_VERSION = '32.1.0';
const AG_GRID_VERSION = '32.2.0';

function getStartingVersion(sourceRoot: string): string | undefined {
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import fs from 'fs-extra';
import { joinPathFragments } from 'nx/src/utils/path';
import { workspaceRoot } from 'nx/src/utils/workspace-root';

const UPDATE_TO_VERSION = '32.1.0';
const UPDATE_TO_VERSION = '32.2.0';

describe('ag-grid.schematic', () => {
const runner = new SchematicTestRunner(
Expand Down
Loading
Loading