ng2csv 7.0.0 → 9.0.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.
package/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2017, 2018, 2021, 2023, 2024 Richard Russell
3
+ Copyright (c) 2017, 2018, 2021, 2023-2026 Richard Russell
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
package/README.md CHANGED
@@ -2,66 +2,47 @@
2
2
 
3
3
  [![Node.js CI](https://github.com/rars/ng2csv/actions/workflows/node.js.yml/badge.svg)](https://github.com/rars/ng2csv/actions/workflows/node.js.yml)
4
4
 
5
- Angular module for saving CSV files.
5
+ Angular library for saving CSV files.
6
6
 
7
7
  ## Quickstart
8
8
 
9
9
  1. Install `file-saver` and `ng2csv` modules from npm:
10
- ```
11
- npm install file-saver ng2csv --save
12
- ```
13
- 2. Import `Ng2CsvModule` to your app:
14
-
15
- ```
16
- import { BrowserModule } from '@angular/platform-browser';
17
- import { NgModule } from '@angular/core';
18
- import { Ng2CsvModule } from 'ng2csv';
19
- import { AppComponent } from './app.component';
20
-
21
- @NgModule({
22
- declarations: [
23
- AppComponent
24
- ],
25
- imports: [
26
- BrowserModule,
27
- Ng2CsvModule
28
- ],
29
- providers: [],
30
- bootstrap: [AppComponent]
31
- })
32
- export class AppModule { }
33
- ```
34
-
35
- 3. Inject the `Ng2CsvService` into your component:
36
-
37
- ```
38
- import { Component } from '@angular/core';
39
- import { Ng2CsvService } from 'ng2csv';
40
-
41
- @Component({
42
- selector: 'app-root',
43
- templateUrl: './app.component.html',
44
- styleUrls: ['./app.component.css'],
45
- providers: [Ng2CsvService]
46
- })
47
- export class AppComponent {
48
- public constructor(private ng2Csv: Ng2CsvService) {}
49
-
50
- public download(): void {
51
- this.ng2Csv.download([
52
- {
53
- id: 1,
54
- name: 'Alice'
55
- },
56
- {
57
- id: 2,
58
- name: 'Bob'
59
- }
60
- ],
61
- 'names.csv');
62
- }
63
- }
64
- ```
10
+
11
+ ```bash
12
+ npm install file-saver ng2csv --save
13
+ ```
14
+
15
+ 2. Inject the `Ng2CsvService` into your component:
16
+
17
+ ```ts
18
+ import { Component, inject } from '@angular/core';
19
+ import { Ng2CsvService } from 'ng2csv';
20
+
21
+ @Component({
22
+ selector: 'app-root',
23
+ templateUrl: './app.component.html',
24
+ styleUrls: ['./app.component.css'],
25
+ })
26
+ export class AppComponent {
27
+ private readonly ng2Csv = inject(Ng2CsvService);
28
+
29
+ public download(): void {
30
+ this.ng2Csv.download(
31
+ [
32
+ {
33
+ id: 1,
34
+ name: 'Alice',
35
+ },
36
+ {
37
+ id: 2,
38
+ name: 'Bob',
39
+ },
40
+ ],
41
+ 'names.csv',
42
+ );
43
+ }
44
+ }
45
+ ```
65
46
 
66
47
  ## Configuration
67
48
 
@@ -73,12 +54,12 @@ Unless specified, an automatic mapping is used from the data to columns. It does
73
54
 
74
55
  You can output a subset of the data's properties to CSV by defining your own custom mapping. This allows you to specify the order columns are written in and what value is written for each row in each column.
75
56
 
76
- ```
57
+ ```ts
77
58
  import { OrderedProjectionCsvRowMapper } from 'ng2csv';
78
59
  // ...
79
60
  const rowMapper = new OrderedProjectionCsvRowMapper<MyType>([
80
- ['First Name', x => x.Name],
81
- ['Identifier', x => 'N' + x.Id.toString()]
61
+ ['First Name', (x) => x.Name],
62
+ ['Identifier', (x) => 'N' + x.Id.toString()],
82
63
  ]);
83
64
  this.ng2Csv.download(myData, 'file.csv', rowMapper);
84
65
  /*
@@ -93,7 +74,7 @@ this.ng2Csv.download(myData, 'file.csv', rowMapper);
93
74
 
94
75
  You can control what character is used to separate columns (e.g. to use ';' or tab separators rather than ',') and whether to include a header row.
95
76
 
96
- ```
77
+ ```ts
97
78
  import { CsvConfiguration } from 'ng2csv';
98
79
  // ...
99
80
  const csvConfig = new CsvConfiguration();
@@ -106,7 +87,7 @@ this.ng2Csv.download(myData, 'file.csv', undefined, csvConfig);
106
87
 
107
88
  You can control how `null` or `undefined` values are written out in config.
108
89
 
109
- ```
90
+ ```ts
110
91
  import { CsvConfiguration } from 'ng2csv';
111
92
  // ...
112
93
  const csvConfig = new CsvConfiguration();
@@ -1,159 +1,113 @@
1
- import * as i0 from '@angular/core';
2
- import { Injectable, NgModule } from '@angular/core';
3
- import { saveAs } from 'file-saver';
1
+ import * as i0 from "@angular/core";
2
+ import { Service } from "@angular/core";
3
+ import { saveAs } from "file-saver";
4
+ var OrderedProjectionCsvRowMapper = class {
5
+ projections;
6
+ constructor(projections) {
7
+ this.projections = projections;
8
+ }
9
+ getColumnNames() {
10
+ return this.projections.map((x) => x[0]);
11
+ }
12
+ map(obj) {
13
+ return this.projections.map((x) => x[1](obj));
14
+ }
15
+ };
16
+ var AutoCsvRowMapper = class {
17
+ derivedCsvRowMapper;
18
+ constructor(data) {
19
+ if (!data || data.length === 0) throw new Error("Parameter 'data' must be a non-empty array of objects.");
20
+ if (typeof data[0] !== "object") throw new Error("Parameter 'data' must contain objects.");
21
+ const projections = [];
22
+ const allKeys = this.getAllKeys(data);
23
+ for (const key of allKeys) projections.push([key, this.createProjection(key)]);
24
+ this.derivedCsvRowMapper = new OrderedProjectionCsvRowMapper(projections);
25
+ }
26
+ getColumnNames() {
27
+ return this.derivedCsvRowMapper.getColumnNames();
28
+ }
29
+ map(obj) {
30
+ return this.derivedCsvRowMapper.map(obj);
31
+ }
32
+ createProjection(property) {
33
+ return (x) => {
34
+ if (x && typeof x === "object" && Object.hasOwn(x, property)) {
35
+ const propertyValue = x[property];
36
+ if (propertyValue === void 0 || propertyValue === null) return "";
37
+ return propertyValue.toString();
38
+ } else return "";
39
+ };
40
+ }
41
+ getAllKeys(objs) {
42
+ const allKeys = {};
43
+ for (const obj of objs) for (const objectKey of Object.keys(obj)) allKeys[objectKey] = 1;
44
+ return Object.keys(allKeys);
45
+ }
46
+ };
47
+ var CsvConfiguration = class {
48
+ delimiter = ",";
49
+ quote = "\"";
50
+ newLine = "\r\n";
51
+ includeHeaderLine = true;
52
+ outputValueForNull = "";
53
+ outputValueForUndefined = "";
54
+ };
55
+ var Ng2CsvService = class Ng2CsvService {
56
+ download(data, filename, csvRowMapper, config = new CsvConfiguration()) {
57
+ const csvData = this.convertToCsv(data, csvRowMapper, config);
58
+ const mimeType = "text/csv; header=" + (config.includeHeaderLine ? "present" : "absent");
59
+ const csvBlob = new Blob([csvData], { type: mimeType });
60
+ saveAs(csvBlob, filename, { autoBom: false });
61
+ }
62
+ convertToCsv(data, csvRowMapper, config = new CsvConfiguration()) {
63
+ if (csvRowMapper === void 0) csvRowMapper = new AutoCsvRowMapper(data);
64
+ const rows = [];
65
+ if (config.includeHeaderLine) {
66
+ const headerFieldSeparator = `${config.quote}${config.delimiter}${config.quote}`;
67
+ rows.push(config.quote + csvRowMapper.getColumnNames().map((x) => this.escapeQuotes(x, config.quote)).join(headerFieldSeparator) + config.quote);
68
+ }
69
+ for (const row of data) rows.push(csvRowMapper.map(row).map((x) => this.mapNullOrUndefinedValues(x, config)).map((x) => this.escapeRowValue(x, config)).join(config.delimiter));
70
+ return rows.join(config.newLine);
71
+ }
72
+ mapNullOrUndefinedValues(value, config) {
73
+ switch (value) {
74
+ case null: return config.outputValueForNull;
75
+ case void 0: return config.outputValueForUndefined;
76
+ default: return value;
77
+ }
78
+ }
79
+ escapeQuotes(value, quoteChar) {
80
+ return value.replace(new RegExp(quoteChar.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), "g"), quoteChar + quoteChar);
81
+ }
82
+ escapeRowValue(value, config) {
83
+ if (value.indexOf(config.delimiter) > -1 || value.indexOf(config.quote) > -1) {
84
+ const escapedValue = this.escapeQuotes(value, config.quote);
85
+ return `${config.quote}${escapedValue}${config.quote}`;
86
+ }
87
+ return value;
88
+ }
89
+ static ɵfac = i0.ɵɵngDeclareFactory({
90
+ minVersion: "12.0.0",
91
+ version: "22.2.1",
92
+ ngImport: i0,
93
+ type: Ng2CsvService,
94
+ deps: [],
95
+ target: i0.ɵɵFactoryTarget.Service
96
+ });
97
+ static ɵprov = i0.ɵɵngDeclareService({
98
+ minVersion: "22.0.0",
99
+ version: "22.2.1",
100
+ ngImport: i0,
101
+ type: Ng2CsvService
102
+ });
103
+ };
104
+ i0.ɵɵngDeclareClassMetadata({
105
+ minVersion: "12.0.0",
106
+ version: "22.2.1",
107
+ ngImport: i0,
108
+ type: Ng2CsvService,
109
+ decorators: [{ type: Service }]
110
+ });
111
+ export { AutoCsvRowMapper, CsvConfiguration, Ng2CsvService, OrderedProjectionCsvRowMapper };
4
112
 
5
- class OrderedProjectionCsvRowMapper {
6
- constructor(projections) {
7
- this.projections = projections;
8
- }
9
- getColumnNames() {
10
- return this.projections.map(x => x[0]);
11
- }
12
- map(obj) {
13
- return this.projections.map(x => x[1](obj));
14
- }
15
- }
16
-
17
- class AutoCsvRowMapper {
18
- constructor(data) {
19
- if (!data || data.length === 0) {
20
- throw new Error('Parameter \'data\' must be a non-empty array of objects.');
21
- }
22
- if (typeof data[0] !== 'object') {
23
- throw new Error('Parameter \'data\' must contain objects.');
24
- }
25
- const projections = [];
26
- const allKeys = this.getAllKeys(data);
27
- for (const key of allKeys) {
28
- projections.push([
29
- key,
30
- this.createProjection(key)
31
- ]);
32
- }
33
- this.derivedCsvRowMapper = new OrderedProjectionCsvRowMapper(projections);
34
- }
35
- getColumnNames() {
36
- return this.derivedCsvRowMapper.getColumnNames();
37
- }
38
- map(obj) {
39
- return this.derivedCsvRowMapper.map(obj);
40
- }
41
- createProjection(property) {
42
- return (x) => {
43
- if (x.hasOwnProperty(property)) {
44
- const propertyValue = x[property];
45
- if (propertyValue === undefined || propertyValue === null) {
46
- return '';
47
- }
48
- return propertyValue.toString();
49
- }
50
- else {
51
- return '';
52
- }
53
- };
54
- }
55
- getAllKeys(objs) {
56
- const allKeys = {};
57
- for (const obj of objs) {
58
- for (const objectKey of Object.keys(obj)) {
59
- allKeys[objectKey] = 1;
60
- }
61
- }
62
- return Object.keys(allKeys);
63
- }
64
- }
65
-
66
- class CsvConfiguration {
67
- constructor() {
68
- this.delimiter = ',';
69
- this.quote = '"';
70
- this.newLine = '\r\n';
71
- this.includeHeaderLine = true;
72
- this.outputValueForNull = '';
73
- this.outputValueForUndefined = '';
74
- }
75
- }
76
-
77
- class Ng2CsvService {
78
- download(data, filename, csvRowMapper, config = new CsvConfiguration()) {
79
- const csvData = this.convertToCsv(data, csvRowMapper, config);
80
- const mimeType = 'text/csv; header='
81
- + (config.includeHeaderLine ? 'present' : 'absent');
82
- const csvBlob = new Blob([csvData], { type: mimeType });
83
- saveAs(csvBlob, filename, true);
84
- }
85
- convertToCsv(data, csvRowMapper, config = new CsvConfiguration()) {
86
- if (csvRowMapper === undefined) {
87
- csvRowMapper = new AutoCsvRowMapper(data);
88
- }
89
- const rows = [];
90
- if (config.includeHeaderLine) {
91
- const headerFieldSeparator = `${config.quote}${config.delimiter}${config.quote}`;
92
- rows.push(config.quote
93
- + csvRowMapper.getColumnNames()
94
- .map(x => this.escapeQuotes(x, config.quote))
95
- .join(headerFieldSeparator)
96
- + config.quote);
97
- }
98
- for (const row of data) {
99
- rows.push(csvRowMapper.map(row)
100
- .map(x => this.mapNullOrUndefinedValues(x, config))
101
- .map(x => this.escapeRowValue(x, config))
102
- .join(config.delimiter));
103
- }
104
- return rows.join(config.newLine);
105
- }
106
- mapNullOrUndefinedValues(value, config) {
107
- switch (value) {
108
- case null: {
109
- return config.outputValueForNull;
110
- }
111
- case undefined: {
112
- return config.outputValueForUndefined;
113
- }
114
- default: {
115
- return value;
116
- }
117
- }
118
- }
119
- escapeQuotes(value, quoteChar) {
120
- return value.replace(new RegExp(quoteChar.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'), 'g'), quoteChar + quoteChar);
121
- }
122
- escapeRowValue(value, config) {
123
- if (value.indexOf(config.delimiter) > -1
124
- || value.indexOf(config.quote) > -1) {
125
- const escapedValue = this.escapeQuotes(value, config.quote);
126
- return `${config.quote}${escapedValue}${config.quote}`;
127
- }
128
- return value;
129
- }
130
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.0.6", ngImport: i0, type: Ng2CsvService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
131
- static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.0.6", ngImport: i0, type: Ng2CsvService, providedIn: 'root' }); }
132
- }
133
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.0.6", ngImport: i0, type: Ng2CsvService, decorators: [{
134
- type: Injectable,
135
- args: [{
136
- providedIn: 'root'
137
- }]
138
- }] });
139
-
140
- class Ng2CsvModule {
141
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.0.6", ngImport: i0, type: Ng2CsvModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
142
- static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "20.0.6", ngImport: i0, type: Ng2CsvModule }); }
143
- static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "20.0.6", ngImport: i0, type: Ng2CsvModule }); }
144
- }
145
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.0.6", ngImport: i0, type: Ng2CsvModule, decorators: [{
146
- type: NgModule,
147
- args: [{}]
148
- }] });
149
-
150
- /*
151
- * Public API Surface of ng2csv
152
- */
153
-
154
- /**
155
- * Generated bundle index. Do not edit.
156
- */
157
-
158
- export { AutoCsvRowMapper, CsvConfiguration, Ng2CsvModule, Ng2CsvService, OrderedProjectionCsvRowMapper };
159
- //# sourceMappingURL=ng2csv.mjs.map
113
+ //# sourceMappingURL=ng2csv.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"ng2csv.mjs","sources":["../../../projects/ng2csv/src/lib/ordered-projection-csv-row-mapper.class.ts","../../../projects/ng2csv/src/lib/auto-csv-row-mapper.class.ts","../../../projects/ng2csv/src/lib/csv-configuration.class.ts","../../../projects/ng2csv/src/lib/ng2csv.service.ts","../../../projects/ng2csv/src/lib/ng2csv.module.ts","../../../projects/ng2csv/src/public-api.ts","../../../projects/ng2csv/src/ng2csv.ts"],"sourcesContent":["import { ICsvRowMapper } from './csv-row-mapper.interface';\n\nexport class OrderedProjectionCsvRowMapper<T>\n implements ICsvRowMapper<T> {\n\n private projections: Array<[string, (obj: T) => string]>;\n\n public constructor(\n projections: Array<[string, (obj: T) => string]>) {\n this.projections = projections;\n }\n\n public getColumnNames(): string[] {\n return this.projections.map(x => x[0]);\n }\n\n public map(obj: T): string[] {\n return this.projections.map(x => x[1](obj));\n }\n}\n","import { ICsvRowMapper } from './csv-row-mapper.interface';\nimport { OrderedProjectionCsvRowMapper } from './ordered-projection-csv-row-mapper.class';\n\nexport class AutoCsvRowMapper<T> implements ICsvRowMapper<T> {\n\n private derivedCsvRowMapper: OrderedProjectionCsvRowMapper<T>;\n\n public constructor(data: T[]) {\n if (!data || data.length === 0) {\n throw new Error(\n 'Parameter \\'data\\' must be a non-empty array of objects.');\n }\n\n if (typeof data[0] !== 'object') {\n throw new Error(\n 'Parameter \\'data\\' must contain objects.'\n );\n }\n\n const projections: Array<[string, (obj: T) => string]> = [];\n\n const allKeys: string[] = this.getAllKeys(data);\n for (const key of allKeys) {\n projections.push([\n key,\n this.createProjection(key)\n ]);\n }\n\n this.derivedCsvRowMapper = new OrderedProjectionCsvRowMapper<T>(\n projections\n );\n }\n\n public getColumnNames(): string[] {\n return this.derivedCsvRowMapper.getColumnNames();\n }\n\n public map(obj: T): string[] {\n return this.derivedCsvRowMapper.map(obj);\n }\n\n private createProjection(property: string): (obj: T) => string {\n return (x: T) => {\n if (x.hasOwnProperty(property)) {\n const propertyValue = (x as any)[property];\n if (propertyValue === undefined || propertyValue === null) {\n return '';\n }\n return propertyValue.toString();\n } else {\n return '';\n }\n };\n }\n\n private getAllKeys(objs: T[]): string[] {\n const allKeys: any = {};\n\n for (const obj of objs) {\n for (const objectKey of Object.keys(obj)) {\n allKeys[objectKey] = 1;\n }\n }\n\n return Object.keys(allKeys);\n }\n}\n","export class CsvConfiguration {\n public delimiter = ',';\n public quote = '\"';\n public newLine = '\\r\\n';\n public includeHeaderLine = true;\n public outputValueForNull = '';\n public outputValueForUndefined = '';\n}\n","import { Injectable } from '@angular/core';\nimport { saveAs } from 'file-saver';\nimport { AutoCsvRowMapper } from './auto-csv-row-mapper.class';\nimport { CsvConfiguration } from './csv-configuration.class';\nimport { ICsvRowMapper } from './csv-row-mapper.interface';\n\n@Injectable({\n providedIn: 'root'\n})\nexport class Ng2CsvService {\n public download<T>(\n data: T[],\n filename: string,\n csvRowMapper?: ICsvRowMapper<T>,\n config: CsvConfiguration = new CsvConfiguration()): void {\n const csvData: string = this.convertToCsv(data, csvRowMapper, config);\n\n const mimeType: string = 'text/csv; header='\n + (config.includeHeaderLine ? 'present' : 'absent');\n\n const csvBlob: Blob = new Blob([csvData], { type: mimeType });\n saveAs(csvBlob, filename, true);\n }\n\n public convertToCsv<T>(\n data: T[],\n csvRowMapper?: ICsvRowMapper<T>,\n config: CsvConfiguration = new CsvConfiguration()): string {\n if (csvRowMapper === undefined) {\n csvRowMapper = new AutoCsvRowMapper(data);\n }\n\n const rows: string[] = [];\n\n if (config.includeHeaderLine) {\n const headerFieldSeparator =\n `${config.quote}${config.delimiter}${config.quote}`;\n rows.push(config.quote\n + csvRowMapper.getColumnNames()\n .map(x => this.escapeQuotes(x, config.quote))\n .join(headerFieldSeparator)\n + config.quote);\n }\n\n for (const row of data) {\n rows.push(csvRowMapper.map(row)\n .map(x => this.mapNullOrUndefinedValues(x, config))\n .map(x => this.escapeRowValue(x, config))\n .join(config.delimiter));\n }\n\n return rows.join(config.newLine);\n }\n\n private mapNullOrUndefinedValues(\n value: string,\n config: CsvConfiguration): string {\n switch (value) {\n case null: {\n return config.outputValueForNull;\n }\n case undefined: {\n return config.outputValueForUndefined;\n }\n default: {\n return value;\n }\n }\n }\n\n private escapeQuotes(\n value: string,\n quoteChar: string): string {\n return value.replace(\n new RegExp(quoteChar.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&'), 'g'),\n quoteChar + quoteChar);\n }\n\n private escapeRowValue(\n value: string,\n config: CsvConfiguration): string {\n if (value.indexOf(config.delimiter) > -1\n || value.indexOf(config.quote) > -1) {\n const escapedValue = this.escapeQuotes(value, config.quote);\n return `${config.quote}${escapedValue}${config.quote}`;\n }\n return value;\n }\n}\n","import { NgModule } from '@angular/core';\n\n@NgModule({})\nexport class Ng2CsvModule { }\n","/*\n * Public API Surface of ng2csv\n */\n\nexport * from './lib/ng2csv.service';\nexport * from './lib/ng2csv.module';\nexport * from './lib/auto-csv-row-mapper.class';\nexport * from './lib/csv-configuration.class';\nexport * from './lib/csv-row-mapper.interface';\nexport * from './lib/ordered-projection-csv-row-mapper.class';\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;;MAEa,6BAA6B,CAAA;AAKxC,IAAA,WAAA,CACI,WAAgD,EAAA;AAClD,QAAA,IAAI,CAAC,WAAW,GAAG,WAAW;;IAGzB,cAAc,GAAA;AACnB,QAAA,OAAO,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;;AAGjC,IAAA,GAAG,CAAC,GAAM,EAAA;AACf,QAAA,OAAO,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;;AAE9C;;MChBY,gBAAgB,CAAA;AAI3B,IAAA,WAAA,CAAmB,IAAS,EAAA;QAC1B,IAAI,CAAC,IAAI,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC,EAAE;AAC9B,YAAA,MAAM,IAAI,KAAK,CACb,0DAA0D,CAAC;;QAG/D,IAAI,OAAO,IAAI,CAAC,CAAC,CAAC,KAAK,QAAQ,EAAE;AAC/B,YA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AAO,CAAA,EAAG,MAAM,CAAC,KAAK,CAAA,EAAG,YAAY,CAAA,EAAG,MAAM,CAAC,KAAK,CAAA,CAAE;;AAExD,QAAA,OAAO,KAAK;;8GA7EH,aAAa,EAAA,IAAA,EAAA,EAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,UAAA,EAAA,CAAA,CAAA;AAAb,IAAA,SAAA,IAAA,CAAA,KAAA,GAAA,EAAA,CAAA,qBAAA,CAAA,EAAA,UAAA,EAAA,QAAA,EAAA,OAAA,EAAA,QAAA,EAAA,QAAA,EAAA,EAAA,EAAA,IAAA,EAAA,aAAa,cAFZ,MAAM,EAAA,CAAA,CAAA;;2FAEP,aAAa,EAAA,UAAA,EAAA,CAAA;kBAHzB,UAAU;AAAC,YAAA,IAAA,EAAA,CAAA;AACV,oBAAA,UAAU,EAAE;AACb,iBAAA;;;MCLY,YAAY,CAAA;8GAAZ,YAAY,EAAA,IAAA,EAAA,EAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,QAAA,EAAA,CAAA,CAAA;+GAAZ,YAAY,EAAA,CAAA,CAAA;+GAAZ,YAAY,EAAA,CAAA,CAAA;;2FAAZ,YAAY,EAAA,UAAA,EAAA,CAAA;kBADxB,QAAQ;mBAAC,EAAE;;;ACFZ;;AAEG;;ACFH;;AAEG;;;;"}
1
+ {"version":3,"file":"ng2csv.mjs","names":[],"sources":["../../../projects/ng2csv/src/lib/ordered-projection-csv-row-mapper.class.ts","../../../projects/ng2csv/src/lib/auto-csv-row-mapper.class.ts","../../../projects/ng2csv/src/lib/csv-configuration.class.ts","../../../projects/ng2csv/src/lib/ng2csv.service.ts"],"sourcesContent":["import { ICsvRowMapper } from './csv-row-mapper.interface';\n\nexport class OrderedProjectionCsvRowMapper<T> implements ICsvRowMapper<T> {\n private readonly projections: Array<\n [string, (obj: T) => string | null | undefined]\n >;\n\n public constructor(\n projections: Array<[string, (obj: T) => string | null | undefined]>\n ) {\n this.projections = projections;\n }\n\n public getColumnNames(): string[] {\n return this.projections.map((x) => x[0]);\n }\n\n public map(obj: T): (string | null | undefined)[] {\n return this.projections.map((x) => x[1](obj));\n }\n}\n","import { ICsvRowMapper } from './csv-row-mapper.interface';\nimport { OrderedProjectionCsvRowMapper } from './ordered-projection-csv-row-mapper.class';\n\nexport class AutoCsvRowMapper<T extends object> implements ICsvRowMapper<T> {\n private derivedCsvRowMapper: OrderedProjectionCsvRowMapper<T>;\n\n public constructor(data: T[]) {\n if (!data || data.length === 0) {\n throw new Error(\"Parameter 'data' must be a non-empty array of objects.\");\n }\n\n if (typeof data[0] !== 'object') {\n throw new Error(\"Parameter 'data' must contain objects.\");\n }\n\n const projections: Array<[string, (obj: T) => string]> = [];\n\n const allKeys: string[] = this.getAllKeys(data);\n for (const key of allKeys) {\n projections.push([key, this.createProjection(key)]);\n }\n\n this.derivedCsvRowMapper = new OrderedProjectionCsvRowMapper<T>(\n projections,\n );\n }\n\n public getColumnNames(): string[] {\n return this.derivedCsvRowMapper.getColumnNames();\n }\n\n public map(obj: T): (string | null | undefined)[] {\n return this.derivedCsvRowMapper.map(obj);\n }\n\n private createProjection(property: string): (obj: T) => string {\n return (x: T) => {\n if (x && typeof x === 'object' && Object.hasOwn(x, property)) {\n const propertyValue = x[property as keyof T];\n if (propertyValue === undefined || propertyValue === null) {\n return '';\n }\n return propertyValue.toString();\n } else {\n return '';\n }\n };\n }\n\n private getAllKeys(objs: T[]): string[] {\n const allKeys: { [key: string]: number } = {};\n\n for (const obj of objs) {\n for (const objectKey of Object.keys(obj)) {\n allKeys[objectKey] = 1;\n }\n }\n\n return Object.keys(allKeys);\n }\n}\n","export class CsvConfiguration {\n public delimiter = ',';\n public quote = '\"';\n public newLine = '\\r\\n';\n public includeHeaderLine = true;\n public outputValueForNull = '';\n public outputValueForUndefined = '';\n}\n","import { Service } from '@angular/core';\nimport { saveAs } from 'file-saver';\nimport { AutoCsvRowMapper } from './auto-csv-row-mapper.class';\nimport { CsvConfiguration } from './csv-configuration.class';\nimport { ICsvRowMapper } from './csv-row-mapper.interface';\n\n@Service()\nexport class Ng2CsvService {\n public download<T extends object>(\n data: T[],\n filename: string,\n csvRowMapper?: ICsvRowMapper<T>,\n config: CsvConfiguration = new CsvConfiguration(),\n ): void {\n const csvData: string = this.convertToCsv(data, csvRowMapper, config);\n\n const mimeType: string =\n 'text/csv; header=' + (config.includeHeaderLine ? 'present' : 'absent');\n\n const csvBlob: Blob = new Blob([csvData], { type: mimeType });\n saveAs(csvBlob, filename, { autoBom: false });\n }\n\n public convertToCsv<T extends object>(\n data: T[],\n csvRowMapper?: ICsvRowMapper<T>,\n config: CsvConfiguration = new CsvConfiguration(),\n ): string {\n if (csvRowMapper === undefined) {\n csvRowMapper = new AutoCsvRowMapper(data);\n }\n\n const rows: string[] = [];\n\n if (config.includeHeaderLine) {\n const headerFieldSeparator = `${config.quote}${config.delimiter}${config.quote}`;\n rows.push(\n config.quote +\n csvRowMapper\n .getColumnNames()\n .map((x) => this.escapeQuotes(x, config.quote))\n .join(headerFieldSeparator) +\n config.quote,\n );\n }\n\n for (const row of data) {\n rows.push(\n csvRowMapper\n .map(row)\n .map((x) => this.mapNullOrUndefinedValues(x, config))\n .map((x) => this.escapeRowValue(x, config))\n .join(config.delimiter),\n );\n }\n\n return rows.join(config.newLine);\n }\n\n private mapNullOrUndefinedValues(\n value: string | null | undefined,\n config: CsvConfiguration,\n ): string {\n switch (value) {\n case null: {\n return config.outputValueForNull;\n }\n case undefined: {\n return config.outputValueForUndefined;\n }\n default: {\n return value;\n }\n }\n }\n\n private escapeQuotes(value: string, quoteChar: string): string {\n return value.replace(\n new RegExp(quoteChar.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&'), 'g'),\n quoteChar + quoteChar,\n );\n }\n\n private escapeRowValue(value: string, config: CsvConfiguration): string {\n if (\n value.indexOf(config.delimiter) > -1 ||\n value.indexOf(config.quote) > -1\n ) {\n const escapedValue = this.escapeQuotes(value, config.quote);\n return `${config.quote}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,GAAG,GAAG,GAChE,YAAY,SAAS;CAEzB;CAEQ,eAAe,OAAe,QAAwB;EAC5D,IACE,MAAM,QAAQ,OAAO,SAAS,IAAI,MAClC,MAAM,QAAQ,OAAO,KAAK,IAAI,IAC9B;GACA,MAAM,eAAe,KAAK,aAAa,OAAO,OAAO,KAAK;GAC1D,OAAO,GAAG,OAAO,QAAQ,eAAe,OAAO;EACjD;EACA,OAAO;CACT;CArFW,OAAA,OAAA,GAAA,mBAAA;EAAA,YAAA;EAAA,SAAA;EAAA,UAAA;EAAA,MAAA;EAAa,MAAA,CAAA;EAAA,QAAA,GAAA,gBAAA;CAAA,CAAA;CAAb,OAAA,QAAA,GAAA,mBAAA;EAAA,YAAA;EAAA,SAAA;EAAA,UAAA;EAAA,MAAA;CAAa,CAAA;;AAAb,GAAA,yBAAA;CAAA,YAAA;CAAA,SAAA;CAAA,UAAA;CAAA,MAAA;CAAa,YAAA,CAAA,EADzB,MAAA,QAAA,CAAA"}
package/package.json CHANGED
@@ -1,11 +1,12 @@
1
1
  {
2
2
  "name": "ng2csv",
3
- "version": "7.0.0",
3
+ "version": "9.0.0",
4
+ "description": "An Angular library for exporting data to CSV.",
4
5
  "dependencies": {
5
6
  "tslib": "^2.0.0"
6
7
  },
7
8
  "peerDependencies": {
8
- "@angular/core": "^19.0.0",
9
+ "@angular/core": "^22.0.0",
9
10
  "file-saver": "^2.0.0"
10
11
  },
11
12
  "repository": {
@@ -24,15 +25,16 @@
24
25
  },
25
26
  "homepage": "https://github.com/rars/ng2csv#readme",
26
27
  "module": "fesm2022/ng2csv.mjs",
27
- "typings": "index.d.ts",
28
+ "typings": "types/ng2csv.d.ts",
28
29
  "exports": {
29
30
  "./package.json": {
30
31
  "default": "./package.json"
31
32
  },
32
33
  ".": {
33
- "types": "./index.d.ts",
34
+ "types": "./types/ng2csv.d.ts",
34
35
  "default": "./fesm2022/ng2csv.mjs"
35
36
  }
36
37
  },
37
- "sideEffects": false
38
+ "sideEffects": false,
39
+ "type": "module"
38
40
  }
@@ -0,0 +1,36 @@
1
+ import * as i0 from "@angular/core";
2
+ export declare class CsvConfiguration {
3
+ delimiter: string;
4
+ quote: string;
5
+ newLine: string;
6
+ includeHeaderLine: boolean;
7
+ outputValueForNull: string;
8
+ outputValueForUndefined: string;
9
+ }
10
+ export interface ICsvRowMapper<T> {
11
+ getColumnNames(): string[];
12
+ map(obj: T): (string | null | undefined)[];
13
+ }
14
+ export declare class Ng2CsvService {
15
+ download<T extends object>(data: T[], filename: string, csvRowMapper?: ICsvRowMapper<T>, config?: CsvConfiguration): void;
16
+ convertToCsv<T extends object>(data: T[], csvRowMapper?: ICsvRowMapper<T>, config?: CsvConfiguration): string;
17
+ private mapNullOrUndefinedValues;
18
+ private escapeQuotes;
19
+ private escapeRowValue;
20
+ static ɵfac: i0.ɵɵFactoryDeclaration<Ng2CsvService, never>;
21
+ static ɵprov: i0.ɵɵInjectableDeclaration<any>;
22
+ }
23
+ export declare class AutoCsvRowMapper<T extends object> implements ICsvRowMapper<T> {
24
+ private derivedCsvRowMapper;
25
+ constructor(data: T[]);
26
+ getColumnNames(): string[];
27
+ map(obj: T): (string | null | undefined)[];
28
+ private createProjection;
29
+ private getAllKeys;
30
+ }
31
+ export declare class OrderedProjectionCsvRowMapper<T> implements ICsvRowMapper<T> {
32
+ private readonly projections;
33
+ constructor(projections: Array<[string, (obj: T) => string | null | undefined]>);
34
+ getColumnNames(): string[];
35
+ map(obj: T): (string | null | undefined)[];
36
+ }
package/index.d.ts DELETED
@@ -1,50 +0,0 @@
1
- import * as i0 from '@angular/core';
2
-
3
- declare class CsvConfiguration {
4
- delimiter: string;
5
- quote: string;
6
- newLine: string;
7
- includeHeaderLine: boolean;
8
- outputValueForNull: string;
9
- outputValueForUndefined: string;
10
- }
11
-
12
- interface ICsvRowMapper<T> {
13
- getColumnNames(): string[];
14
- map(obj: T): string[];
15
- }
16
-
17
- declare class Ng2CsvService {
18
- download<T>(data: T[], filename: string, csvRowMapper?: ICsvRowMapper<T>, config?: CsvConfiguration): void;
19
- convertToCsv<T>(data: T[], csvRowMapper?: ICsvRowMapper<T>, config?: CsvConfiguration): string;
20
- private mapNullOrUndefinedValues;
21
- private escapeQuotes;
22
- private escapeRowValue;
23
- static ɵfac: i0.ɵɵFactoryDeclaration<Ng2CsvService, never>;
24
- static ɵprov: i0.ɵɵInjectableDeclaration<Ng2CsvService>;
25
- }
26
-
27
- declare class Ng2CsvModule {
28
- static ɵfac: i0.ɵɵFactoryDeclaration<Ng2CsvModule, never>;
29
- static ɵmod: i0.ɵɵNgModuleDeclaration<Ng2CsvModule, never, never, never>;
30
- static ɵinj: i0.ɵɵInjectorDeclaration<Ng2CsvModule>;
31
- }
32
-
33
- declare class AutoCsvRowMapper<T> implements ICsvRowMapper<T> {
34
- private derivedCsvRowMapper;
35
- constructor(data: T[]);
36
- getColumnNames(): string[];
37
- map(obj: T): string[];
38
- private createProjection;
39
- private getAllKeys;
40
- }
41
-
42
- declare class OrderedProjectionCsvRowMapper<T> implements ICsvRowMapper<T> {
43
- private projections;
44
- constructor(projections: Array<[string, (obj: T) => string]>);
45
- getColumnNames(): string[];
46
- map(obj: T): string[];
47
- }
48
-
49
- export { AutoCsvRowMapper, CsvConfiguration, Ng2CsvModule, Ng2CsvService, OrderedProjectionCsvRowMapper };
50
- export type { ICsvRowMapper };