@zeedhi/teknisa-components-common 1.130.0 → 1.132.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.
Files changed (32) hide show
  1. package/coverage/clover.xml +1224 -1109
  2. package/coverage/coverage-final.json +48 -46
  3. package/coverage/lcov-report/index.html +22 -22
  4. package/coverage/lcov-report/tests/__helpers__/component-event-helper.ts.html +3 -3
  5. package/coverage/lcov-report/tests/__helpers__/flush-promises-helper.ts.html +1 -1
  6. package/coverage/lcov-report/tests/__helpers__/get-child-helper.ts.html +11 -11
  7. package/coverage/lcov-report/tests/__helpers__/index.html +1 -1
  8. package/coverage/lcov-report/tests/__helpers__/index.ts.html +4 -4
  9. package/coverage/lcov-report/tests/__helpers__/mock-created-helper.ts.html +3 -3
  10. package/coverage/lcov.info +2230 -1993
  11. package/dist/tek-components-common.esm.js +393 -195
  12. package/dist/tek-components-common.umd.js +393 -194
  13. package/package.json +2 -2
  14. package/tests/unit/components/tek-grid/grid-columns-button.spec.ts +123 -2
  15. package/tests/unit/components/tek-grid/grid-export-button.spec.ts +403 -0
  16. package/tests/unit/components/tek-grid/grid-filter-button.spec.ts +147 -4
  17. package/tests/unit/components/tek-grid/grid.spec.ts +182 -9
  18. package/tests/unit/components/tek-grid/layout_options.spec.ts +680 -25
  19. package/tests/unit/utils/object-comparison.spec.ts +89 -0
  20. package/types/components/index.d.ts +1 -0
  21. package/types/components/tek-grid/grid-columns-button.d.ts +2 -1
  22. package/types/components/tek-grid/grid-export-button.d.ts +19 -0
  23. package/types/components/tek-grid/grid-filter-button.d.ts +1 -0
  24. package/types/components/tek-grid/grid.d.ts +4 -0
  25. package/types/components/tek-grid/interfaces.d.ts +8 -0
  26. package/types/components/tek-grid/layout-options.d.ts +15 -0
  27. package/types/components/tek-tree-grid/tree-grid.d.ts +2 -0
  28. package/types/utils/grid-base/export-options/button-option.d.ts +3 -1
  29. package/types/utils/grid-base/export-options/multi-option.d.ts +3 -1
  30. package/types/utils/grid-base/grid-base.d.ts +1 -3
  31. package/types/utils/index.d.ts +1 -0
  32. package/types/utils/object-comparison.d.ts +3 -0
@@ -0,0 +1,89 @@
1
+ import {
2
+ areObjectsEqual,
3
+ cloneComparableValue,
4
+ normalizeComparableValue,
5
+ } from '../../../src/utils/object-comparison';
6
+
7
+ describe('object-comparison', () => {
8
+ describe('areObjectsEqual()', () => {
9
+ it('should compare objects with different key order as equal', () => {
10
+ expect(areObjectsEqual({ a: 1, b: 2 }, { b: 2, a: 1 })).toBeTruthy();
11
+ });
12
+
13
+ it('should compare nested object values', () => {
14
+ expect(areObjectsEqual(
15
+ { filter: { id: [{ value: '10' }] } },
16
+ { filter: { id: [{ value: '20' }] } },
17
+ )).toBeFalsy();
18
+ });
19
+
20
+ it('should preserve array order when comparing values', () => {
21
+ expect(areObjectsEqual([1, 2, 3], [3, 2, 1])).toBeFalsy();
22
+ expect(areObjectsEqual([1, 2, 3], [1, 2, 3])).toBeTruthy();
23
+ });
24
+
25
+ it('should ignore undefined properties', () => {
26
+ expect(areObjectsEqual(
27
+ { value: '10', optional: undefined },
28
+ { value: '10' },
29
+ )).toBeTruthy();
30
+ });
31
+
32
+ it('should compare empty-like values as equal', () => {
33
+ expect(areObjectsEqual(null, undefined)).toBeTruthy();
34
+ expect(areObjectsEqual('', undefined)).toBeTruthy();
35
+ expect(areObjectsEqual({}, [])).toBeTruthy();
36
+ expect(areObjectsEqual({ filter: {} }, {})).toBeTruthy();
37
+ expect(areObjectsEqual(
38
+ { filter: null, dynamicFilter: undefined },
39
+ { filter: '', dynamicFilter: [] },
40
+ )).toBeTruthy();
41
+ });
42
+
43
+ it('should compare primitive values without coercion', () => {
44
+ expect(areObjectsEqual(1, '1')).toBeFalsy();
45
+ expect(areObjectsEqual(false, '')).toBeFalsy();
46
+ expect(areObjectsEqual(0, '')).toBeFalsy();
47
+ });
48
+ });
49
+
50
+ describe('cloneComparableValue()', () => {
51
+ it('should clone nested values', () => {
52
+ const value = {
53
+ filter: {
54
+ id: [{ value: '10' }],
55
+ },
56
+ };
57
+
58
+ const clonedValue = cloneComparableValue(value);
59
+ value.filter.id[0].value = '20';
60
+
61
+ expect(clonedValue).toEqual({
62
+ filter: {
63
+ id: [{ value: '10' }],
64
+ },
65
+ });
66
+ });
67
+ });
68
+
69
+ describe('normalizeComparableValue()', () => {
70
+ it('should sort object keys and remove empty-like values', () => {
71
+ expect(normalizeComparableValue({
72
+ b: 2,
73
+ a: undefined,
74
+ d: {},
75
+ c: 3,
76
+ })).toEqual({
77
+ b: 2,
78
+ c: 3,
79
+ });
80
+ });
81
+
82
+ it('should normalize empty-like values to null', () => {
83
+ expect(normalizeComparableValue(undefined)).toBeNull();
84
+ expect(normalizeComparableValue('')).toBeNull();
85
+ expect(normalizeComparableValue({})).toBeNull();
86
+ expect(normalizeComparableValue([])).toBeNull();
87
+ });
88
+ });
89
+ });
@@ -26,6 +26,7 @@ export * from './tek-grid/grid';
26
26
  export * from './tek-grid/grid-column';
