gbs-add-block 0.0.96 → 0.0.97
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
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# GBS Building Blocks 2.0 (v0.0.
|
|
1
|
+
# GBS Building Blocks 2.0 (v0.0.97)
|
|
2
2
|
|
|
3
3
|
Latest and upgraded version of GBS building blocks with headless UI and removed dependencies.
|
|
4
4
|
|
|
@@ -6,7 +6,7 @@ Latest and upgraded version of GBS building blocks with headless UI and removed
|
|
|
6
6
|
|
|
7
7
|
For detailed documentation on usage and props, Please visit: [Building Block Documentation v2.0](https://blackmax-designs.gitbook.io/building-block-v2.0)
|
|
8
8
|
|
|
9
|
-
## What's New 🎉 (Ver 0.0.
|
|
9
|
+
## What's New 🎉 (Ver 0.0.97)
|
|
10
10
|
|
|
11
11
|
- Updated for bug fixes.
|
|
12
12
|
|
package/package.json
CHANGED
|
@@ -66,6 +66,7 @@ interface GridContextType {
|
|
|
66
66
|
rowChange: (rowData: any) => void;
|
|
67
67
|
showTotalPages?: boolean;
|
|
68
68
|
onSearch?: (searchParam: string) => void;
|
|
69
|
+
onToolbarButtonClick?: (action: string) => void;
|
|
69
70
|
}
|
|
70
71
|
|
|
71
72
|
const GridContext = createContext<GridContextType | undefined>(undefined);
|
|
@@ -99,6 +100,7 @@ export const GridProvider: React.FC<{
|
|
|
99
100
|
searchParamValue = () => {},
|
|
100
101
|
showTotalPages = false,
|
|
101
102
|
onSearch = () => {},
|
|
103
|
+
onToolbarButtonClick = () => {},
|
|
102
104
|
} = props;
|
|
103
105
|
|
|
104
106
|
// States Handling Grid
|
|
@@ -425,6 +427,7 @@ export const GridProvider: React.FC<{
|
|
|
425
427
|
rowChange,
|
|
426
428
|
showTotalPages,
|
|
427
429
|
onSearch,
|
|
430
|
+
onToolbarButtonClick,
|
|
428
431
|
};
|
|
429
432
|
|
|
430
433
|
return (
|
|
@@ -37,8 +37,13 @@ export const useGridPagination = () => {
|
|
|
37
37
|
|
|
38
38
|
// Hook for grid search functionality
|
|
39
39
|
export const useGridSearch = () => {
|
|
40
|
-
const {
|
|
41
|
-
|
|
40
|
+
const {
|
|
41
|
+
searchParam,
|
|
42
|
+
handleSearchInput,
|
|
43
|
+
handleSearch,
|
|
44
|
+
enableSearch,
|
|
45
|
+
onSearch,
|
|
46
|
+
} = useGridContext();
|
|
42
47
|
|
|
43
48
|
return {
|
|
44
49
|
searchParam,
|
|
@@ -90,6 +95,8 @@ export const useGridExport = () => {
|
|
|
90
95
|
pdfName,
|
|
91
96
|
pdfOptions,
|
|
92
97
|
gridButtonClass,
|
|
98
|
+
onToolbarButtonClick,
|
|
99
|
+
lazy,
|
|
93
100
|
} = useGridContext();
|
|
94
101
|
|
|
95
102
|
return {
|
|
@@ -101,5 +108,7 @@ export const useGridExport = () => {
|
|
|
101
108
|
pdfName,
|
|
102
109
|
pdfOptions,
|
|
103
110
|
gridButtonClass,
|
|
111
|
+
onToolbarButtonClick,
|
|
112
|
+
lazy,
|
|
104
113
|
};
|
|
105
114
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React from "react";
|
|
1
|
+
import React, { lazy } from "react";
|
|
2
2
|
import { useGridExport, useGridSearch } from "../hooks/GridHooks";
|
|
3
3
|
import {
|
|
4
4
|
exportToExcelHelper,
|
|
@@ -25,6 +25,7 @@ const GridToolbar = () => {
|
|
|
25
25
|
pdfName,
|
|
26
26
|
pdfOptions,
|
|
27
27
|
gridButtonClass,
|
|
28
|
+
onToolbarButtonClick,
|
|
28
29
|
} = useGridExport();
|
|
29
30
|
|
|
30
31
|
if (!enableSearch && !enableExcelExport && !enablePdfExport) {
|
|
@@ -70,7 +71,11 @@ const GridToolbar = () => {
|
|
|
70
71
|
<button
|
|
71
72
|
className={gridButtonClass}
|
|
72
73
|
onClick={() => {
|
|
73
|
-
|
|
74
|
+
if (!lazy) {
|
|
75
|
+
exportToExcelHelper(workingDataSource, columns, excelName);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
if (onToolbarButtonClick) onToolbarButtonClick("excelExport");
|
|
74
79
|
}}
|
|
75
80
|
>
|
|
76
81
|
Export to Excel
|
|
@@ -81,12 +86,15 @@ const GridToolbar = () => {
|
|
|
81
86
|
<button
|
|
82
87
|
className={gridButtonClass}
|
|
83
88
|
onClick={() => {
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
89
|
+
if (!lazy) {
|
|
90
|
+
exportToPDFHelper(
|
|
91
|
+
workingDataSource,
|
|
92
|
+
columns,
|
|
93
|
+
pdfName,
|
|
94
|
+
pdfOptions
|
|
95
|
+
);
|
|
96
|
+
}
|
|
97
|
+
if (onToolbarButtonClick) onToolbarButtonClick("pdfExport");
|
|
90
98
|
}}
|
|
91
99
|
>
|
|
92
100
|
Export to PDF
|