Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

STCOM-1132 replace json2csv #2002

Draft
wants to merge 4 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Expand Up @@ -13,6 +13,7 @@
* Fix keyboard interaction with MCL Columnheaders - Enter and Spacebar can now be used to 'click' them. Refs STCOM-680.
* The Datepicker works correctly with an invalid date. Refs STCOM-1110.
* Implement timeZone support in `<Timepicker/>` default output formatter. Refs STCOM-1128.
* Replace `json2csv` with `@json2csv`. Refs STCOM-1132.

## [11.0.0](https://github.com/folio-org/stripes-components/tree/v11.0.0) (2023-01-30)
[Full Changelog](https://github.com/folio-org/stripes-components/compare/v10.3.0...v11.0.0)
Expand Down
5 changes: 3 additions & 2 deletions lib/ExportCsv/exportToCsv.js
@@ -1,4 +1,5 @@
import { Parser } from 'json2csv';
import { Parser } from '@json2csv/plainjs';
import { flatten } from '@json2csv/transforms';

// Ignoring next block in tests since we don't have a great way to suppress downloads in tests
// istanbul ignore next
Expand Down Expand Up @@ -96,7 +97,7 @@ export default function exportToCsv(objectArray, opts) {
.omit(excludeFields)
.ensureToInclude(explicitlyIncludeFields).list;

const parser = new Parser({ fields, flatten: true, header });
const parser = new Parser({ fields, header, transforms: [flatten()] });
const csv = parser.parse(objectArray);
triggerDownload(csv, filename);
}
3 changes: 2 additions & 1 deletion package.json
Expand Up @@ -102,12 +102,13 @@
},
"dependencies": {
"@folio/stripes-react-hotkeys": "^3.0.5",
"@json2csv/plainjs": "^6.1.2",
"@json2csv/transforms": "^6.1.2",
"classnames": "^2.2.5",
"currency-codes": "^1.5.0",
"dom-helpers": "^3.2.1",
"downshift": "^2.0.16",
"hoist-non-react-statics": "^3.1.0",
"json2csv": "^4.2.1",
"lodash": "^4.17.4",
"memoize-one": "^5.0.0",
"moment-range": "^4.0.2",
Expand Down