cat-documents-ng 0.3.21 → 0.3.22
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.
- package/README.md +322 -0
- package/Shared/constant/SHARED.d.ts +13 -0
- package/fesm2022/cat-documents-ng.mjs +477 -78
- package/fesm2022/cat-documents-ng.mjs.map +1 -1
- package/lib/document/components/document-content-viewer/document-content-viewer.component.d.ts +52 -7
- package/lib/document/services/csv-parser.service.d.ts +88 -0
- package/lib/document/services/document-http.service.d.ts +7 -0
- package/package.json +1 -1
package/lib/document/components/document-content-viewer/document-content-viewer.component.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { OnChanges, SimpleChanges, OnInit } from '@angular/core';
|
|
2
2
|
import { ExcelParserService, ExcelRowData } from '../../services/excel-parser.service';
|
|
3
|
+
import { CsvParserService, CsvRowData } from '../../services/csv-parser.service';
|
|
3
4
|
import { DocumentHttpService } from '../../services/document-http.service';
|
|
4
5
|
import * as i0 from "@angular/core";
|
|
5
6
|
/**
|
|
@@ -10,6 +11,7 @@ import * as i0 from "@angular/core";
|
|
|
10
11
|
*/
|
|
11
12
|
export declare class DocumentContentViewerComponent implements OnChanges, OnInit {
|
|
12
13
|
private excelParserService;
|
|
14
|
+
private csvParserService;
|
|
13
15
|
private documentHttpService;
|
|
14
16
|
/**
|
|
15
17
|
* The document URL to display
|
|
@@ -66,6 +68,31 @@ export declare class DocumentContentViewerComponent implements OnChanges, OnInit
|
|
|
66
68
|
* @type {boolean}
|
|
67
69
|
*/
|
|
68
70
|
isLoadingWordDocument: boolean;
|
|
71
|
+
/**
|
|
72
|
+
* CSV data for display
|
|
73
|
+
* @type {any}
|
|
74
|
+
*/
|
|
75
|
+
csvData: any;
|
|
76
|
+
/**
|
|
77
|
+
* Parsed CSV data as table rows
|
|
78
|
+
* @type {any[][]}
|
|
79
|
+
*/
|
|
80
|
+
csvTableData: any[][];
|
|
81
|
+
/**
|
|
82
|
+
* Enhanced CSV data with styling information
|
|
83
|
+
* @type {CsvRowData[]}
|
|
84
|
+
*/
|
|
85
|
+
csvStyledData: CsvRowData[];
|
|
86
|
+
/**
|
|
87
|
+
* Loading state for CSV files
|
|
88
|
+
* @type {boolean}
|
|
89
|
+
*/
|
|
90
|
+
isLoadingCsv: boolean;
|
|
91
|
+
/**
|
|
92
|
+
* Error state for CSV files
|
|
93
|
+
* @type {string | null}
|
|
94
|
+
*/
|
|
95
|
+
csvError: string | null;
|
|
69
96
|
/**
|
|
70
97
|
* Configuration for the document viewer
|
|
71
98
|
* @type {any}
|
|
@@ -76,7 +103,7 @@ export declare class DocumentContentViewerComponent implements OnChanges, OnInit
|
|
|
76
103
|
* @param {ExcelParserService} excelParserService - Service for parsing Excel files
|
|
77
104
|
* @param {DocumentHttpService} documentHttpService - Service for making HTTP requests with authentication
|
|
78
105
|
*/
|
|
79
|
-
constructor(excelParserService: ExcelParserService, documentHttpService: DocumentHttpService);
|
|
106
|
+
constructor(excelParserService: ExcelParserService, csvParserService: CsvParserService, documentHttpService: DocumentHttpService);
|
|
80
107
|
/**
|
|
81
108
|
* Computed property to determine if the document is an image
|
|
82
109
|
* @type {boolean}
|
|
@@ -132,6 +159,11 @@ export declare class DocumentContentViewerComponent implements OnChanges, OnInit
|
|
|
132
159
|
* @type {ExcelRowData[]}
|
|
133
160
|
*/
|
|
134
161
|
get safeExcelStyledData(): ExcelRowData[];
|
|
162
|
+
/**
|
|
163
|
+
* Safely gets the styled CSV data for display
|
|
164
|
+
* @type {CsvRowData[]}
|
|
165
|
+
*/
|
|
166
|
+
get safeCsvStyledData(): CsvRowData[];
|
|
135
167
|
/**
|
|
136
168
|
* Handles changes to input properties
|
|
137
169
|
* @param {SimpleChanges} changes - The changes object
|
|
@@ -168,17 +200,30 @@ export declare class DocumentContentViewerComponent implements OnChanges, OnInit
|
|
|
168
200
|
*/
|
|
169
201
|
private resetExcelData;
|
|
170
202
|
/**
|
|
171
|
-
*
|
|
203
|
+
* Loads CSV data for display
|
|
204
|
+
*/
|
|
205
|
+
private loadCsvData;
|
|
206
|
+
/**
|
|
207
|
+
* Parses CSV data using the service
|
|
208
|
+
* @param {string} data - CSV file data
|
|
209
|
+
*/
|
|
210
|
+
private parseCsvData;
|
|
211
|
+
/**
|
|
212
|
+
* Resets CSV data to initial state
|
|
172
213
|
*/
|
|
173
|
-
|
|
214
|
+
private resetCsvData;
|
|
174
215
|
/**
|
|
175
|
-
*
|
|
216
|
+
* TrackBy function for CSV cells to improve performance
|
|
217
|
+
* @param index - Cell index
|
|
218
|
+
* @param cell - Cell object
|
|
219
|
+
* @returns Unique identifier for the cell
|
|
176
220
|
*/
|
|
177
|
-
|
|
221
|
+
trackByCell(index: number, cell: any): any;
|
|
178
222
|
/**
|
|
179
|
-
*
|
|
223
|
+
* Checks if CSV data is valid and ready for display
|
|
224
|
+
* @returns {boolean} True if CSV data is valid
|
|
180
225
|
*/
|
|
181
|
-
|
|
226
|
+
private isCsvDataValid;
|
|
182
227
|
static ɵfac: i0.ɵɵFactoryDeclaration<DocumentContentViewerComponent, never>;
|
|
183
228
|
static ɵcmp: i0.ɵɵComponentDeclaration<DocumentContentViewerComponent, "document-content-viewer", never, { "documentUrl": { "alias": "documentUrl"; "required": false; }; "contentType": { "alias": "contentType"; "required": false; }; "documentName": { "alias": "documentName"; "required": false; }; }, {}, never, never, false, never>;
|
|
184
229
|
}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import * as i0 from "@angular/core";
|
|
2
|
+
export interface CsvRowData {
|
|
3
|
+
cells: Array<{
|
|
4
|
+
value: string;
|
|
5
|
+
isHeader?: boolean;
|
|
6
|
+
style?: any;
|
|
7
|
+
}>;
|
|
8
|
+
}
|
|
9
|
+
export interface ParsedCsvData {
|
|
10
|
+
headers: string[];
|
|
11
|
+
rows: string[][];
|
|
12
|
+
styledData: CsvRowData[];
|
|
13
|
+
totalRows: number;
|
|
14
|
+
totalColumns: number;
|
|
15
|
+
hasHeaders: boolean;
|
|
16
|
+
}
|
|
17
|
+
export declare class CsvParserService {
|
|
18
|
+
constructor();
|
|
19
|
+
/**
|
|
20
|
+
* Parses CSV data from a string
|
|
21
|
+
* @param csvContent - The CSV content as a string
|
|
22
|
+
* @param options - Parsing options
|
|
23
|
+
* @returns Parsed CSV data
|
|
24
|
+
*/
|
|
25
|
+
parseCsvData(csvContent: string, options?: {
|
|
26
|
+
delimiter?: string;
|
|
27
|
+
hasHeaders?: boolean;
|
|
28
|
+
maxRows?: number;
|
|
29
|
+
}): ParsedCsvData;
|
|
30
|
+
/**
|
|
31
|
+
* Parses a single CSV line with proper handling of quoted fields
|
|
32
|
+
* @param line - Single CSV line
|
|
33
|
+
* @param delimiter - Field delimiter
|
|
34
|
+
* @returns Array of field values
|
|
35
|
+
*/
|
|
36
|
+
private parseCsvLine;
|
|
37
|
+
/**
|
|
38
|
+
* Creates styled data for display in tables
|
|
39
|
+
* @param headers - Column headers
|
|
40
|
+
* @param rows - Data rows
|
|
41
|
+
* @param hasHeaders - Whether the data has headers
|
|
42
|
+
* @returns Styled data array
|
|
43
|
+
*/
|
|
44
|
+
private createStyledData;
|
|
45
|
+
/**
|
|
46
|
+
* Creates empty CSV data structure
|
|
47
|
+
* @returns Empty CSV data
|
|
48
|
+
*/
|
|
49
|
+
private createEmptyCsvData;
|
|
50
|
+
/**
|
|
51
|
+
* Validates CSV content
|
|
52
|
+
* @param csvContent - CSV content to validate
|
|
53
|
+
* @returns Validation result
|
|
54
|
+
*/
|
|
55
|
+
validateCsvContent(csvContent: string): {
|
|
56
|
+
isValid: boolean;
|
|
57
|
+
errors: string[];
|
|
58
|
+
};
|
|
59
|
+
/**
|
|
60
|
+
* Counts columns in a CSV line
|
|
61
|
+
* @param line - CSV line
|
|
62
|
+
* @returns Number of columns
|
|
63
|
+
*/
|
|
64
|
+
private countColumns;
|
|
65
|
+
/**
|
|
66
|
+
* Exports data to CSV format
|
|
67
|
+
* @param data - Data to export
|
|
68
|
+
* @param headers - Column headers
|
|
69
|
+
* @param delimiter - Field delimiter
|
|
70
|
+
* @returns CSV string
|
|
71
|
+
*/
|
|
72
|
+
exportToCsv(data: string[][], headers: string[], delimiter?: string): string;
|
|
73
|
+
/**
|
|
74
|
+
* Escapes a CSV field value
|
|
75
|
+
* @param field - Field value to escape
|
|
76
|
+
* @returns Escaped field value
|
|
77
|
+
*/
|
|
78
|
+
private escapeCsvField;
|
|
79
|
+
/**
|
|
80
|
+
* Gets CSV preview (first few rows)
|
|
81
|
+
* @param csvContent - Full CSV content
|
|
82
|
+
* @param maxRows - Maximum number of rows to preview
|
|
83
|
+
* @returns Preview data
|
|
84
|
+
*/
|
|
85
|
+
getCsvPreview(csvContent: string, maxRows?: number): ParsedCsvData;
|
|
86
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<CsvParserService, never>;
|
|
87
|
+
static ɵprov: i0.ɵɵInjectableDeclaration<CsvParserService>;
|
|
88
|
+
}
|
|
@@ -154,6 +154,13 @@ export declare class DocumentHttpService {
|
|
|
154
154
|
* @returns {Observable<ArrayBuffer>} Observable that emits the file data as ArrayBuffer
|
|
155
155
|
*/
|
|
156
156
|
downloadExcelFile(documentUrl: string): Observable<ArrayBuffer>;
|
|
157
|
+
/**
|
|
158
|
+
* Downloads a CSV file with proper authentication headers
|
|
159
|
+
* Authentication is handled automatically by the HTTP interceptor
|
|
160
|
+
* @param {string} documentUrl - The URL of the CSV file to download
|
|
161
|
+
* @returns {Observable<string>} Observable that emits the file data as string
|
|
162
|
+
*/
|
|
163
|
+
downloadCsvFile(documentUrl: string): Observable<string>;
|
|
157
164
|
static ɵfac: i0.ɵɵFactoryDeclaration<DocumentHttpService, never>;
|
|
158
165
|
static ɵprov: i0.ɵɵInjectableDeclaration<DocumentHttpService>;
|
|
159
166
|
}
|