27
27
  export * from './tek-grid/grid-columns-button';
28
28
  export * from './tek-grid/grid-columns-button-controller';
29
+ export * from './tek-grid/grid-export-button';
29
30
  export * from './tek-grid/grid-filter-button';
30
31
  export * from './tek-grid/layout-options';
31
32
  export * from './tek-grid/filter-helper';
@@ -1,4 +1,5 @@
1
1
  import { IterableColumnsButton } from '@zeedhi/common';
2
+ import { TekGridColumnsButtonController } from './grid-columns-button-controller';
2
3
  import { ITekGridColumnsButton } from './interfaces';
3
4
  /**
4
5
  * Base class for TekGrid Columns Button component
@@ -6,7 +7,7 @@ import { ITekGridColumnsButton } from './interfaces';
6
7
  export declare class TekGridColumnsButton extends IterableColumnsButton implements ITekGridColumnsButton {
7
8
  hideGroups: boolean;
8
9
  constructor(props: ITekGridColumnsButton);
9
- onCreated(): void;
10
+ createController(): TekGridColumnsButtonController;
10
11
  private aggregationDataSet;
11
12
  getAggregationSelectData(): any[];
12
13
  }
@@ -0,0 +1,19 @@
1
+ import { ComponentRender, IComponentRender } from '@zeedhi/common';
2
+ import type { TekTreeGrid } from '../tek-tree-grid/tree-grid';
3
+ import type { TekGrid } from './grid';
4
+ import { ITekGridExportButton, ITekGridExportConfig } from './interfaces';
5
+ /**
6
+ * Base class for TekGrid export button/dropdown component.
7
+ */
8
+ export declare class TekGridExportButton extends ComponentRender implements ITekGridExportButton {
9
+ gridName?: string;
10
+ grid?: TekGrid | TekTreeGrid;
11
+ exportConfig?: ITekGridExportConfig[];
12
+ exportActions?: IComponentRender[];
13
+ constructor(props: ITekGridExportButton);
14
+ private getOption;
15
+ private getExportConfigButtons;
16
+ private loadChildren;
17
+ loadGrid(gridName?: string): void;
18
+ onCreated(): void;
19
+ }
@@ -15,6 +15,7 @@ export declare class TekGridFilterButton extends Button implements ITekGridFilte
15
15
  constructor(props: ITekGridFilterButton);
16
16
  loadGrid(gridName?: string): void;
17
17
  click(event?: Event): void;
18
+ onCreated(): void;
18
19
  private loadFilterValues;
19
20
  hideFilterModal(): void;
20
21
  destroyFilterModal(): void;
@@ -3,6 +3,7 @@ import { Datasource, IDictionary, IEventParam } from '@zeedhi/core';
3
3
  import { ITekGridAtoms } from '../../utils';
4
4
  import { TekGridColumn } from './grid-column';
5
5
  import { IGroupedData, IModalFilterProps, ITekGrid, ITekGridColumn, ITekGridEvents, ITekGridExportConfig, ITekGridGroup, ITekGridGroupFooter } from './interfaces';
