From 2df165253b01d43476d7a059083c1ca8b17fd783 Mon Sep 17 00:00:00 2001 From: Zak Burke Date: Tue, 7 Mar 2023 00:04:40 -0500 Subject: [PATCH 1/2] STCOM-1132 replace json2csv `json2csv` was abandoned after v5. Replace it with `@json2csv`. Refs STCOM-1132 --- CHANGELOG.md | 1 + lib/ExportCsv/exportToCsv.js | 5 +++-- package.json | 3 ++- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4c3348914..c518d1f2b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ * Timepicker conforms to redux-form's expected blur behavior. Refs STCOM-1119. * Add optgroup example of `Select` component in storybook. Refs STCOM-1121. * Fix Convert24hr function of timepicker to fix 'invalid date' message when timedropdown is used. Refs STCOM-1120. +* 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) diff --git a/lib/ExportCsv/exportToCsv.js b/lib/ExportCsv/exportToCsv.js index 49d471c87..4e1ff64c6 100644 --- a/lib/ExportCsv/exportToCsv.js +++ b/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 @@ -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); } diff --git a/package.json b/package.json index 3b30e2db4..fc8df2e5e 100644 --- a/package.json +++ b/package.json @@ -50,6 +50,8 @@ "@folio/eslint-config-stripes": "^6", "@folio/stripes-cli": "^2.4.0", "@folio/stripes-testing": "^4.5.0", + "@json2csv/plainjs": "^6.1.2", + "@json2csv/transforms": "^6.1.2", "@mdx-js/loader": "^1.6.22", "@storybook/addon-actions": "^6.3.6", "@storybook/addon-essentials": "^6.3.6", @@ -107,7 +109,6 @@ "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", From 5f31f71cd6926c1ab6591cd3ee2bef2a0ca65efe Mon Sep 17 00:00:00 2001 From: Zak Burke Date: Mon, 13 Mar 2023 10:17:29 -0400 Subject: [PATCH 2/2] STCOM-1132 use direct-deps, not dev-deps, dummy. --- package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index fc8df2e5e..969ed9c5a 100644 --- a/package.json +++ b/package.json @@ -50,8 +50,6 @@ "@folio/eslint-config-stripes": "^6", "@folio/stripes-cli": "^2.4.0", "@folio/stripes-testing": "^4.5.0", - "@json2csv/plainjs": "^6.1.2", - "@json2csv/transforms": "^6.1.2", "@mdx-js/loader": "^1.6.22", "@storybook/addon-actions": "^6.3.6", "@storybook/addon-essentials": "^6.3.6", @@ -104,6 +102,8 @@ }, "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",