gbs-add-block 1.2.6 → 1.2.8
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 +3 -3
- package/index.cjs +10 -9
- package/package.json +1 -1
- package/source/components/button/index.tsx +2 -2
- package/source/components/card/index.tsx +1 -1
- package/source/components/checkbox/index.tsx +1 -1
- package/source/components/datagrid/context/GridContext.tsx +38 -17
- package/source/components/datagrid/createTemplate.tsx +2 -2
- package/source/components/datagrid/hooks/usePagination.ts +0 -8
- package/source/components/datagrid/hooks/useSearch.ts +3 -3
- package/source/components/datagrid/index.tsx +2 -1
- package/source/components/datagrid/layout/GridBody.tsx +7 -4
- package/source/components/datagrid/layout/GridPagination.tsx +3 -2
- package/source/components/datagrid/layout/GridToolbar.tsx +2 -1
- package/source/components/datagrid/type.ts +18 -2
- package/source/components/datagridbeta/README.md +232 -0
- package/source/components/datagridbeta/__tests__/core.test.ts +341 -0
- package/source/components/datagridbeta/__tests__/export.test.ts +70 -0
- package/source/components/datagridbeta/core/columnHelper.ts +21 -0
- package/source/components/datagridbeta/core/columns.ts +288 -0
- package/source/components/datagridbeta/core/filtering.ts +237 -0
- package/source/components/datagridbeta/core/grid.ts +616 -0
- package/source/components/datagridbeta/core/index.ts +14 -0
- package/source/components/datagridbeta/core/rows.ts +64 -0
- package/source/components/datagridbeta/core/sorting.ts +111 -0
- package/source/components/datagridbeta/core/state.ts +82 -0
- package/source/components/datagridbeta/core/store.ts +52 -0
- package/source/components/datagridbeta/core/types.ts +266 -0
- package/source/components/datagridbeta/core/values.ts +98 -0
- package/source/components/datagridbeta/core/virtual.ts +85 -0
- package/source/components/datagridbeta/export/csv.ts +32 -0
- package/source/components/datagridbeta/export/download.ts +12 -0
- package/source/components/datagridbeta/export/pdf.ts +61 -0
- package/source/components/datagridbeta/export/table.ts +73 -0
- package/source/components/datagridbeta/export/xlsx.ts +145 -0
- package/source/components/datagridbeta/export/zip.ts +87 -0
- package/source/components/datagridbeta/index.ts +7 -0
- package/source/components/datagridbeta/react/Cell.tsx +282 -0
- package/source/components/datagridbeta/react/ColumnMenu.tsx +135 -0
- package/source/components/datagridbeta/react/DataGrid.tsx +296 -0
- package/source/components/datagridbeta/react/FilterForm.tsx +142 -0
- package/source/components/datagridbeta/react/HeaderRow.tsx +306 -0
- package/source/components/datagridbeta/react/Pagination.tsx +107 -0
- package/source/components/datagridbeta/react/Popover.tsx +79 -0
- package/source/components/datagridbeta/react/Row.tsx +85 -0
- package/source/components/datagridbeta/react/Toolbar.tsx +266 -0
- package/source/components/datagridbeta/react/Viewport.tsx +167 -0
- package/source/components/datagridbeta/react/context.ts +57 -0
- package/source/components/datagridbeta/react/hooks.ts +80 -0
- package/source/components/datagridbeta/react/icons.tsx +72 -0
- package/source/components/datagridbeta/react/keyboard.ts +110 -0
- package/source/components/datagridbeta/react/locale.ts +128 -0
- package/source/components/datagridbeta/styles.css +717 -0
- package/source/components/datepicker/index.tsx +7 -7
- package/source/components/input/index.tsx +1 -1
- package/source/components/multiselect/PortalDropDown.tsx +1 -1
- package/source/components/multiselect/index.tsx +6 -6
- package/source/components/navbar/AuthSection.tsx +5 -5
- package/source/components/navbar/NavItemComponent.tsx +2 -2
- package/source/components/select/PortalDropDown.tsx +1 -1
- package/source/components/select/index.tsx +5 -5
- package/source/components/spinner/index.tsx +2 -2
- package/source/components/tabs/index.tsx +6 -6
- package/source/components/textarea/index.tsx +9 -9
- package/source/components/toast/ToastComponent.tsx +26 -25
- package/source/components/toast/ToastIcon.tsx +8 -8
- package/source/components/uploader/ProgressAnimation.tsx +2 -2
- package/source/components/uploader/UploadedFilePreview.tsx +1 -1
- package/source/components/uploader/index.tsx +1 -1
- package/source/components/uploader/uploaderIcon.tsx +1 -1
- package/source/globalStyle.ts +29 -16
- package/source/theme.ts +7 -7
package/README.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# GBS Building Blocks 2.0 (v1.2.
|
|
1
|
+
# GBS Building Blocks 2.0 (v1.2.8)
|
|
2
2
|
|
|
3
3
|
Latest and upgraded version of GBS building blocks with headless UI and removed dependencies.
|
|
4
4
|
|
|
@@ -6,9 +6,9 @@ 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://gramprokit.vercel.app)
|
|
8
8
|
|
|
9
|
-
## What's New 🎉 (Ver 1.2.
|
|
9
|
+
## What's New 🎉 (Ver 1.2.8)
|
|
10
10
|
|
|
11
|
-
-
|
|
11
|
+
- Canditate update for next major change 2.0.0
|
|
12
12
|
|
|
13
13
|
## Authors
|
|
14
14
|
|
package/index.cjs
CHANGED
|
@@ -50,6 +50,7 @@ const copyCommonFiles = async (destPath) => {
|
|
|
50
50
|
const commonFiles = [
|
|
51
51
|
{ src: ["..", "utils.ts"], dest: "utils.ts" },
|
|
52
52
|
{ src: ["..", "globalStyle.ts"], dest: "globalStyle.ts" },
|
|
53
|
+
{ src: ["..", "theme.ts"], dest: "theme.ts" },
|
|
53
54
|
{ src: ["..", "icon"], dest: "icon" },
|
|
54
55
|
];
|
|
55
56
|
|
|
@@ -81,7 +82,7 @@ const copyComponent = async (component, destPath) => {
|
|
|
81
82
|
component === "Grid"
|
|
82
83
|
? "This Version of Grid will be deprecated soon. Please Install The New Data Grid Component"
|
|
83
84
|
: ""
|
|
84
|
-
}
|
|
85
|
+
}`,
|
|
85
86
|
);
|
|
86
87
|
} catch (error) {
|
|
87
88
|
console.error(`Error installing component ${component}:`, error.message);
|
|
@@ -96,12 +97,12 @@ const installComponentWithDependencies = async (component, destPath) => {
|
|
|
96
97
|
|
|
97
98
|
// Check which components need to be installed
|
|
98
99
|
const pendingInstalls = Array.from(componentsToInstall).filter(
|
|
99
|
-
(comp) => !checkComponentExists(comp, destPath)
|
|
100
|
+
(comp) => !checkComponentExists(comp, destPath),
|
|
100
101
|
);
|
|
101
102
|
|
|
102
103
|
if (pendingInstalls.length === 0) {
|
|
103
104
|
console.log(
|
|
104
|
-
`✓ ${component} and all its dependencies are already installed
|
|
105
|
+
`✓ ${component} and all its dependencies are already installed.`,
|
|
105
106
|
);
|
|
106
107
|
return;
|
|
107
108
|
}
|
|
@@ -133,12 +134,12 @@ const installMultipleComponents = async (components, destPath) => {
|
|
|
133
134
|
|
|
134
135
|
// Filter out already installed components
|
|
135
136
|
const pendingInstalls = Array.from(allComponentsToInstall).filter(
|
|
136
|
-
(comp) => !checkComponentExists(comp, destPath)
|
|
137
|
+
(comp) => !checkComponentExists(comp, destPath),
|
|
137
138
|
);
|
|
138
139
|
|
|
139
140
|
if (pendingInstalls.length === 0) {
|
|
140
141
|
console.log(
|
|
141
|
-
"✓ All selected components and their dependencies are already installed."
|
|
142
|
+
"✓ All selected components and their dependencies are already installed.",
|
|
142
143
|
);
|
|
143
144
|
return;
|
|
144
145
|
}
|
|
@@ -181,7 +182,7 @@ const interactiveComponentSelector = async () => {
|
|
|
181
182
|
console.clear();
|
|
182
183
|
console.log("🚀 Component Installer - Interactive Mode");
|
|
183
184
|
console.log(
|
|
184
|
-
"Use ↑/↓ arrow keys to navigate, SPACE to select/deselect, ENTER to install\n"
|
|
185
|
+
"Use ↑/↓ arrow keys to navigate, SPACE to select/deselect, ENTER to install\n",
|
|
185
186
|
);
|
|
186
187
|
|
|
187
188
|
CONFIG.components.forEach((component, index) => {
|
|
@@ -215,7 +216,7 @@ const interactiveComponentSelector = async () => {
|
|
|
215
216
|
case "\u001b[B": // Down arrow
|
|
216
217
|
currentIndex = Math.min(
|
|
217
218
|
CONFIG.components.length - 1,
|
|
218
|
-
currentIndex + 1
|
|
219
|
+
currentIndex + 1,
|
|
219
220
|
);
|
|
220
221
|
renderMenu();
|
|
221
222
|
break;
|
|
@@ -265,7 +266,7 @@ const parseMultipleComponents = (componentString) => {
|
|
|
265
266
|
|
|
266
267
|
const validateComponents = (components) => {
|
|
267
268
|
const invalidComponents = components.filter(
|
|
268
|
-
(comp) => !CONFIG.components.includes(comp)
|
|
269
|
+
(comp) => !CONFIG.components.includes(comp),
|
|
269
270
|
);
|
|
270
271
|
if (invalidComponents.length > 0) {
|
|
271
272
|
console.error(`Invalid components: ${invalidComponents.join(", ")}`);
|
|
@@ -337,7 +338,7 @@ const main = async () => {
|
|
|
337
338
|
|
|
338
339
|
if (!argv.add) {
|
|
339
340
|
console.error(
|
|
340
|
-
"Please specify a component to install using -a/--add, use -i/--interactive for interactive mode, or -l/--list to see available components"
|
|
341
|
+
"Please specify a component to install using -a/--add, use -i/--interactive for interactive mode, or -l/--list to see available components",
|
|
341
342
|
);
|
|
342
343
|
process.exit(1);
|
|
343
344
|
}
|
package/package.json
CHANGED
|
@@ -7,8 +7,8 @@
|
|
|
7
7
|
|
|
8
8
|
import React, { type ButtonHTMLAttributes, type ReactNode } from "react";
|
|
9
9
|
import { twMerge } from "tailwind-merge";
|
|
10
|
-
import { buttonStyles } from "
|
|
11
|
-
import type { ComponentSize, ComponentVariant } from "
|
|
10
|
+
import { buttonStyles } from "../globalStyle";
|
|
11
|
+
import type { ComponentSize, ComponentVariant } from "../theme";
|
|
12
12
|
|
|
13
13
|
interface ButtonProps extends ButtonHTMLAttributes<HTMLButtonElement> {
|
|
14
14
|
children?: ReactNode;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React, { type HTMLAttributes, type ReactNode } from "react";
|
|
2
2
|
import { twMerge } from "tailwind-merge";
|
|
3
|
-
import { cardStyles } from "
|
|
3
|
+
import { cardStyles } from "../globalStyle";
|
|
4
4
|
|
|
5
5
|
interface CardProps extends HTMLAttributes<HTMLDivElement> {
|
|
6
6
|
children?: ReactNode;
|
|
@@ -16,7 +16,7 @@ export const Checkbox = ({
|
|
|
16
16
|
<input
|
|
17
17
|
type="checkbox"
|
|
18
18
|
className={twMerge(
|
|
19
|
-
"h-5 w-5 cursor-pointer rounded border-
|
|
19
|
+
"h-5 w-5 cursor-pointer rounded border-zinc-300 dark:border-zinc-700 bg-white dark:bg-zinc-950 text-black dark:text-white transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-black dark:focus-visible:ring-white focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-55",
|
|
20
20
|
className
|
|
21
21
|
)}
|
|
22
22
|
{...props}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import React, { createContext, useContext } from "react";
|
|
2
2
|
import type { GridContextType, GridProps } from "../type";
|
|
3
|
+
import { gridStyles } from "../../globalStyle";
|
|
3
4
|
import {
|
|
4
5
|
useDataSource,
|
|
5
6
|
useColumns,
|
|
@@ -18,7 +19,6 @@ export const GridProvider: React.FC<{
|
|
|
18
19
|
const {
|
|
19
20
|
dataSource,
|
|
20
21
|
columns = [],
|
|
21
|
-
pageSettings,
|
|
22
22
|
enableSearch = false,
|
|
23
23
|
lazy = false,
|
|
24
24
|
enableExcelExport = false,
|
|
@@ -26,18 +26,11 @@ export const GridProvider: React.FC<{
|
|
|
26
26
|
enablePdfExport = false,
|
|
27
27
|
pdfName = "data",
|
|
28
28
|
pdfOptions = {},
|
|
29
|
-
gridButtonClass = "px-1 py-2 text-xs rounded bg-zinc-200 dark:bg-zinc-700 cursor-pointer",
|
|
30
29
|
selectAll = false,
|
|
31
30
|
onSelectRow,
|
|
32
31
|
isFetching,
|
|
33
|
-
tableHeaderStyle = "text-left px-2 py-4 bg-zinc-200 dark:bg-zinc-800",
|
|
34
|
-
gridContainerClass = "flex flex-col rounded-md overflow-hidden dark:text-white",
|
|
35
32
|
gridColumnStyleSelectAll = "px-4 text-xs",
|
|
36
33
|
gridColumnStyle = "p-2 text-xs",
|
|
37
|
-
rowChange = () => {},
|
|
38
|
-
pageStatus = () => {},
|
|
39
|
-
activeFilterArrayValue,
|
|
40
|
-
searchParamValue = () => {},
|
|
41
34
|
showTotalPages = false,
|
|
42
35
|
onSearch = () => {},
|
|
43
36
|
onToolbarButtonClick = () => {},
|
|
@@ -45,6 +38,29 @@ export const GridProvider: React.FC<{
|
|
|
45
38
|
initialSearchParam = "",
|
|
46
39
|
} = props;
|
|
47
40
|
|
|
41
|
+
// Resolve pageSize with fallbacks
|
|
42
|
+
const resolvedPageSize = props.pageSize || props.pageSettings?.pageNumber || 10;
|
|
43
|
+
const resolvedPageSettings = {
|
|
44
|
+
pageNumber: resolvedPageSize,
|
|
45
|
+
totalCount: props.pageSettings?.totalCount,
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
// Resolve callback aliases
|
|
49
|
+
const resolvedRowChange = props.onRowClick || props.rowChange || (() => {});
|
|
50
|
+
const resolvedPageStatus = props.onPageChange || props.pageStatus || (() => {});
|
|
51
|
+
const resolvedActiveFilterArrayValue = props.onFilterChange || props.activeFilterArrayValue;
|
|
52
|
+
const resolvedSearchParamValue = props.onSearchChange || props.searchParamValue || (() => {});
|
|
53
|
+
|
|
54
|
+
// Resolve CSS classes using design tokens from theme presets
|
|
55
|
+
const gridContainerClass = props.gridContainerClass || gridStyles.container;
|
|
56
|
+
const gridButtonClass = props.gridButtonClass || gridStyles.button;
|
|
57
|
+
const tableHeaderStyle = props.tableHeaderStyle || gridStyles.tableHeader;
|
|
58
|
+
const gridToolbarClass = props.gridToolbarClass || gridStyles.toolbar;
|
|
59
|
+
const gridPaginationClass = props.gridPaginationClass || gridStyles.pagination;
|
|
60
|
+
const gridRowEvenClass = props.gridRowEvenClass || gridStyles.rowEven;
|
|
61
|
+
const gridRowOddClass = props.gridRowOddClass || gridStyles.rowOdd;
|
|
62
|
+
const gridRowSelectedClass = props.gridRowSelectedClass || gridStyles.rowSelected;
|
|
63
|
+
|
|
48
64
|
// Data source management
|
|
49
65
|
const {
|
|
50
66
|
workingDataSource,
|
|
@@ -52,7 +68,7 @@ export const GridProvider: React.FC<{
|
|
|
52
68
|
fallbackSourceData,
|
|
53
69
|
totalPages,
|
|
54
70
|
setTotalPages,
|
|
55
|
-
} = useDataSource(dataSource,
|
|
71
|
+
} = useDataSource(dataSource, resolvedPageSettings, lazy);
|
|
56
72
|
|
|
57
73
|
// Column management
|
|
58
74
|
const { workingColumns, setWorkingColumns } = useColumns(
|
|
@@ -75,8 +91,7 @@ export const GridProvider: React.FC<{
|
|
|
75
91
|
totalPages,
|
|
76
92
|
lazy,
|
|
77
93
|
workingDataSource,
|
|
78
|
-
|
|
79
|
-
pageStatus,
|
|
94
|
+
resolvedPageStatus,
|
|
80
95
|
);
|
|
81
96
|
|
|
82
97
|
// Search functionality
|
|
@@ -86,10 +101,10 @@ export const GridProvider: React.FC<{
|
|
|
86
101
|
fallbackSourceData,
|
|
87
102
|
dataSource,
|
|
88
103
|
lazy,
|
|
89
|
-
pageSettings,
|
|
104
|
+
pageSettings: resolvedPageSettings,
|
|
90
105
|
resetPage,
|
|
91
106
|
setTotalPages,
|
|
92
|
-
searchParamValue,
|
|
107
|
+
searchParamValue: resolvedSearchParamValue,
|
|
93
108
|
initialSearchParam,
|
|
94
109
|
});
|
|
95
110
|
|
|
@@ -110,8 +125,8 @@ export const GridProvider: React.FC<{
|
|
|
110
125
|
fallbackSourceData,
|
|
111
126
|
resetPage,
|
|
112
127
|
setTotalPages,
|
|
113
|
-
pageSettings,
|
|
114
|
-
activeFilterArrayValue,
|
|
128
|
+
pageSettings: resolvedPageSettings,
|
|
129
|
+
activeFilterArrayValue: resolvedActiveFilterArrayValue,
|
|
115
130
|
lazy,
|
|
116
131
|
initialFilters,
|
|
117
132
|
});
|
|
@@ -160,7 +175,8 @@ export const GridProvider: React.FC<{
|
|
|
160
175
|
|
|
161
176
|
// Grid settings
|
|
162
177
|
columns,
|
|
163
|
-
pageSettings,
|
|
178
|
+
pageSettings: resolvedPageSettings,
|
|
179
|
+
pageSize: resolvedPageSize,
|
|
164
180
|
enableSearch,
|
|
165
181
|
enableExcelExport,
|
|
166
182
|
enablePdfExport,
|
|
@@ -171,9 +187,14 @@ export const GridProvider: React.FC<{
|
|
|
171
187
|
selectAll,
|
|
172
188
|
tableHeaderStyle,
|
|
173
189
|
gridContainerClass,
|
|
190
|
+
gridToolbarClass,
|
|
191
|
+
gridPaginationClass,
|
|
192
|
+
gridRowEvenClass,
|
|
193
|
+
gridRowOddClass,
|
|
194
|
+
gridRowSelectedClass,
|
|
174
195
|
gridColumnStyleSelectAll,
|
|
175
196
|
gridColumnStyle,
|
|
176
|
-
rowChange,
|
|
197
|
+
rowChange: resolvedRowChange,
|
|
177
198
|
showTotalPages,
|
|
178
199
|
onSearch,
|
|
179
200
|
onToolbarButtonClick,
|
|
@@ -26,7 +26,7 @@ export const createTemplate = (
|
|
|
26
26
|
type={config.type || "text"}
|
|
27
27
|
className={
|
|
28
28
|
config.className ||
|
|
29
|
-
"p-1 text-xs outline-none w-full rounded focus:border-b-2 border-
|
|
29
|
+
"p-1 text-xs outline-none w-full rounded focus:border-b-2 border-black dark:border-white dark:bg-zinc-900"
|
|
30
30
|
}
|
|
31
31
|
placeholder={config.placeholder || `Enter ${field}`}
|
|
32
32
|
defaultValue={rowData[field]}
|
|
@@ -41,7 +41,7 @@ export const createTemplate = (
|
|
|
41
41
|
key={`${field}-${rowData.id}`}
|
|
42
42
|
className={
|
|
43
43
|
config.className ||
|
|
44
|
-
"p-1 w-full text-xs rounded outline-none focus:border-b-2 border-
|
|
44
|
+
"p-1 w-full text-xs rounded outline-none focus:border-b-2 border-black dark:border-white dark:bg-zinc-900"
|
|
45
45
|
}
|
|
46
46
|
defaultValue={rowData[field]}
|
|
47
47
|
onChange={handleSelectChange}
|
|
@@ -4,13 +4,11 @@ export const usePagination = (
|
|
|
4
4
|
totalPages: number,
|
|
5
5
|
lazy: boolean,
|
|
6
6
|
dataSource?: any[],
|
|
7
|
-
pageSettings?: { pageNumber: number },
|
|
8
7
|
pageStatus?: ({ currentPage }: { currentPage: number }) => void
|
|
9
8
|
) => {
|
|
10
9
|
const [currentPage, setCurrentPage] = useState(0);
|
|
11
10
|
const [pageStart, setPageStart] = useState(0);
|
|
12
11
|
const [pageEnd, setPageEnd] = useState(10);
|
|
13
|
-
const [prevDataLength, setPrevDataLength] = useState(0);
|
|
14
12
|
|
|
15
13
|
// Update page range based on current page
|
|
16
14
|
const updatePageRange = useCallback(
|
|
@@ -38,12 +36,6 @@ export const usePagination = (
|
|
|
38
36
|
}
|
|
39
37
|
}, [currentPage, pageStatus]);
|
|
40
38
|
|
|
41
|
-
// This will handle the case when dataSource changes
|
|
42
|
-
// and adjust the current page accordingly in managed workflow
|
|
43
|
-
useEffect(() => {
|
|
44
|
-
setPrevDataLength(dataSource?.length || 0);
|
|
45
|
-
}, [dataSource?.length]);
|
|
46
|
-
|
|
47
39
|
// Defensive check: if current page is out of bounds due to totalPages shrinking, reset to 0
|
|
48
40
|
useEffect(() => {
|
|
49
41
|
if (totalPages > 0 && currentPage >= totalPages) {
|
|
@@ -60,9 +60,9 @@ export const useSearch = ({
|
|
|
60
60
|
if (!lazy) {
|
|
61
61
|
const filteredData = workingDataSource.filter((item: any) =>
|
|
62
62
|
Object.values(item).some((val: any) => {
|
|
63
|
-
const trimmedVal = val
|
|
64
|
-
const trimmedSearchParam = searchParam
|
|
65
|
-
return trimmedVal
|
|
63
|
+
const trimmedVal = val?.toString()?.toLowerCase()?.trim();
|
|
64
|
+
const trimmedSearchParam = searchParam?.toLowerCase()?.trim();
|
|
65
|
+
return trimmedVal?.includes(trimmedSearchParam);
|
|
66
66
|
})
|
|
67
67
|
);
|
|
68
68
|
setWorkingDataSource(filteredData);
|
|
@@ -17,7 +17,8 @@ const DataGrid = memo(GridComponent, (prevProps, nextProps) => {
|
|
|
17
17
|
return (
|
|
18
18
|
prevProps.dataSource === nextProps.dataSource &&
|
|
19
19
|
prevProps.columns === nextProps.columns &&
|
|
20
|
-
prevProps.
|
|
20
|
+
prevProps.pageSize === nextProps.pageSize &&
|
|
21
|
+
prevProps.pageSettings?.pageNumber === nextProps.pageSettings?.pageNumber &&
|
|
21
22
|
prevProps.enableSearch === nextProps.enableSearch &&
|
|
22
23
|
prevProps.enablePdfExport === nextProps.enablePdfExport &&
|
|
23
24
|
prevProps.enableExcelExport === nextProps.enableExcelExport
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React
|
|
1
|
+
import React from "react";
|
|
2
2
|
import { useGridContext } from "../context/GridContext";
|
|
3
3
|
import FilterPopup from "./FilterPopup";
|
|
4
4
|
import Icon from "../../icon/Icon";
|
|
@@ -24,6 +24,9 @@ const GridBody = () => {
|
|
|
24
24
|
handleSelectAll,
|
|
25
25
|
handleSelect,
|
|
26
26
|
isRowSelected,
|
|
27
|
+
gridRowEvenClass,
|
|
28
|
+
gridRowOddClass,
|
|
29
|
+
gridRowSelectedClass,
|
|
27
30
|
} = useGridContext();
|
|
28
31
|
|
|
29
32
|
const renderCell = (rowData: any, column: Column, rowIndex: number) => {
|
|
@@ -140,10 +143,10 @@ const GridBody = () => {
|
|
|
140
143
|
key={rowIndex}
|
|
141
144
|
className={
|
|
142
145
|
isRowSelected(rowData)
|
|
143
|
-
?
|
|
146
|
+
? gridRowSelectedClass
|
|
144
147
|
: rowIndex % 2 === 0
|
|
145
|
-
?
|
|
146
|
-
:
|
|
148
|
+
? gridRowEvenClass
|
|
149
|
+
: gridRowOddClass
|
|
147
150
|
}
|
|
148
151
|
onClick={() => rowChange(rowData)}
|
|
149
152
|
>
|
|
@@ -23,10 +23,11 @@ const Pagination = () => {
|
|
|
23
23
|
lazy,
|
|
24
24
|
pageSettings,
|
|
25
25
|
showTotalPages,
|
|
26
|
+
gridPaginationClass,
|
|
26
27
|
} = useGridContext();
|
|
27
28
|
|
|
28
29
|
return (
|
|
29
|
-
<div className=
|
|
30
|
+
<div className={gridPaginationClass}>
|
|
30
31
|
<div className="flex text-xs">
|
|
31
32
|
Showing {currentPage + 1} of {totalPages} pages
|
|
32
33
|
{showTotalPages && (
|
|
@@ -76,7 +77,7 @@ const Pagination = () => {
|
|
|
76
77
|
className={`hidden md:block px-2 py-1 text-sm rounded-md transition-colors duration-200 ease-in-out ${
|
|
77
78
|
currentPage === pageStart + i
|
|
78
79
|
? "bg-black text-white dark:bg-white dark:text-black"
|
|
79
|
-
: "bg-gray-200 dark:bg-zinc-700 hover:bg-gray-300 dark:hover:bg-zinc-600"
|
|
80
|
+
: "bg-gray-200 dark:bg-zinc-700 text-black dark:text-white hover:bg-gray-300 dark:hover:bg-zinc-600"
|
|
80
81
|
}`}
|
|
81
82
|
>
|
|
82
83
|
{pageStart + i + 1}
|
|
@@ -24,6 +24,7 @@ const GridToolbar = () => {
|
|
|
24
24
|
gridButtonClass,
|
|
25
25
|
onToolbarButtonClick,
|
|
26
26
|
lazy,
|
|
27
|
+
gridToolbarClass,
|
|
27
28
|
} = useGridContext();
|
|
28
29
|
|
|
29
30
|
if (!enableSearch && !enableExcelExport && !enablePdfExport) {
|
|
@@ -31,7 +32,7 @@ const GridToolbar = () => {
|
|
|
31
32
|
}
|
|
32
33
|
|
|
33
34
|
return (
|
|
34
|
-
<div className=
|
|
35
|
+
<div className={gridToolbarClass}>
|
|
35
36
|
{/* Search input */}
|
|
36
37
|
{enableSearch && (
|
|
37
38
|
<div className="flex">
|
|
@@ -14,7 +14,8 @@ export interface ActiveFilterArrayValue {
|
|
|
14
14
|
export type GridProps = {
|
|
15
15
|
dataSource: any[] | string;
|
|
16
16
|
columns?: any[];
|
|
17
|
-
pageSettings
|
|
17
|
+
pageSettings?: PageSettingsProps;
|
|
18
|
+
pageSize?: number;
|
|
18
19
|
enableSearch?: boolean;
|
|
19
20
|
lazy?: boolean;
|
|
20
21
|
enableExcelExport?: boolean;
|
|
@@ -24,6 +25,11 @@ export type GridProps = {
|
|
|
24
25
|
gridContainerClass?: string;
|
|
25
26
|
gridButtonClass?: string;
|
|
26
27
|
gridHeaderClass?: string;
|
|
28
|
+
gridToolbarClass?: string;
|
|
29
|
+
gridPaginationClass?: string;
|
|
30
|
+
gridRowEvenClass?: string;
|
|
31
|
+
gridRowOddClass?: string;
|
|
32
|
+
gridRowSelectedClass?: string;
|
|
27
33
|
gridGlobalSearchButtonClass?: string;
|
|
28
34
|
gridPaginationButtonClass?: string;
|
|
29
35
|
pdfOptions?: any;
|
|
@@ -34,10 +40,14 @@ export type GridProps = {
|
|
|
34
40
|
tableHeaderStyle?: string;
|
|
35
41
|
gridColumnStyleSelectAll?: string;
|
|
36
42
|
gridColumnStyle?: string;
|
|
37
|
-
rowChange?: any;
|
|
43
|
+
rowChange?: (rowData: any) => void;
|
|
44
|
+
onRowClick?: (rowData: any) => void;
|
|
38
45
|
pageStatus?: ({ currentPage }: { currentPage: number }) => void;
|
|
46
|
+
onPageChange?: ({ currentPage }: { currentPage: number }) => void;
|
|
39
47
|
activeFilterArrayValue?: ActiveFilterArrayValue[] | any;
|
|
48
|
+
onFilterChange?: (filters: ActiveFilterArrayValue[]) => void;
|
|
40
49
|
searchParamValue?: (value: string) => void;
|
|
50
|
+
onSearchChange?: (value: string) => void;
|
|
41
51
|
showTotalPages?: boolean;
|
|
42
52
|
onSearch?: (value: string) => void;
|
|
43
53
|
onToolbarButtonClick?: (action: string) => void;
|
|
@@ -163,6 +173,7 @@ export interface GridContextType {
|
|
|
163
173
|
// Grid settings
|
|
164
174
|
columns: any[];
|
|
165
175
|
pageSettings: any;
|
|
176
|
+
pageSize: number;
|
|
166
177
|
enableSearch: boolean;
|
|
167
178
|
enableExcelExport: boolean;
|
|
168
179
|
enablePdfExport: boolean;
|
|
@@ -173,6 +184,11 @@ export interface GridContextType {
|
|
|
173
184
|
selectAll: boolean;
|
|
174
185
|
tableHeaderStyle: string;
|
|
175
186
|
gridContainerClass: string;
|
|
187
|
+
gridToolbarClass: string;
|
|
188
|
+
gridPaginationClass: string;
|
|
189
|
+
gridRowEvenClass: string;
|
|
190
|
+
gridRowOddClass: string;
|
|
191
|
+
gridRowSelectedClass: string;
|
|
176
192
|
gridColumnStyleSelectAll: string;
|
|
177
193
|
gridColumnStyle: string;
|
|
178
194
|
rowChange: (rowData: any) => void;
|