@linzjs/step-ag-grid 13.4.0 → 13.5.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.
- package/dist/index.css +2 -1
- package/dist/src/utils/util.d.ts +7 -0
- package/dist/src/utils/util.test.d.ts +1 -0
- package/dist/step-ag-grid.esm.js +151 -37
- package/dist/step-ag-grid.esm.js.map +1 -1
- package/package.json +4 -3
- package/src/contexts/GridContextProvider.tsx +4 -1
- package/src/stories/grid/GridReadOnly.stories.tsx +1 -1
- package/src/styles/Grid.scss +2 -1
- package/src/utils/util.test.ts +8 -0
- package/src/utils/util.ts +10 -0
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@linzjs/step-ag-grid",
|
|
3
3
|
"repository": "github:linz/step-ag-grid.git",
|
|
4
4
|
"license": "MIT",
|
|
5
|
-
"version": "13.
|
|
5
|
+
"version": "13.5.1",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"aggrid",
|
|
8
8
|
"ag-grid",
|
|
@@ -36,14 +36,15 @@
|
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
38
|
"@linzjs/lui": ">=17",
|
|
39
|
-
"ag-grid-community": "27
|
|
40
|
-
"ag-grid-react": "
|
|
39
|
+
"ag-grid-community": ">=27",
|
|
40
|
+
"ag-grid-react": ">=27",
|
|
41
41
|
"debounce-promise": "^3.1.2",
|
|
42
42
|
"lodash-es": ">=4",
|
|
43
43
|
"matcher": "^5.0.0",
|
|
44
44
|
"react": ">=17",
|
|
45
45
|
"react-dom": ">=17",
|
|
46
46
|
"react-transition-state": "^2.0.2",
|
|
47
|
+
"sanitize-filename": "^1.6.3",
|
|
47
48
|
"uuid": "^9.0.0"
|
|
48
49
|
},
|
|
49
50
|
"scripts": {
|
|
@@ -6,7 +6,7 @@ import { compact, debounce, defer, delay, difference, isEmpty, last, remove, sor
|
|
|
6
6
|
import { ReactElement, ReactNode, useCallback, useContext, useEffect, useMemo, useRef, useState } from "react";
|
|
7
7
|
|
|
8
8
|
import { ColDefT, GridBaseRow } from "../components";
|
|
9
|
-
import { isNotEmpty, wait } from "../utils/util";
|
|
9
|
+
import { isNotEmpty, sanitiseFileName, wait } from "../utils/util";
|
|
10
10
|
import { GridContext, GridFilterExternal } from "./GridContext";
|
|
11
11
|
import { GridUpdatingContext } from "./GridUpdatingContext";
|
|
12
12
|
|
|
@@ -482,6 +482,8 @@ export const GridContextProvider = <RowType extends GridBaseRow>(props: GridCont
|
|
|
482
482
|
(csvExportParams?: CsvExportParams) => {
|
|
483
483
|
if (!gridApi || !columnApi) return;
|
|
484
484
|
|
|
485
|
+
const fileName = csvExportParams?.fileName && sanitiseFileName(csvExportParams.fileName);
|
|
486
|
+
|
|
485
487
|
const columnKeys = columnApi
|
|
486
488
|
?.getColumnState()
|
|
487
489
|
.filter((cs) => !cs.hide && gridApi.getColumnDef(cs.colId)?.headerComponentParams?.exportable !== false)
|
|
@@ -490,6 +492,7 @@ export const GridContextProvider = <RowType extends GridBaseRow>(props: GridCont
|
|
|
490
492
|
columnKeys,
|
|
491
493
|
processCellCallback: downloadCsvUseValueFormattersProcessCellCallback,
|
|
492
494
|
...csvExportParams,
|
|
495
|
+
fileName,
|
|
493
496
|
});
|
|
494
497
|
},
|
|
495
498
|
[columnApi, gridApi],
|
|
@@ -231,7 +231,7 @@ const GridReadOnlyTemplate: ComponentStory<typeof Grid> = (props: GridProps) =>
|
|
|
231
231
|
]}
|
|
232
232
|
/>
|
|
233
233
|
<GridFilterColumnsToggle />
|
|
234
|
-
<GridFilterDownloadCsvButton />
|
|
234
|
+
<GridFilterDownloadCsvButton fileName={"readOnlyGrid"} />
|
|
235
235
|
</GridFilters>
|
|
236
236
|
<Grid
|
|
237
237
|
data-testid={"readonly"}
|
package/src/styles/Grid.scss
CHANGED
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
display: flex;
|
|
32
32
|
align-items: center;
|
|
33
33
|
flex-direction: row;
|
|
34
|
-
padding:
|
|
34
|
+
padding: 12px;
|
|
35
35
|
background-color: colors.$hint;
|
|
36
36
|
border-bottom: 1px solid colors.$silver;
|
|
37
37
|
border-top: 2px solid colors.$lily;
|
|
@@ -59,6 +59,7 @@
|
|
|
59
59
|
.GridFilterQuick-input {
|
|
60
60
|
width: 100%;
|
|
61
61
|
height: 40px;
|
|
62
|
+
min-height: 40px;
|
|
62
63
|
border: 0.06rem solid colors.$silver;
|
|
63
64
|
border-radius: 3px;
|
|
64
65
|
padding-left: 0.75rem;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { sanitiseFileName } from "./util";
|
|
2
|
+
|
|
3
|
+
describe("sanitiseFileName", () => {
|
|
4
|
+
test("sanitiseFileName", () => {
|
|
5
|
+
expect(sanitiseFileName(" LT 1235/543 &%//*$ ")).toBe("LT_1235-543_&%-$");
|
|
6
|
+
expect(sanitiseFileName(" @filename here!!! ")).toBe("@filename_here!!!");
|
|
7
|
+
});
|
|
8
|
+
});
|
package/src/utils/util.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { isEmpty, negate } from "lodash-es";
|
|
2
|
+
import sanitize from "sanitize-filename";
|
|
2
3
|
|
|
3
4
|
export const isNotEmpty = negate(isEmpty);
|
|
4
5
|
|
|
@@ -36,3 +37,12 @@ export const stringByteLengthIsInvalid = (str: string, maxBytes: number) =>
|
|
|
36
37
|
new TextEncoder().encode(str).length > maxBytes;
|
|
37
38
|
|
|
38
39
|
export const fnOrVar = (fn: any, param: any) => (typeof fn === "function" ? fn(param) : fn);
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Trim filename and replaces troublesome characters.
|
|
43
|
+
*
|
|
44
|
+
* e.g. " LT 1235/543 &%//*$ " => "LT_1235-543_&%-$"
|
|
45
|
+
* e.g. " @filename here!!!" => "@filename_here!!!"
|
|
46
|
+
*/
|
|
47
|
+
export const sanitiseFileName = (filename: string): string =>
|
|
48
|
+
sanitize(filename.trim().replaceAll(/(\/|\\)+/g, "-")).replaceAll(/\s+/g, "_");
|