basesite-shared-grid-lib 0.0.1

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.
@@ -0,0 +1,338 @@
1
+ import { IGetRowsParams, ColDef, ColGroupDef, IServerSideGetRowsRequest, IServerSideGetRowsParams } from 'ag-grid-community';
2
+ import { OdataQueryExtendFull, OdataQueryExtendOptions, OdataQueryOptions } from './types';
3
+ export declare class OdataProviderOptions {
4
+ /**
5
+ * Function for call odata api
6
+ */
7
+ callApi: (query: string) => Promise<any>;
8
+ /**
9
+ * Name of field contain count of record results in grouping odata query
10
+ * @default childCount
11
+ */
12
+ groupCountFieldName?: string;
13
+ /**
14
+ * Use in odata build query
15
+ * @default false
16
+ */
17
+ isCaseSensitiveStringFilter?: boolean;
18
+ /**
19
+ * Callback for extend odata query options for implement user logic
20
+ */
21
+ beforeRequest?: (options: OdataQueryOptions, provider: OdataProvider, request: IGetRowsParams | IServerSideGetRowsRequest) => void;
22
+ /**
23
+ * Callback for pivot or group for aplly column ag-grid settings
24
+ * @example
25
+ * <pre><code>
26
+ * beforeSetSecondaryColumns = secondaryColumns => {
27
+ for (let i = 0; i < secondaryColumns.length; i++) {
28
+ const col = secondaryColumns[i]
29
+ if (col.children) {
30
+ beforeSetSecondaryColumns(col.children)
31
+ } else {
32
+ //Aplly new setting for group dyncamic created column
33
+ // col.cellClassRules =
34
+ // col.valueFormatter =
35
+ }
36
+ }
37
+ }
38
+ * </pre></code>
39
+ */
40
+ beforeSetSecondaryColumns?: (secondaryColDefs: (ColDef | ColGroupDef)[]) => void;
41
+ /**
42
+ * Callback invoked after load data
43
+ * @param options odata provider options
44
+ * @param rowData data for ag-grid
45
+ * @param totalCount total count records
46
+ *
47
+ * @example
48
+ * <pre><code>
49
+ afterLoadData = (options, rowData, totalCount) => {
50
+ if (options.skip === 0 && rowData.length > 0) {
51
+ gridApi.columnController.autoSizeAllColumns()
52
+ }
53
+ }
54
+ * </code></pre>
55
+ */
56
+ afterLoadData?: (options: OdataQueryExtendOptions, rowData: any[], totalCount: number) => void;
57
+ /**
58
+ * Callback for catch error
59
+ */
60
+ setError?: (error: any, params: IGetRowsParams | IServerSideGetRowsParams) => void;
61
+ /**
62
+ * List of columns by id/field are case sensitive for build odata query
63
+ */
64
+ caseSensitiveColumns?: string[];
65
+ /**
66
+ * Use for specified column custom filter implementation
67
+ * <pre><code>
68
+ customFilters: {
69
+ "customer": (colName,col,isCaseSensitiveStringFilter,provider) =>{
70
+ return provider.odataOperator.in(
71
+ colName,
72
+ col.values
73
+ )
74
+ }
75
+ }
76
+ */
77
+ customFilters?: {
78
+ [index: string]: (colName: string, col: any, isCaseSensitiveStringFilter: boolean, provider: OdataProvider) => string;
79
+ };
80
+ }
81
+ declare interface CancelablePromise {
82
+ promise: Promise<any>;
83
+ cancel: () => void;
84
+ }
85
+ export declare class OdataProvider implements OdataProviderOptions {
86
+ /**
87
+ * Function for call odata api
88
+ */
89
+ callApi: (query: string) => Promise<any>;
90
+ /**
91
+ * Name of field contain count of record results in grouping odata query
92
+ * @default childCount
93
+ */
94
+ groupCountFieldName: string;
95
+ /**
96
+ * Use in odata build query
97
+ * @default false
98
+ */
99
+ isCaseSensitiveStringFilter: boolean;
100
+ /**
101
+ * Callback for extend odata query options for implement user logic
102
+ */
103
+ beforeRequest: ((options: OdataQueryOptions, provider: OdataProvider, request: IGetRowsParams | IServerSideGetRowsRequest) => void) | undefined;
104
+ /**
105
+ * Callback for pivot or group for aplly column ag-grid settings
106
+ * @example
107
+ * <pre><code>
108
+ * beforeSetSecondaryColumns = secondaryColumns => {
109
+ for (let i = 0; i < secondaryColumns.length; i++) {
110
+ const col = secondaryColumns[i]
111
+ if (col.children) {
112
+ beforeSetSecondaryColumns(col.children)
113
+ } else {
114
+ //Aplly new setting for group dyncamic created column
115
+ // col.cellClassRules =
116
+ // col.valueFormatter =
117
+ }
118
+ }
119
+ }
120
+ * </pre></code>
121
+ */
122
+ beforeSetSecondaryColumns: ((secondaryColDefs: (ColDef | ColGroupDef)[]) => void) | undefined;
123
+ /**
124
+ * Callback invoked after load data
125
+ * @param options odata provider options
126
+ * @param rowData data for ag-grid
127
+ * @param totalCount total count records
128
+ *
129
+ * @example
130
+ * <pre><code>
131
+ afterLoadData = (options, rowData, totalCount) => {
132
+ if (options.skip === 0 && rowData.length > 0) {
133
+ gridApi.columnController.autoSizeAllColumns()
134
+ }
135
+ }
136
+ * </code></pre>
137
+ */
138
+ afterLoadData: ((options: OdataQueryExtendOptions, rowData: any[], totalCount: number) => void) | undefined;
139
+ /**
140
+ * Callback for catch error
141
+ */
142
+ setError: ((error: any, params: IGetRowsParams | IServerSideGetRowsParams) => void) | undefined;
143
+ /**
144
+ * List of columns by id/field are case sensitive for build odata query
145
+ */
146
+ caseSensitiveColumns?: string[];
147
+ /**
148
+ * Use for specified column custom filter implementation
149
+ * <pre><code>
150
+ customFilters: {
151
+ "customer": (colName,col,isCaseSensitiveStringFilter,provider) =>{
152
+ return provider.odataOperator.in(
153
+ colName,
154
+ col.values
155
+ )
156
+ }
157
+ }
158
+ */
159
+ customFilters?: {
160
+ [index: string]: (colName: string, col: any, isCaseSensitiveStringFilter: boolean, provider: OdataProvider) => string;
161
+ };
162
+ cancelPromice: CancelablePromise;
163
+ constructor(options: OdataProviderOptions);
164
+ /**Creator a cancelable Promise */
165
+ createCancelablePromise: () => CancelablePromise;
166
+ /**Odata query operations */
167
+ odataOperator: any;
168
+ /**
169
+ * Apply tolower for column in odata syntax
170
+ * @param col column name
171
+ * @param isCaseSensitiveStringFilter need apply tolower
172
+ */
173
+ ifTolowerCol: (col: string, isCaseSensitiveStringFilter: boolean) => string;
174
+ /**
175
+ *
176
+ * @param value string value
177
+ * @param isCaseSensitiveStringFilter need apply tolower
178
+ */
179
+ ifTolower: (value: string, isCaseSensitiveStringFilter: boolean) => string;
180
+ /**
181
+ * Odata aggregation operations
182
+ */
183
+ odataAggregation: any;
184
+ /**
185
+ * Odata query builder
186
+ * @param options parameter for odata query
187
+ */
188
+ toQuery: (options: OdataQueryExtendFull) => string;
189
+ /**
190
+ * Add quotes for string value
191
+ * @param value string value
192
+ */
193
+ encode: (value: string) => string;
194
+ /**
195
+ * Conctat to date a time for create datetime format for odata query
196
+ * @param value date string
197
+ */
198
+ toDateTime: (value: string) => string | null;
199
+ /**
200
+ *
201
+ * @param colName columnName
202
+ * @returns is CaseSensitive for column
203
+ */
204
+ private getIsNeedCaseSensitive;
205
+ /**
206
+ * Convert ag-grid column filter to odata query
207
+ * @param colName columnName
208
+ * @param col ag-grid column
209
+ */
210
+ private getFilterOdata;
211
+ /**
212
+ * Extract value from record by path to field
213
+ * @param field path to column value
214
+ * @param obj record
215
+ */
216
+ private getValue;
217
+ /**
218
+ * Caclulate pivot data for ag-grid from odata
219
+ * @param pivotCols pivot columns
220
+ * @param rowGroupCols row group columns
221
+ * @param valueCols value columns
222
+ * @param data odata result
223
+ * @param countField count field name
224
+ */
225
+ private getPivot;
226
+ /**
227
+ *
228
+ * @param rowData array odata result
229
+ * @param rowGroupCols row group columns
230
+ * @param groupKeys what groups the user is viewing
231
+ * @param countField count field name
232
+ */
233
+ private buildGroupsFromData;
234
+ /**
235
+ * Internal function for execute callback function for each property of object
236
+ * @param object object contained odata grouped result
237
+ * @param callback function do somthing
238
+ */
239
+ private iterateObject;
240
+ /**
241
+ * Prepeare grouped data
242
+ * @param rowData array odata result
243
+ * @param field grouping field
244
+ */
245
+ private groupBy;
246
+ /**
247
+ * Calculate total count records in group
248
+ * @param rowData array odata result data
249
+ * @param countField field contained count of all records
250
+ */
251
+ private aggregateList;
252
+ /**
253
+ * Calculate distinct values for input field from Odata api
254
+ * @param field The field of the row to get the cells data from
255
+ * @param callback The function for return distinct values for input field
256
+ * @param beforeRequest The function for customize request
257
+ * @example
258
+ * <pre><code>
259
+ * const setFilterValuesFuncParams = params => {
260
+ * const me = this
261
+ * const col = params.colDef.field
262
+ * const storeName = me.getStoreName(col)
263
+ * const callback = data => {
264
+ * if (data) {
265
+ * me.setState({ [storeName]: data })
266
+ * params.success(data)
267
+ * }
268
+ * }
269
+ * odataProviderInstance.getFilterValuesParams(params.colDef.field, callback)
270
+ * }
271
+ *
272
+ * ///....
273
+ * <AgGridColumn
274
+ field="product"
275
+ headerName={'PRODUCT'}
276
+ filter="agSetColumnFilter"
277
+ // rowGroup
278
+ // enablePivot
279
+ enableRowGroup
280
+ filterParams={{
281
+ values: setFilterValuesFuncParams,
282
+ newRowsAction: 'keep'
283
+ }}
284
+ // filterParams={{caseSensitive: true}}
285
+ />
286
+ * </code></pre>
287
+ */
288
+ getFilterValuesParams: (field: string, callback: (data: any[]) => void, beforeRequest: (options: OdataQueryExtendFull) => void | undefined) => void;
289
+ /**
290
+ * Detect is string value
291
+ * @param value
292
+ */
293
+ isStrVal: (value: any) => boolean;
294
+ /**
295
+ * Extartc values from odata response
296
+ * @param response
297
+ */
298
+ private getOdataResult;
299
+ /**
300
+ * Endocing column name to odata notation
301
+ * @param colName column name
302
+ */
303
+ private getWrapColumnName;
304
+ /**
305
+ * grid calls this to get rows for IServerSideDatasource
306
+ * @param params ag-grid details for the request
307
+ */
308
+ /**
309
+ * grid calls this to get rows implement
310
+ * @param params ag-grid details for the request
311
+ */
312
+ getRows(params: IGetRowsParams | IServerSideGetRowsParams): void;
313
+ /**
314
+ * Set result
315
+ * @param params ag-grid details for the request
316
+ * @param isServerMode detect type of params
317
+ * @param rowsThisBlock data of the request
318
+ * @param rowCount count of total result
319
+ */
320
+ private setResult;
321
+ /**
322
+ * Generate odata options for build query from ag-grid request
323
+ * @param params ag-grid details for the request
324
+ */
325
+ getOdataOptions: (params: IGetRowsParams | IServerSideGetRowsParams) => OdataQueryExtendFull;
326
+ /**
327
+ * Generate odata query from ag-grid request
328
+ * @param params ag-grid details for the request
329
+ */
330
+ getOdataQuery: (params: IGetRowsParams | IServerSideGetRowsParams) => string;
331
+ }
332
+ export declare class OdataProviderClient extends OdataProvider {
333
+ getRows(params: IServerSideGetRowsParams): void;
334
+ }
335
+ export declare class OdataServerSideProvider extends OdataProvider {
336
+ getRows(params: IServerSideGetRowsParams): void;
337
+ }
338
+ export {};
@@ -0,0 +1,20 @@
1
+ import { ColumnVO } from 'ag-grid-community';
2
+ export interface OdataQueryOptions {
3
+ sort?: Array<string>;
4
+ filter?: Array<string>;
5
+ expand?: Array<string>;
6
+ select?: Array<string>;
7
+ }
8
+ export interface OdataQueryExtendOptions extends OdataQueryOptions {
9
+ skip?: number;
10
+ top?: number;
11
+ }
12
+ export interface OdataQueryExtendFull extends OdataQueryExtendOptions {
13
+ count?: boolean;
14
+ apply?: Array<string>;
15
+ }
16
+ export declare class PivotResultDat {
17
+ data: any[];
18
+ aggCols: any[];
19
+ secondaryColDefs: ColumnVO[];
20
+ }
@@ -0,0 +1,2 @@
1
+ export declare function escapeRegExp(string: any): any;
2
+ export declare function replaceAll(str: string, search: string, replacement: string): string;
@@ -0,0 +1,12 @@
1
+ import { ICellRendererAngularComp } from 'ag-grid-angular';
2
+ import * as i0 from "@angular/core";
3
+ export declare class ButtonRendererComponent implements ICellRendererAngularComp {
4
+ params: any;
5
+ label: any;
6
+ icon: any;
7
+ agInit(params: any): void;
8
+ refresh(params?: any): boolean;
9
+ onClick($event: any): void;
10
+ static ɵfac: i0.ɵɵFactoryDeclaration<ButtonRendererComponent, never>;
11
+ static ɵcmp: i0.ɵɵComponentDeclaration<ButtonRendererComponent, "lib-button-renderer", never, {}, {}, never, never, false, never>;
12
+ }
@@ -0,0 +1,16 @@
1
+ import { DatePipe } from '@angular/common';
2
+ import { ITooltipAngularComp } from 'ag-grid-angular';
3
+ import { ITooltipParams } from 'ag-grid-community';
4
+ import * as i0 from "@angular/core";
5
+ export declare class CustomTooltip implements ITooltipAngularComp {
6
+ private datePipe;
7
+ constructor(datePipe: DatePipe);
8
+ params: {
9
+ color: string;
10
+ } & ITooltipParams;
11
+ agInit(params: {
12
+ color: string;
13
+ } & ITooltipParams): void;
14
+ static ɵfac: i0.ɵɵFactoryDeclaration<CustomTooltip, never>;
15
+ static ɵcmp: i0.ɵɵComponentDeclaration<CustomTooltip, "tooltip-component", never, {}, {}, never, never, false, never>;
16
+ }
package/package.json ADDED
@@ -0,0 +1,39 @@
1
+ {
2
+ "name": "basesite-shared-grid-lib",
3
+ "version": "0.0.1",
4
+ "peerDependencies": {
5
+ "@angular/common": "^15.1.0",
6
+ "@angular/core": "^15.1.0",
7
+ "ag-grid-angular": "^29.0.0",
8
+ "ag-grid-community": "^29.0.0",
9
+ "ag-grid-enterprise": "^29.0.0"
10
+ },
11
+ "dependencies": {
12
+ "tslib": "^2.3.0"
13
+ },
14
+ "bundledDependencies": [
15
+ "ag-grid-angular",
16
+ "ag-grid-community",
17
+ "ag-grid-enterprise"
18
+ ],
19
+ "sideEffects": false,
20
+ "module": "fesm2015/basesite-shared-grid-lib.mjs",
21
+ "es2020": "fesm2020/basesite-shared-grid-lib.mjs",
22
+ "esm2020": "esm2020/basesite-shared-grid-lib.mjs",
23
+ "fesm2020": "fesm2020/basesite-shared-grid-lib.mjs",
24
+ "fesm2015": "fesm2015/basesite-shared-grid-lib.mjs",
25
+ "typings": "index.d.ts",
26
+ "exports": {
27
+ "./package.json": {
28
+ "default": "./package.json"
29
+ },
30
+ ".": {
31
+ "types": "./index.d.ts",
32
+ "esm2020": "./esm2020/basesite-shared-grid-lib.mjs",
33
+ "es2020": "./fesm2020/basesite-shared-grid-lib.mjs",
34
+ "es2015": "./fesm2015/basesite-shared-grid-lib.mjs",
35
+ "node": "./fesm2015/basesite-shared-grid-lib.mjs",
36
+ "default": "./fesm2020/basesite-shared-grid-lib.mjs"
37
+ }
38
+ }
39
+ }
@@ -0,0 +1,3 @@
1
+ export * from './lib/grid-library.service';
2
+ export * from './lib/grid-library.component';
3
+ export * from './lib/grid-library.module';
@@ -0,0 +1,84 @@
1
+ @import 'ag-grid-community/styles/ag-grid.css';
2
+ @import 'ag-grid-community/styles/ag-theme-balham.css';
3
+
4
+
5
+ button {
6
+ font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
7
+ }
8
+
9
+ .btn-actions {
10
+ background: #E1E6EF;
11
+ border: 1px solid rgba(0, 0, 0, .08);
12
+ color: #324168;
13
+ position: absolute;
14
+ border-radius: 3.81078px;
15
+ margin-top: 1px;
16
+ padding: 3px;
17
+ }
18
+ .custom-tooltip {
19
+ width: auto;
20
+ height: auto;
21
+ border: 1px solid cornflowerblue;
22
+ overflow: hidden;
23
+ background-color: #fff !important;
24
+ }
25
+
26
+ .custom-tooltip p {
27
+ margin: 5px;
28
+ white-space: nowrap;
29
+ }
30
+
31
+ .custom-tooltip p:first-of-type {
32
+ font-weight: bold;
33
+ }
34
+
35
+ .btn-actions::before {
36
+ background-color: #fff !important;
37
+ border: 1px solid cornflowerblue;
38
+ content: attr(data-title);
39
+ display: none;
40
+ font-weight: bold;
41
+ position: absolute;
42
+ top: 0px;
43
+ left: 25px;
44
+ z-index: 1;
45
+ }
46
+ .btn-actions:hover::before {
47
+ display: block;
48
+ position: absolute;
49
+ padding: 3px 7px;
50
+ }
51
+ .action-button{
52
+ overflow: unset !important;
53
+ }
54
+ .ag-paging-panel,.ag-icon::before{
55
+ color: #7141B1 !important;
56
+ font-weight: 700 !important;
57
+ }
58
+ .ag-ltr .ag-cell,.ag-header-cell-comp-wrapper {
59
+ color: #324168;
60
+ font-weight: 500;
61
+ }
62
+ .ag-header-cell, .ag-header-group-cell{
63
+ background-color: #fff;
64
+ }
65
+ .ag-row{
66
+ border-bottom: 0;
67
+ }
68
+ .ag-row-odd{
69
+ background-color: #fafafa;
70
+ }
71
+ .ag-pinned-right-cols-container > div > div .btn-actions:hover::before{
72
+ left: auto;
73
+ right: 20px !important;
74
+ }
75
+ .ag-pinned-left-cols-container > div > div:last-child .btn-actions:hover::before{
76
+ left: auto;
77
+ right: 15px !important;
78
+ }
79
+ .ag-header-cell::after, .ag-header-group-cell::after{
80
+ background-color: #ffffff !important;
81
+ }
82
+ .ag-root-wrapper,.ag-header{
83
+ border:none !important;
84
+ }