@zeedhi/teknisa-components-common 3.0.4 → 3.2.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 (134) hide show
  1. package/dist/teknisa-components-common.es.js +3536 -0
  2. package/dist/types/components/index.d.ts +2 -0
  3. package/dist/types/components/tek-breadcrumb-header/breadcrumb-header.d.ts +2 -2
  4. package/dist/types/components/tek-breadcrumb-header/interfaces.d.ts +1 -1
  5. package/dist/types/components/tek-datasource/tek-memory-datasource.d.ts +1 -21
  6. package/dist/types/components/tek-datasource/tek-rest-datasource.d.ts +6 -30
  7. package/dist/types/components/tek-grid/filter-helper.d.ts +2 -2
  8. package/dist/types/components/tek-grid/grid-filter-button.d.ts +1 -0
  9. package/dist/types/components/tek-grid/grouped-data-manager.d.ts +8 -1
  10. package/dist/types/components/tek-grid/grouped-data-navigator.d.ts +12 -0
  11. package/dist/types/components/tek-grid/index.d.ts +1 -1
  12. package/dist/types/components/tek-grid/interfaces.d.ts +8 -1
  13. package/dist/types/components/tek-grid/tek-grid-controller.d.ts +19 -17
  14. package/dist/types/components/tek-grid/tek-grid-data-editor.d.ts +11 -0
  15. package/dist/types/components/tek-grid/tek-grid-toolbar-provider/export-options/multi-option.d.ts +1 -1
  16. package/dist/types/components/tek-grid/tek-grid-toolbar-provider/tek-grid-toolbar-provider.d.ts +8 -1
  17. package/dist/types/components/tek-grid/tek-grid.d.ts +24 -6
  18. package/dist/types/components/tek-loading/interfaces.d.ts +6 -0
  19. package/dist/types/components/tek-loading/loading.d.ts +16 -0
  20. package/dist/types/components/tek-user-info/TekUserInfoController.d.ts +4 -4
  21. package/dist/types/utils/extract-properties/extract-properties.d.ts +1 -0
  22. package/dist/types/utils/index.d.ts +2 -0
  23. package/dist/types/utils/report-filter/report-filter.d.ts +12 -0
  24. package/package.json +32 -12
  25. package/coverage/clover.xml +0 -6
  26. package/coverage/coverage-final.json +0 -1
  27. package/coverage/lcov-report/base.css +0 -224
  28. package/coverage/lcov-report/block-navigation.js +0 -87
  29. package/coverage/lcov-report/favicon.png +0 -0
  30. package/coverage/lcov-report/index.html +0 -101
  31. package/coverage/lcov-report/prettify.css +0 -1
  32. package/coverage/lcov-report/prettify.js +0 -2
  33. package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
  34. package/coverage/lcov-report/sorter.js +0 -210
  35. package/coverage/lcov.info +0 -0
  36. package/dist/teknisa-components-common.js +0 -3802
  37. package/dist/teknisa-components-common.min.js +0 -3802
  38. package/dist/types/components/tek-grid/grouped-view-navigator.d.ts +0 -14
  39. package/dist/types/error/delete-rows-error.d.ts +0 -6
  40. package/environments.json +0 -14
  41. package/jest.config.js +0 -1
  42. package/src/components/index.ts +0 -101
  43. package/src/components/tek-breadcrumb-header/breadcrumb-header.ts +0 -29
  44. package/src/components/tek-breadcrumb-header/interfaces.ts +0 -7
  45. package/src/components/tek-datasource/index.ts +0 -3
  46. package/src/components/tek-datasource/interfaces.ts +0 -36
  47. package/src/components/tek-datasource/tek-memory-datasource.ts +0 -314
  48. package/src/components/tek-datasource/tek-rest-datasource.ts +0 -224
  49. package/src/components/tek-grid/columns-searcher.ts +0 -22
  50. package/src/components/tek-grid/dynamic-filter-datasource-factory.ts +0 -20
  51. package/src/components/tek-grid/filter-helper.ts +0 -20
  52. package/src/components/tek-grid/grid-filter-button.ts +0 -419
  53. package/src/components/tek-grid/grouped-data-manager.ts +0 -448
  54. package/src/components/tek-grid/grouped-data-selector.ts +0 -40
  55. package/src/components/tek-grid/grouped-view-navigator.ts +0 -84
  56. package/src/components/tek-grid/index.ts +0 -18
  57. package/src/components/tek-grid/interfaces.ts +0 -329
  58. package/src/components/tek-grid/keymap-grouped.ts +0 -20
  59. package/src/components/tek-grid/layout-options.ts +0 -248
  60. package/src/components/tek-grid/tek-grid-column.ts +0 -193
  61. package/src/components/tek-grid/tek-grid-columns-button/tek-grid-columns-button-controller.ts +0 -28
  62. package/src/components/tek-grid/tek-grid-columns-button/tek-grid-columns-button.ts +0 -38
  63. package/src/components/tek-grid/tek-grid-controller.ts +0 -140
  64. package/src/components/tek-grid/tek-grid-events.ts +0 -105
  65. package/src/components/tek-grid/tek-grid-toolbar-provider/export-options/button-option.ts +0 -26
  66. package/src/components/tek-grid/tek-grid-toolbar-provider/export-options/index.ts +0 -3
  67. package/src/components/tek-grid/tek-grid-toolbar-provider/export-options/interfaces.ts +0 -6
  68. package/src/components/tek-grid/tek-grid-toolbar-provider/export-options/multi-option.ts +0 -85
  69. package/src/components/tek-grid/tek-grid-toolbar-provider/index.ts +0 -2
  70. package/src/components/tek-grid/tek-grid-toolbar-provider/tek-grid-toolbar-provider.ts +0 -365
  71. package/src/components/tek-grid/tek-grid.ts +0 -1118
  72. package/src/components/tek-user-info/TekUserInfoController.ts +0 -87
  73. package/src/components/tek-user-info/interfaces.ts +0 -21
  74. package/src/components/tek-user-info/tek-user-info-list.ts +0 -64
  75. package/src/components/tek-user-info/tek-user-info.ts +0 -337
  76. package/src/error/tek-grid-delete-rows-error.ts +0 -15
  77. package/src/error/teknisa-common-error.ts +0 -8
  78. package/src/utils/config/config.ts +0 -8
  79. package/src/utils/index.ts +0 -3
  80. package/src/utils/is-filled-object/is-filled-object.ts +0 -5
  81. package/src/utils/is-nil.ts +0 -3
  82. package/tests/__helpers__/component-event-helper.ts +0 -5
  83. package/tests/__helpers__/flush-promises-helper.ts +0 -3
  84. package/tests/__helpers__/get-child-helper.ts +0 -27
  85. package/tests/__helpers__/index.ts +0 -3
  86. package/tests/__helpers__/mock-created-helper.ts +0 -12
  87. package/tests/__mocks__/@zeedhi/core/i18n.js +0 -75
  88. package/tests/__mocks__/@zeedhi/core.js +0 -5
  89. package/tests/unit/components/crud/crud-add-button.spec.ts +0 -56
  90. package/tests/unit/components/crud/crud-button.spec.ts +0 -94
  91. package/tests/unit/components/crud/crud-cancel-button.spec.ts +0 -91
  92. package/tests/unit/components/crud/crud-delete-button.spec.ts +0 -122
  93. package/tests/unit/components/crud/crud-form.spec.ts +0 -165
  94. package/tests/unit/components/crud/crud-save-button.spec.ts +0 -118
  95. package/tests/unit/components/tek-breadcrumb-header/tek-breadcrumb-header.spec.ts +0 -42
  96. package/tests/unit/components/tek-card-title/CardTitle.spec.ts +0 -34
  97. package/tests/unit/components/tek-datasource/memory-datasource.spec.ts +0 -460
  98. package/tests/unit/components/tek-datasource/rest-datasource.spec.ts +0 -362
  99. package/tests/unit/components/tek-drag-grid/tek-drag-grid.spec.ts +0 -112
  100. package/tests/unit/components/tek-grid/button-option.spec.ts +0 -49
  101. package/tests/unit/components/tek-grid/columns-searcher.spec.ts +0 -112
  102. package/tests/unit/components/tek-grid/dynamic-filter-datasource-factory.spec.ts +0 -90
  103. package/tests/unit/components/tek-grid/filter-helper.spec.ts +0 -52
  104. package/tests/unit/components/tek-grid/grid-filter-button.spec.ts +0 -842
  105. package/tests/unit/components/tek-grid/grouped-data-manager.spec.ts +0 -593
  106. package/tests/unit/components/tek-grid/grouped-data-selector.spec.ts +0 -136
  107. package/tests/unit/components/tek-grid/grouped-view-navigator.spec.ts +0 -244
  108. package/tests/unit/components/tek-grid/keymap-grouped.spec.ts +0 -20
  109. package/tests/unit/components/tek-grid/layout-options.spec.ts +0 -1020
  110. package/tests/unit/components/tek-grid/multi-option.spec.ts +0 -139
  111. package/tests/unit/components/tek-grid/tek-grid-column.spec.ts +0 -312
  112. package/tests/unit/components/tek-grid/tek-grid-columns-button.spec.ts +0 -228
  113. package/tests/unit/components/tek-grid/tek-grid-controller.spec.ts +0 -253
  114. package/tests/unit/components/tek-grid/tek-grid-events.spec.ts +0 -186
  115. package/tests/unit/components/tek-grid/tek-grid-toolbar-provider.spec.ts +0 -34
  116. package/tests/unit/components/tek-grid/tek-grid.spec.ts +0 -895
  117. package/tests/unit/components/tek-grid/tek-memory-datasource.spec.ts +0 -482
  118. package/tests/unit/components/tek-grid/tek-rest-datasource.spec.ts +0 -422
  119. package/tests/unit/components/tek-image/Image.spec.ts +0 -67
  120. package/tests/unit/components/tek-iterable-carousel/iterable-carousel.spec.ts +0 -37
  121. package/tests/unit/components/tek-iterable-component-render/iterable-component-render.spec.ts +0 -200
  122. package/tests/unit/components/tek-loading/Loading.spec.ts +0 -30
  123. package/tests/unit/components/tek-notifications/notifications.spec.ts +0 -201
  124. package/tests/unit/components/tek-product-card/product-card.spec.ts +0 -61
  125. package/tests/unit/components/tek-user-info/TekUserInfoContoller.spec.ts +0 -220
  126. package/tests/unit/components/tek-user-info/tek-user-info-list.spec.ts +0 -86
  127. package/tests/unit/components/tek-user-info/tek-user-info.spec.ts +0 -430
  128. package/tests/unit/components/tree-grid/tree-grid.spec.ts +0 -776
  129. package/tests/unit/utils/grid-base/export-options/button-option.spec.ts +0 -44
  130. package/tests/unit/utils/grid-base/export-options/multi-option.spec.ts +0 -135
  131. package/tests/unit/utils/grid-base/grid-controller.spec.ts +0 -174
  132. package/tests/unit/utils/report-filter/report-filter.spec.ts +0 -66
  133. package/tsconfig.build.json +0 -7
  134. package/tsconfig.eslint.json +0 -9