6
+ import type { TekGridFilterButton } from './grid-filter-button';
6
7
  import { TekGridLayoutOptions } from './layout-options';
7
8
  export declare class TekGrid extends GridEditable implements ITekGrid {
8
9
  title: string;
@@ -178,6 +179,8 @@ export declare class TekGrid extends GridEditable implements ITekGrid {
178
179
  isGrouped(): number | false;
179
180
  navigateDown(params?: any): void;
180
181
  navigateUp(params?: any): void;
182
+ navigateDatasource(up: boolean): void;
183
+ private navigateGroupedDatasource;
181
184
  directionalLeft(params: IEventParam<any>): void;
182
185
  directionalRight(params: IEventParam<any>): void;
183
186
  /**
@@ -206,6 +209,7 @@ export declare class TekGrid extends GridEditable implements ITekGrid {
206
209
  selectGroupClick(row: IDictionary<any>, isSelected: boolean, event: Event, element: HTMLElement): void;
207
210
  getAtomInstance<T>(key: keyof ITekGridAtoms): T;
208
211
  getFilterInputs(columnName?: string): Input[];
212
+ registerFilterButton(filterButton: TekGridFilterButton): void;
209
213
  isColumnSearchable(column: TekGridColumn): boolean;
210
214
  getColumn(name: string): TekGridColumn;
211
215
  /**
@@ -117,6 +117,7 @@ export interface ITekGridLayoutColumn {
117
117
  }
118
118
  export interface ITekGridLayoutOptions extends IComponentRender {
119
119
  events?: ITekGridLayoutOptionsEvents;
120
+ gridName?: string;
120
121
  }
121
122
  export declare type IFilterRelation = 'AND' | 'OR';
122
123
  export declare type IFilterOperation = 'CONTAINS' | 'NOT_CONTAINS' | 'EQUALS' | 'NOT_EQUALS' | 'GREATER_THAN' | 'LESS_THAN' | 'GREATER_THAN_EQUALS' | 'LESS_THAN_EQUALS' | 'IN' | 'NOT_IN' | 'BETWEEN';
@@ -138,6 +139,7 @@ export interface ITekGridColumn extends IGridColumnEditable {
138
139
  storeData?: boolean;
139
140
  }
140
141
  export interface ITekGridColumnsButton extends IIterableColumnsButton {
142
+ gridName?: string;
141
143
  hideGroups?: boolean;
142
144
  }
143
145
  export interface ITekGridFilterButton extends IButton {
@@ -145,6 +147,12 @@ export interface ITekGridFilterButton extends IButton {
145
147
  grid?: TekGrid | TekTreeGrid;
146
148
  showCheckboxAll?: boolean;
147
149
  }
150
+ export interface ITekGridExportButton extends IComponentRender {
151
+ gridName?: string;
152
+ grid?: TekGrid | TekTreeGrid;
153
+ exportConfig?: ITekGridExportConfig[];
154
+ exportActions?: IComponentRender[];
155
+ }
148
156
  export interface ITekGridGroup {
149
157
  column: ITekGridColumn;
150
158
  name: string;
@@ -3,6 +3,7 @@ import { IDictionary } from '@zeedhi/core';
3
3
  import { IDynamicFilterItem, ITekGridLayoutColumn } from '..';
4
4
  import { ITekGridLayoutOptions, ITekGridLayout, ITekGridLayoutOptionsEvents } from './interfaces';
5
5
  export declare class TekGridLayoutOptions extends ComponentRender implements ITekGridLayoutOptions {
6
+ gridName?: string;
6
7
  currentLayoutName: string;
7
8
  layoutEdited: boolean;
8
9
  layouts: IDictionary<ITekGridLayout>;
@@ -15,11 +16,24 @@ export declare class TekGridLayoutOptions extends ComponentRender implements ITe
15
16
  originalDatasourceFilter: IDictionary<any>;
16
17
  events: ITekGridLayoutOptionsEvents;
17
18
  grid: Grid;
19
+ private changeLayoutEventGrid?;
20
+ private originalLayoutSnapshot?;
21
+ constructor(props: ITekGridLayoutOptions);
18
22
  private getParentGrid;
23
+ loadGrid(gridName?: string): Grid;
24
+ private onGridChangeLayout;
25
+ private registerChangeLayoutEvent;
19
26
  onMounted(element: HTMLElement): Promise<void>;
20
27
  private checkLayoutsData;
21
28
  protected loadLayoutsInfo(): Promise<any>;
22
29
  getHelperValue(column: any): string | (string | undefined)[] | undefined;
30
+ getLayoutColumnSnapshot(column: any, isVisible?: boolean): ITekGridLayoutColumn;
31
+ private getCurrentLayoutSnapshot;
32
+ private getBaselineLayoutSnapshot;
33
+ private getOriginalLayoutSnapshot;
34
+ hasLayoutChanges(): boolean;
35
+ getCurrentLayout(): ITekGridLayout;
36
+ getLayout(name?: string): ITekGridLayout | undefined;
23
37
  layoutHasFilter(layout: string | ITekGridLayout): number | false;
24
38
  private confirmFilterModal?;
25
39
  private newLayoutValue?;
@@ -31,6 +45,7 @@ export declare class TekGridLayoutOptions extends ComponentRender implements ITe
31
45
  private saveLayouts;
32
46
  deleteLayout(name: string): void;
33
47
  updateLayout(name: string, layout: ITekGridLayout): void;
48
+ updateLayout(name?: string): void;
34
49
  updateDefaultLayout(layout: ITekGridLayout): void;
35
50
  private fixColumns;
36
51
  }
@@ -3,6 +3,7 @@ import { Datasource, IDictionary } from '@zeedhi/core';
3
3
  import { ITekGridAtoms } from '../../utils';
4
4
  import { TekGridColumn } from '../tek-grid/grid-column';
5
5
  import { IModalFilterProps, ITekGridColumn, ITekGridEvents, ITekGridExportConfig } from '../tek-grid/interfaces';
6
+ import type { TekGridFilterButton } from '../tek-grid/grid-filter-button';
6
7
  import { ITekTreeGrid } from './interfaces';
7
8
  import { TekGridLayoutOptions } from '..';
8
9
  export declare class TekTreeGrid extends TreeGridEditable implements ITekTreeGrid {
@@ -98,5 +99,6 @@ export declare class TekTreeGrid extends TreeGridEditable implements ITekTreeGri
98
99
  rowClick(row: IDictionary<any>, event: Event, element: HTMLElement): void;
99
100
  getAtomInstance<T>(key: keyof ITekGridAtoms): T;
100
101
  getFilterInputs(columnName?: string): import("@zeedhi/common").Input[];
102
+ registerFilterButton(filterButton: TekGridFilterButton): void;
101
103
  getColumn(name: string): TekGridColumn;
102
104
  }
@@ -1,4 +1,6 @@
1
- import { ITekGridExportConfig, TekGrid, TekTreeGrid } from '../../../components';
1
+ import type { TekTreeGrid } from '../../../components/tek-tree-grid/tree-grid';
2
+ import type { ITekGridExportConfig } from '../../../components/tek-grid/interfaces';
3
+ import type { TekGrid } from '../../../components/tek-grid/grid';
2
4
  import { IExportOption } from './interfaces';
3
5
  export declare class ButtonOption implements IExportOption {
4
6
  private config;
@@ -1,5 +1,7 @@
1
1
  import { IRow } from '@zeedhi/common';
2
- import { ITekGridExportConfig, TekGrid, TekTreeGrid } from '../../../components';
2
+ import type { TekTreeGrid } from '../../../components/tek-tree-grid/tree-grid';
3
+ import type { ITekGridExportConfig } from '../../../components/tek-grid/interfaces';
4
+ import type { TekGrid } from '../../../components/tek-grid/grid';
3
5
  import { IExportOption } from './interfaces';
4
6
  export declare class MultiOption implements IExportOption {
5
7
  private config;
@@ -21,11 +21,8 @@ export interface ITekGridAtoms {
21
21
  }
22
22
  export declare class GridBase {
23
23
  private grid;
24
- private exportConfigButtons;
25
24
  private defaultToolbar;
26
25
  constructor(grid: TekGrid | TekTreeGrid);
27
- private getOption;
28
- private getExportConfigButtons;
29
26
  private initializeDefaultToolbarItems;
30
27
  private processUserToolbarItems;
31
28
  /**
@@ -39,6 +36,7 @@ export declare class GridBase {
39
36
  createToolbarProps(): IComponentRender[];
40
37
  filterButton?: TekGridFilterButton;
41
38
  private loadFilterButton;
39
+ registerFilterButton(filterButton: TekGridFilterButton): void;
42
40
  private hideButtonClick;
43
41
  private addButtonClick;
44
42
  private deleteButtonClick;
@@ -4,3 +4,4 @@ export * from './grid-base/grid-controller';
4
4
  export * from './grid-base/export-options';
5
5
  export * from './config/config';
6
6
  export * from './extract-properties';
7
+ export * from './object-comparison';
@@ -0,0 +1,3 @@
1
+ export declare function cloneComparableValue<T>(value: T): T;
2
+ export declare function normalizeComparableValue(value: any): any;
3
+ export declare function areObjectsEqual(first: any, second: any): boolean;