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

Ag 11320 tree shakeable #7966

Closed
wants to merge 8 commits into from
Closed
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
@@ -1,9 +1,9 @@
{
"name": "@ag-grid-community/angular",
"version": "31.3.1",
"version": "31.3.2",
"license": "MIT",
"peerDependencies": {
"@ag-grid-community/core": "31.3.1",
"@ag-grid-community/core": ">= 31",
"@angular/common": ">= 14.0.0",
"@angular/core": ">= 14.0.0"
},
Expand Down
4 changes: 2 additions & 2 deletions community-modules/client-side-row-model/package.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"name": "@ag-grid-community/client-side-row-model",
"version": "31.3.1",
"version": "31.3.13",
"description": "Advanced Data Grid / Data Table supporting Javascript / Typescript / React / Angular / Vue",
"dependencies": {
"tslib": "^2.3.0",
"@ag-grid-community/core": "31.3.1"
"@ag-grid-community/core": ">= 31"
},
"main": "./dist/package/main.cjs.js",
"types": "./dist/types/src/main.d.ts",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,30 +1,29 @@
import {
Autowired,
Bean,
ChangedPath,
FilterManager,
RowNode,
BeanStub
BeanStub,
Optional
} from "@ag-grid-community/core";

@Bean("filterService")
export class FilterService extends BeanStub {

@Autowired('filterManager') private filterManager: FilterManager;
@Optional('filterManager') private filterManager?: FilterManager;

public filter(changedPath: ChangedPath): void {
const filterActive: boolean = this.filterManager.isChildFilterPresent();
this.filterNodes(filterActive, changedPath);
this.filterNodes(changedPath);
}

private filterNodes(filterActive: boolean, changedPath: ChangedPath): void {

private filterNodes(changedPath: ChangedPath): void {
const filterCallback = (rowNode: RowNode, includeChildNodes: boolean) => {
// recursively get all children that are groups to also filter
if (rowNode.hasChildren()) {

// result of filter for this node. when filtering tree data, includeChildNodes = true when parent passes
if (filterActive && !includeChildNodes) {
if (this.filterManager?.isChildFilterPresent() && !includeChildNodes) {
rowNode.childrenAfterFilter = rowNode.childrenAfterGroup!.filter(childNode => {
// a group is included in the result if it has any children of it's own.
// by this stage, the child groups are already filtered
Expand All @@ -33,7 +32,7 @@ export class FilterService extends BeanStub {
// both leaf level nodes and tree data nodes have data. these get added if
// the data passes the filter
const passBecauseDataPasses = childNode.data
&& this.filterManager.doesRowPassFilter({rowNode: childNode});
&& this.filterManager!.doesRowPassFilter({rowNode: childNode});

// note - tree data nodes pass either if a) they pass themselves or b) any children of that node pass

Expand All @@ -59,7 +58,7 @@ export class FilterService extends BeanStub {
// tree data filter traverses the hierarchy depth first and includes child nodes if parent passes
// filter, and parent nodes will be include if any children exist.

if (rowNode.childrenAfterGroup) {
if (this.filterManager && rowNode.childrenAfterGroup) {
for (let i = 0; i < rowNode.childrenAfterGroup.length; i++) {
const childNode = rowNode.childrenAfterGroup[i];

Expand Down
2 changes: 1 addition & 1 deletion community-modules/core/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@ag-grid-community/core",
"version": "31.3.1",
"version": "31.3.19",
"description": "Advanced Data Grid / Data Table supporting Javascript / Typescript / React / Angular / Vue",
"dependencies": {
"tslib": "^2.3.0"
Expand Down
3 changes: 2 additions & 1 deletion community-modules/core/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,8 @@
"platform": "browser",
"target": "es6",
"format": ["cjs", "esm"],
"sourcemap": true
"sourcemap": true,
"metafile": true
},
"configurations": {
"watch": {
Expand Down
6 changes: 2 additions & 4 deletions community-modules/core/src/columns/columnDefFactory.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
import { ColDef, ColGroupDef } from "../entities/colDef";
import { Column } from "../entities/column";
import { Bean } from "../context/context";
import { _deepCloneDefinition } from "../utils/object";
import { ProvidedColumnGroup } from "../entities/providedColumnGroup";
import { _deepCloneDefinition } from "../utils/object";

@Bean('columnDefFactory')
export class ColumnDefFactory {

public buildColumnDefs(cols: Column[], rowGroupColumns: Column[], pivotColumns: Column[]): (ColDef | ColGroupDef)[] {

console.log("ColumnDefFactory.buildColumnDefs");
const res: (ColDef | ColGroupDef)[] = [];

const colGroupDefs: {[id: string]: ColGroupDef} = {};
Expand Down
8 changes: 3 additions & 5 deletions community-modules/core/src/columns/columnModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ import { AnimationFrameService } from "../misc/animationFrameService";
import { SortController } from "../sortController";
import { _missingOrEmpty, _exists, _missing, _attrToBoolean, _attrToNumber } from '../utils/generic';
import { _camelCaseToHumanText } from '../utils/string';
import { ColumnDefFactory } from "./columnDefFactory";
import { _convertToMap } from '../utils/map';
import { _warnOnce } from '../utils/function';
import { CtrlsService } from '../ctrlsService';
Expand Down Expand Up @@ -129,7 +128,6 @@ export class ColumnModel extends BeanStub {
@Autowired('valueCache') private valueCache: ValueCache;
@Autowired('animationFrameService') private animationFrameService: AnimationFrameService;
@Autowired('sortController') private sortController: SortController;
@Autowired('columnDefFactory') private columnDefFactory: ColumnDefFactory;

@Optional('aggFuncService') private aggFuncService?: IAggFuncService;

Expand Down Expand Up @@ -1616,7 +1614,7 @@ export class ColumnModel extends BeanStub {
this.moveColumns([column], toIndex, source);
}

public getColumnDefs(): (ColDef | ColGroupDef)[] | undefined {
public getColumnDefsSorted(): Column[] | undefined {
if (!this.primaryColumns) { return; }

const cols = this.primaryColumns.slice();
Expand All @@ -1626,10 +1624,10 @@ export class ColumnModel extends BeanStub {
} else if (this.lastPrimaryOrder) {
cols.sort((a: Column, b: Column) => this.lastPrimaryOrder.indexOf(a) - this.lastPrimaryOrder.indexOf(b));
}

return this.columnDefFactory.buildColumnDefs(cols, this.rowGroupColumns, this.pivotColumns);
return cols;
}


// used by:
// + angularGrid -> for setting body width
// + rowController -> setting main row widths (when inserting and resizing)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@
import { BeanStub } from "../../context/beanStub";
import { Bean, PostConstruct } from "../../context/context";
import { ReadOnlyFloatingFilter } from "../../filter/floating/provided/readOnlyFloatingFilter";
import { DateFilter } from "../../filter/provided/date/dateFilter";
import { DateFloatingFilter } from "../../filter/provided/date/dateFloatingFilter";
import { DefaultDateComponent } from "../../filter/provided/date/defaultDateComponent";
import { NumberFilter } from "../../filter/provided/number/numberFilter";
import { NumberFloatingFilter } from "../../filter/provided/number/numberFloatingFilter";
import { TextFilter } from "../../filter/provided/text/textFilter";
import { TextFloatingFilter } from "../../filter/provided/text/textFloatingFilter";
import { HeaderComp } from "../../headerRendering/cells/column/headerComp";
import { SortIndicatorComp } from "../../headerRendering/cells/column/sortIndicatorComp";
Expand Down Expand Up @@ -37,7 +32,7 @@ import { AgMenuItemRenderer } from "../../widgets/agMenuItemRenderer";
@Bean('userComponentRegistry')
export class UserComponentRegistry extends BeanStub {

private agGridDefaults: { [key: string]: any } = {
private static agGridDefaults: { [key: string]: any } = {
//date
agDateInput: DefaultDateComponent,

Expand All @@ -48,8 +43,6 @@ export class UserComponentRegistry extends BeanStub {

//floating filters
agTextColumnFloatingFilter: TextFloatingFilter,
agNumberColumnFloatingFilter: NumberFloatingFilter,
agDateColumnFloatingFilter: DateFloatingFilter,
agReadOnlyFloatingFilter: ReadOnlyFloatingFilter,

// renderers
Expand All @@ -72,10 +65,6 @@ export class UserComponentRegistry extends BeanStub {
agCheckboxCellEditor: CheckboxCellEditor,

//filter
agTextColumnFilter: TextFilter,
agNumberColumnFilter: NumberFilter,
agDateColumnFilter: DateFilter,

//overlays
agLoadingOverlay: LoadingOverlayComponent,
agNoRowsOverlay: NoRowsOverlayComponent,
Expand Down Expand Up @@ -111,7 +100,7 @@ export class UserComponentRegistry extends BeanStub {
}
}

public registerDefaultComponent(name: string, component: any) {
public static registerDefaultComponent(name: string, component: any) {

if (this.agGridDefaults[name]) {
console.error(`Trying to overwrite a default component. You should call registerComponent`);
Expand Down Expand Up @@ -143,7 +132,7 @@ export class UserComponentRegistry extends BeanStub {
return createResult(jsComponent, isFwkComp);
}

const defaultComponent = this.agGridDefaults[name];
const defaultComponent = UserComponentRegistry.agGridDefaults[name];
if (defaultComponent) {
return createResult(defaultComponent, false);
}
Expand All @@ -161,7 +150,7 @@ export class UserComponentRegistry extends BeanStub {
private warnAboutMissingComponent(propertyName: string, componentName: string) {
const validComponents = [
// Don't include the old names / internals in potential suggestions
...Object.keys(this.agGridDefaults).filter(k => !['agCellEditor', 'agGroupRowRenderer', 'agSortIndicator'].includes(k)),
...Object.keys(UserComponentRegistry.agGridDefaults).filter(k => !['agCellEditor', 'agGroupRowRenderer', 'agSortIndicator'].includes(k)),
...Object.keys(this.jsComps)];
const suggestions = _fuzzySuggestions(componentName, validComponents, true, 0.8).values;

Expand Down
Loading