@@ -1,193 +0,0 @@
1
- import { Datasource, DatasourceFactory, IDictionary } from '@zeedhi/core';
2
- import { GridColumnEditable } from '@zeedhi/common';
3
- import { IFilterPropsComponent, ITekGridColumn, ITekGridColumnAggregation } from './interfaces';
4
- import { TekGrid } from './tek-grid';
5
-
6
- /**
7
- * Base class for TekGrid column
8
- */
9
- export class TekGridColumn extends GridColumnEditable implements ITekGridColumn {
10
- /* filter component props */
11
- public filterProps: IFilterPropsComponent | IFilterPropsComponent[] = [];
12
-
13
- /* column can be use to filter */
14
- public filterable = true;
15
-
16
- /* Index of the column inside filter modal */
17
- public filterIndex?: number;
18
-
19
- /* should not consider lookup column on search */
20
- public skipLookupSearch = false;
21
-
22
- /* column is grouped */
23
- private groupedValue = false;
24
-
25
- /* column group is opened */
26
- private groupOpenedValue?: boolean = false;
27
-
28
- /* Value to show when grouped value is empty */
29
- public groupLabelForEmptyValue = '';
30
-
31
- /* column has aggregation */
32
- private aggregationValue?: ITekGridColumnAggregation;
33
-
34
- /* column is visible */
35
- private isVisibleValue = true;
36
-
37
- /**
38
- * Defines if the column should store the componentProps datasource.data in memory
39
- */
40
- public storeData = true;
41
-
42
- private grid: TekGrid;
43
-
44
- /* istanbul ignore next */
45
- /**
46
- * Creates a new TekGrid Column.
47
- * @param props TekGrid column properties
48
- */
49
- constructor(props: ITekGridColumn, grid: TekGrid) {
50
- super(props);
51
- this.grid = grid;
52
- this.isVisible = this.getInitValue('isVisible', props.isVisible, this.isVisible);
53
- this.filterProps = this.getInitValue('filterProps', props.filterProps, this.filterProps);
54
- this.filterable = this.getInitValue('filterable', props.filterable, this.filterable);
55
- this.filterIndex = this.getInitValue('filterIndex', props.filterIndex, this.filterIndex);
56
- this.skipLookupSearch = this.getInitValue('skipLookupSearch', props.skipLookupSearch, this.skipLookupSearch);
57
- this.grouped = this.getInitValue('grouped', props.grouped, this.grouped);
58
- this.groupOpened = this.getInitValue('groupOpened', props.groupOpened, this.groupOpened);
59
- this.aggregation = this.getInitValue('aggregation', props.aggregation, this.aggregation);
60
- this.groupLabelForEmptyValue = this.getInitValue(
61
- 'groupLabelForEmptyValue',
62
- props.groupLabelForEmptyValue,
63
- this.groupLabelForEmptyValue,
64
- );
65
- this.storeData = this.getInitValue('storeData', props.storeData, this.storeData);
66
- this.createAccessors();
67
- }
68
-
69
- public async getBatchLookupData(lookupColumn: string, values: any[]): Promise<IDictionary[]> {
70
- const batch: IDictionary[] = [];
71
- const dataToLookup: any[] = [];
72
- values.forEach((value) => {
73
- if (this.lookupData[value]) {
74
- batch.push(this.lookupData[value]);
75
- return;
76
- }
77
-
78
- const dataIndex = this.lookupDatasource!.data.findIndex((row) => row[lookupColumn] === value);
79
- if (dataIndex !== -1) {
80
- this.lookupData[value] = this.lookupDatasource!.data[dataIndex];
81
- batch.push(this.lookupData[value]);
82
- return;
83
- }
84
-
85
- dataToLookup.push(value);
86
- });
87
-
88
- if (dataToLookup.length > 0) {
89
- await this.lookupFn(lookupColumn, dataToLookup);
90
-
91
- dataToLookup.forEach((value) => {
92
- const row = this.lookupData[value];
93
- if (row) batch.push(row);
94
- });
95
- }
96
-
97
- return batch;
98
- }
99
-
100
- /**
101
- * Memory search, without changing lookupDatasource
102
- */
103
- public async memorySearch(search: string): Promise<any> {
104
- if (!this.lookupDatasource) {
105
- throw new Error("Can't search in a column that doesn't have a datasource");
106
- }
107
-
108
- let { data } = this.lookupDatasource;
109
- if (this.storeData) {
110
- if (!data.length) {
111
- data = await this.lookupDatasource.get();
112
- }
113
- } else {
114
- // datasource without the lookup filters
115
- const defaultDs = DatasourceFactory.factory({
116
- ...this.componentProps.datasource,
117
- lazyLoad: true,
118
- loadAll: true,
119
- });
120
- defaultDs.initialize();
121
-
122
- data = await defaultDs.get();
123
- }
124
-
125
- const { dataText } = this.componentProps;
126
- const searchIn = Array.isArray(dataText) ? dataText : [dataText];
127
-
128
- // get datasource as memory
129
- const datasource: Datasource = DatasourceFactory.factory({
130
- searchIn,
131
- data,
132
- type: 'memory',
133
- loadAll: true,
134
- });
135
- datasource.initialize();
136
-
137
- return datasource.setSearch(search);
138
- }
139
-
140
- get grouped() {
141
- return this.groupedValue;
142
- }
143
-
144
- set grouped(value: boolean) {
145
- const changed = value !== this.groupedValue;
146
- this.groupedValue = value;
147
- if (changed) {
148
- this.changeGrouping();
149
- }
150
- }
151
-
152
- get aggregation() {
153
- return this.aggregationValue;
154
- }
155
-
156
- set aggregation(value: ITekGridColumnAggregation) {
157
- const changed = value !== this.aggregationValue;
158
- this.aggregationValue = value;
159
- if (changed) {
160
- this.changeGrouping();
161
- }
162
- }
163
-
164
- get groupOpened() {
165
- return this.groupOpenedValue;
166
- }
167
-
168
- set groupOpened(value: boolean | undefined) {
169
- const changed = value !== this.groupOpenedValue;
170
- this.groupOpenedValue = value;
171
- if (changed) {
172
- this.changeGrouping();
173
- }
174
- }
175
-
176
- /* istanbul ignore next */
177
- // @ts-expect-error
178
- get isVisible() {
179
- return this.isVisibleValue && !this.grouped;
180
- }
181
-
182
- /* istanbul ignore next */
183
- set isVisible(value: boolean) {
184
- this.isVisibleValue = value;
185
- }
186
-
187
- private changeGrouping() {
188
- // wait for grid.constructor to be fully executed
189
- setTimeout(() => {
190
- this.grid.updateGrouping();
191
- });
192
- }
193
- }
@@ -1,28 +0,0 @@
1
- import { IEventParam } from '@zeedhi/core';
2
- import { Checkbox, IterableColumnsButtonController } from '@zeedhi/common';
3
- import { TekGridColumn } from '../tek-grid-column';
4
-
5
- export class TekGridColumnsButtonController extends IterableColumnsButtonController {
6
- public changeGroupedColumn(column: TekGridColumn, { component, event, element }: IEventParam<Checkbox>) {
7
- column.grouped = component.value;
8
- if (!column.grouped) {
9
- const index = this.iterableComponent.datasource.order.indexOf(`${column.name}.asc`);
10
- this.iterableComponent.datasource.order.splice(index, 1);
11
- }
12
- this.iterableComponent.changeLayout(event, element);
13
- }
14
-
15
- public changeAggregationColumn(column: TekGridColumn, { component, event, element }: IEventParam<Checkbox>) {
16
- const newValue = component.value || undefined;
17
- if (column.aggregation !== newValue) {
18
- this.iterableComponent.changeLayout(event, element);
19
- }
20
- column.aggregation = newValue;
21
- }
22
-
23
- public showHideTekColumn(column: TekGridColumn, { component, event, element }: IEventParam<Checkbox>) {
24
- if (!component.value && column.grouped) column.grouped = false;
25
- column.isVisible = component.value;
26
- this.iterableComponent.changeLayout(event, element);
27
- }
28
- }
@@ -1,38 +0,0 @@
1
- import { I18n, Loader } from '@zeedhi/core';
2
- import { IterableColumnsButton } from '@zeedhi/common';
3
- import { TekGridColumn } from '../tek-grid-column';
4
- import { ITekGridColumnsButton, columnAggregationValues } from '../interfaces';
5
- import { TekGridColumnsButtonController } from './tek-grid-columns-button-controller';
6
-
7
- /**
8
- * Base class for TekGrid Columns Button component
9
- */
10
- export class TekGridColumnsButton extends IterableColumnsButton<TekGridColumn> implements ITekGridColumnsButton {
11
- public hideGroups = false;
12
-
13
- constructor(props: ITekGridColumnsButton) {
14
- super(props);
15
- this.hideGroups = this.getInitValue('hideGroups', props.hideGroups, this.hideGroups);
16
- this.createAccessors();
17
- }
18
-
19
- public onCreated() {
20
- super.onCreated();
21
- Loader.addController(`IterableColumnsButtonController_${this.name}`, TekGridColumnsButtonController, [
22
- this.iterableComponent,
23
- ]);
24
- this.controller = Loader.getInstance(`IterableColumnsButtonController_${this.name}`);
25
- }
26
-
27
- private aggregationDataSet: any[] = [];
28
-
29
- public getAggregationSelectData() {
30
- if (!this.aggregationDataSet.length) {
31
- this.aggregationDataSet = columnAggregationValues.filter(Boolean).map((value) => ({
32
- text: I18n.translate(`TEKGRID_AGGREGATION_${value}`),
33
- value,
34
- }));
35
- }
36
- return this.aggregationDataSet;
37
- }
38
- }
@@ -1,140 +0,0 @@
1
- import { IGridEditable } from '@zeedhi/common';
2
- import { ISupportsToolbar } from './interfaces';
3
-
4
- export class TekGridController {
5
- private grid!: IGridEditable & ISupportsToolbar;
6
-
7
- public openToolbar = true;
8
-
9
- public constructor(grid: IGridEditable & ISupportsToolbar) {
10
- this.grid = grid;
11
- this.openToolbar = this.grid.toolbarOpened;
12
- }
13
-
14
- public get gridTitle() {
15
- return this.grid.title;
16
- }
17
-
18
- public get showAddButton() {
19
- return this.grid.addButton;
20
- }
21
-
22
- public get showDeleteButton() {
23
- return this.grid.deleteButton !== 'none';
24
- }
25
-
26
- public get showFilterButton() {
27
- return this.grid.filterButton;
28
- }
29
-
30
- public get showModalFilterProps() {
31
- return this.grid.modalFilterProps;
32
- }
33
-
34
- public get showSearchInput() {
35
- return this.grid.showSearch;
36
- }
37
-
38
- public get showToolbar() {
39
- return this.openToolbar;
40
- }
41
-
42
- public set showToolbar(value: boolean) {
43
- this.openToolbar = value;
44
- }
45
-
46
- public get toolbarClass(): string {
47
- return !this.openToolbar ? 'is-rotated' : '';
48
- }
49
-
50
- public get tooltipName() {
51
- return !this.openToolbar ? 'TEKGRID_SHOW' : 'TEKGRID_HIDE';
52
- }
53
-
54
- public get showReloadButton() {
55
- return this.grid.showReload;
56
- }
57
-
58
- public get showDivider2() {
59
- return (
60
- this.showReloadButton &&
61
- (this.showLayoutOptionsButton ||
62
- this.showColumnsButton ||
63
- this.showActionsButton ||
64
- this.showExportButton ||
65
- this.showSearchInput)
66
- );
67
- }
68
-
69
- public get showColumnsButton() {
70
- return this.grid.columnsButton;
71
- }
72
-
73
- public get columnsButtonIgnore() {
74
- return this.grid.columnsButtonIgnore;
75
- }
76
-
77
- public get showLayoutOptionsButton() {
78
- return this.grid.showLayoutOptions;
79
- }
80
-
81
- public get showDivider1() {
82
- return (
83
- (this.showAddButton || this.showDeleteButton) &&
84
- (this.showReloadButton ||
85
- this.showLayoutOptionsButton ||
86
- this.showColumnsButton ||
87
- this.showActionsButton ||
88
- this.showExportButton ||
89
- this.showSearchInput)
90
- );
91
- }
92
-
93
- public get showActionsButton() {
94
- return this.grid.actions.length > 0;
95
- }
96
-
97
- public get showExportButton() {
98
- return this.grid.showExport;
99
- }
100
-
101
- public get showActionAndExportButton() {
102
- return (
103
- (this.showLayoutOptionsButton || this.showColumnsButton) &&
104
- (this.showActionsButton || this.showExportButton || this.showSearchInput)
105
- );
106
- }
107
-
108
- public get showDivider3() {
109
- return (this.showActionsButton || this.showExportButton) && this.showSearchInput;
110
- }
111
-
112
- public get isEditing() {
113
- return this.grid.editing;
114
- }
115
-
116
- public get showEditButtons() {
117
- return this.isEditing && this.grid.showEditButtons;
118
- }
119
-
120
- public get isNotEditing() {
121
- return !this.isEditing;
122
- }
123
-
124
- public get disableDeleteButton() {
125
- if (this.grid.deleteButton === 'selection') {
126
- if (this.grid.selectAllPages) {
127
- const { allSelected, except } = this.grid.selectionState;
128
- return (allSelected && except.length === this.grid.datasource.total) || (!allSelected && except.length === 0);
129
- }
130
-
131
- return this.grid.selectedRows.length === 0;
132
- }
133
-
134
- if (this.grid.deleteButton === 'currentRow') {
135
- return !this.grid.datasource.currentRow[this.grid.datasource.uniqueKey];
136
- }
137
-
138
- return false;
139
- }
140
- }
@@ -1,105 +0,0 @@
1
- import { IDictionary } from '@zeedhi/core';
2
- import { GridEditableEvents } from '@zeedhi/common';
3
- import { ITekGrid, ITekGridEvents, ITekGridSummary } from './interfaces';
4
- import { TekGridColumn } from './tek-grid-column';
5
-
6
- export class TekGridEvents extends GridEditableEvents implements ITekGridEvents {
7
- protected tekGrid: ITekGrid;
8
-
9
- /**
10
- * Flag to prevent row click
11
- */
12
- protected preventRowClick = false;
13
-
14
- protected preventRowDoubleClick = false;
15
-
16
- constructor(tekGrid: ITekGrid) {
17
- super(tekGrid);
18
- this.tekGrid = tekGrid;
19
- }
20
-
21
- calcSummary(column: TekGridColumn, summary: ITekGridSummary, row: IDictionary): void {
22
- this.tekGrid.callEvent('calcSummary', {
23
- component: this.tekGrid,
24
- column,
25
- columnName: column.name,
26
- summary,
27
- row,
28
- rowValue: row[column.name],
29
- });
30
- }
31
-
32
- public rowDoubleClick(row: IDictionary<any>, event: Event, element: HTMLElement) {
33
- if (!this.preventRowDoubleClick) {
34
- this.tekGrid.datasource.currentRow = row;
35
-
36
- this.tekGrid.callEvent('rowDoubleClick', {
37
- event,
38
- element,
39
- row,
40
- component: this.tekGrid,
41
- column: undefined,
42
- });
43
- }
44
- this.preventRowDoubleClick = false;
45
- }
46
-
47
- /**
48
- * Dispatches group row click event
49
- * @param row Grid row
50
- * @param event DOM event
51
- * @param element DOM Element
52
- */
53
- public groupRowClick(row: IDictionary<any>, event: Event, element: HTMLElement) {
54
- if (!this.preventRowClick) {
55
- this.tekGrid.callEvent('groupRowClick', {
56
- event,
57
- element,
58
- row,
59
- component: this.tekGrid,
60
- column: undefined,
61
- });
62
- }
63
- this.preventRowClick = false;
64
- }
65
-
66
- public groupRowDoubleClick(row: IDictionary<any>, event: Event, element: HTMLElement) {
67
- if (!this.preventRowDoubleClick) {
68
- this.tekGrid.callEvent('groupRowDoubleClick', {
69
- event,
70
- element,
71
- row,
72
- component: this.tekGrid,
73
- column: undefined,
74
- });
75
- }
76
- this.preventRowDoubleClick = false;
77
- }
78
-
79
- /**
80
- * Dispatches group select/unselect event
81
- * @param row Group row
82
- * @param isSelected Row is selected
83
- * @param event DOM event
84
- * @param element DOM Element
85
- */
86
- public selectGroupClick(row: IDictionary<any>, isSelected: boolean, event: Event, element: HTMLElement) {
87
- if (isSelected) {
88
- this.tekGrid.callEvent('groupSelected', {
89
- event,
90
- element,
91
- row,
92
- component: this.tekGrid,
93
- column: undefined,
94
- });
95
- } else {
96
- this.tekGrid.callEvent('groupUnselected', {
97
- event,
98
- element,
99
- row,
100
- component: this.tekGrid,
101
- column: undefined,
102
- });
103
- }
104
- }
105
- }
@@ -1,26 +0,0 @@
1
- import { IComponent } from '@zeedhi/common';
2
- import { IExportable, ITekGridExportConfig } from '../../interfaces';
3
- import { IExportOption } from './interfaces';
4
-
5
- export class ButtonOption implements IExportOption {
6
- private config: ITekGridExportConfig;
7
-
8
- constructor(config: ITekGridExportConfig) {
9
- this.config = config;
10
- }
11
-
12
- buildComponent(grid: IComponent & IExportable) {
13
- const { type, label, portrait = true, iconName } = this.config;
14
- const orientation = portrait ? 'portrait' : 'landscape';
15
- return {
16
- label,
17
- iconName,
18
- name: `${grid.name}_export_${type}_${orientation}`,
19
- component: 'ZdButton',
20
- flat: true,
21
- events: {
22
- click: () => grid.getReport(type, portrait) as any,
23
- },
24
- };
25
- }
26
- }
@@ -1,3 +0,0 @@
1
- export * from './button-option';
2
- export * from './multi-option';
3
- export * from './interfaces';
@@ -1,6 +0,0 @@
1
- import { IComponent, IComponentRender } from '@zeedhi/common';
2
- import { IExportable } from '../../interfaces';
3
-
4
- export interface IExportOption {
5
- buildComponent: (grid: IComponent & IExportable) => IComponentRender;
6
- }
@@ -1,85 +0,0 @@
1
- import { IButton, IComponent, IDivider, IRow, IText, ITooltip } from '@zeedhi/common';
2
- import { IExportable, ITekGridExportConfig, MultiOptionParams } from '../../interfaces';
3
- import { IExportOption } from './interfaces';
4
-
5
- export class MultiOption implements IExportOption {
6
- private config: ITekGridExportConfig;
7
-
8
- constructor(config: ITekGridExportConfig) {
9
- this.config = config;
10
- }
11
-
12
- private formatName(id: string, type: string, grid: IComponent & IExportable) {
13
- return `${grid.name}_export_${type}_${id}`;
14
- }
15
-
16
- private buildTooltip(option: MultiOptionParams, type: string, grid: IComponent & IExportable): ITooltip {
17
- const { label } = option;
18
- return {
19
- name: this.formatName(`tooltip_${label}`, type, grid),
20
- component: 'ZdTooltip',
21
- bottom: true,
22
- label,
23
- children: [],
24
- };
25
- }
26
-
27
- private buildButton(option: MultiOptionParams, type: string, grid: IComponent & IExportable): IButton {
28
- const { cssClass, label, iconName, reportParams } = option;
29
- const { portrait: optionPortrait, rowObj } = reportParams || {};
30
-
31
- return {
32
- name: this.formatName(`button_${label}`, type, grid),
33
- component: 'ZdButton',
34
- cssClass,
35
- icon: true,
36
- iconName,
37
- events: {
38
- click: () => grid.getReport(type, optionPortrait, rowObj) as any,
39
- },
40
- };
41
- }
42
-
43
- private buildDivider(option: MultiOptionParams, type: string, grid: IComponent & IExportable): IDivider {
44
- const { label } = option;
45
-
46
- return {
47
- name: this.formatName(`divider_${label}`, type, grid),
48
- component: 'ZdDivider',
49
- cssClass: 'zd-my-1',
50
- vertical: true,
51
- };
52
- }
53
-
54
- buildComponent(grid: IComponent & IExportable) {
55
- const { type, label, multiOption } = this.config;
56
-
57
- const optionComponents = multiOption!.flatMap((option) => [
58
- {
59
- ...this.buildTooltip(option, type, grid),
60
- children: [this.buildButton(option, type, grid)],
61
- },
62
- this.buildDivider(option, type, grid),
63
- ]);
64
-
65
- optionComponents.pop();
66
-
67
- const text: IText = {
68
- name: this.formatName('text', type, grid),
69
- component: 'ZdText',
70
- cssClass: 'zd-display-flex zd-align-center zd-flex-grow-1 tek-grid-export-multioption-text',
71
- events: {
72
- click: ({ event }) => event?.stopPropagation(),
73
- },
74
- text: label || '',
75
- };
76
- const result: IRow = {
77
- name: this.formatName('row', type, grid),
78
- component: 'ZdRow',
79
- cssClass: 'zd-display-flex zd-ma-0 zd-py-0 zd-gap-x-1 tek-grid-export-multioption-row',
80
- children: [text, ...optionComponents],
81
- };
82
-
83
- return result;
84
- }
85
- }
@@ -1,2 +0,0 @@
1
- export * from './export-options';
2
- export * from './tek-grid-toolbar-provider';