gbs-add-block 1.2.5 → 1.2.7
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 -4
- package/index.cjs +1 -0
- package/package.json +36 -30
- package/source/components/button/index.tsx +41 -24
- package/source/components/card/index.tsx +30 -9
- package/source/components/checkbox/index.tsx +24 -15
- 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/datepicker/index.tsx +7 -6
- package/source/components/input/index.tsx +141 -143
- package/source/components/modal/index.tsx +151 -139
- package/source/components/modal/types.ts +18 -16
- package/source/components/multiselect/PortalDropDown.tsx +1 -0
- package/source/components/multiselect/index.tsx +5 -4
- package/source/components/navbar/AuthSection.tsx +5 -5
- package/source/components/navbar/NavItemComponent.tsx +2 -2
- package/source/components/select/PortalDropDown.tsx +20 -4
- package/source/components/select/index.tsx +6 -4
- package/source/components/select/types.ts +2 -0
- package/source/components/spinner/index.tsx +2 -2
- package/source/components/tabs/index.tsx +70 -51
- package/source/components/tabs/types.ts +15 -14
- package/source/components/textarea/index.tsx +122 -149
- 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 +74 -35
- package/source/icon/iconPaths.ts +6 -0
- package/source/theme.ts +40 -0
package/README.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# GBS Building Blocks 2.0 (v1.2.
|
|
1
|
+
# GBS Building Blocks 2.0 (v1.2.7)
|
|
2
2
|
|
|
3
3
|
Latest and upgraded version of GBS building blocks with headless UI and removed dependencies.
|
|
4
4
|
|
|
@@ -6,10 +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.7)
|
|
10
10
|
|
|
11
|
-
-
|
|
12
|
-
- Data Grid Style Update
|
|
11
|
+
- UI Update (Canditate update for next major change 2.0.0)
|
|
13
12
|
|
|
14
13
|
## Authors
|
|
15
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
|
|
package/package.json
CHANGED
|
@@ -1,30 +1,36 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "gbs-add-block",
|
|
3
|
-
"version": "1.2.
|
|
4
|
-
"description": "React Component Library",
|
|
5
|
-
"type": "module",
|
|
6
|
-
"files": [
|
|
7
|
-
"index.cjs",
|
|
8
|
-
"source"
|
|
9
|
-
],
|
|
10
|
-
"engines": {
|
|
11
|
-
"node": ">=17"
|
|
12
|
-
},
|
|
13
|
-
"bin": {
|
|
14
|
-
"gbs-add-block": "index.cjs"
|
|
15
|
-
},
|
|
16
|
-
"scripts": {
|
|
17
|
-
"test": "echo \"Error: no test specified\" && exit 1"
|
|
18
|
-
},
|
|
19
|
-
"keywords": [],
|
|
20
|
-
"author": "Anandhu Remanan",
|
|
21
|
-
"license": "ISC",
|
|
22
|
-
"dependencies": {
|
|
23
|
-
"fs-extra": "^11.0.4",
|
|
24
|
-
"path": "^0.12.7",
|
|
25
|
-
"yargs": "^17.7.2"
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
1
|
+
{
|
|
2
|
+
"name": "gbs-add-block",
|
|
3
|
+
"version": "1.2.7",
|
|
4
|
+
"description": "React Component Library",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"files": [
|
|
7
|
+
"index.cjs",
|
|
8
|
+
"source"
|
|
9
|
+
],
|
|
10
|
+
"engines": {
|
|
11
|
+
"node": ">=17"
|
|
12
|
+
},
|
|
13
|
+
"bin": {
|
|
14
|
+
"gbs-add-block": "index.cjs"
|
|
15
|
+
},
|
|
16
|
+
"scripts": {
|
|
17
|
+
"test": "echo \"Error: no test specified\" && exit 1"
|
|
18
|
+
},
|
|
19
|
+
"keywords": [],
|
|
20
|
+
"author": "Anandhu Remanan",
|
|
21
|
+
"license": "ISC",
|
|
22
|
+
"dependencies": {
|
|
23
|
+
"fs-extra": "^11.0.4",
|
|
24
|
+
"path": "^0.12.7",
|
|
25
|
+
"yargs": "^17.7.2",
|
|
26
|
+
"@grampro/headless-helpers": "^1.0.21",
|
|
27
|
+
"tailwind-merge": "^3.6.0"
|
|
28
|
+
},
|
|
29
|
+
"devDependencies": {
|
|
30
|
+
"@types/fs-extra": "^11.0.4"
|
|
31
|
+
},
|
|
32
|
+
"peerDependencies": {
|
|
33
|
+
"react": "^19.0.0",
|
|
34
|
+
"react-dom": "^19.0.0"
|
|
35
|
+
}
|
|
36
|
+
}
|
|
@@ -1,25 +1,42 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) Grampro Business Services and affiliates.
|
|
3
|
-
*
|
|
4
|
-
* This source code is licensed under the MIT license found in the
|
|
5
|
-
* LICENSE file in the root directory of this source tree.
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
import React, { type ButtonHTMLAttributes, type ReactNode } from "react";
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
buttonClass
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Grampro Business Services and affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import React, { type ButtonHTMLAttributes, type ReactNode } from "react";
|
|
9
|
+
import { twMerge } from "tailwind-merge";
|
|
10
|
+
import { buttonStyles } from "../globalStyle";
|
|
11
|
+
import type { ComponentSize, ComponentVariant } from "../theme";
|
|
12
|
+
|
|
13
|
+
interface ButtonProps extends ButtonHTMLAttributes<HTMLButtonElement> {
|
|
14
|
+
children?: ReactNode;
|
|
15
|
+
variant?: ComponentVariant;
|
|
16
|
+
size?: ComponentSize;
|
|
17
|
+
buttonClass?: string;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export const Button = ({
|
|
21
|
+
children,
|
|
22
|
+
variant = "primary",
|
|
23
|
+
size = "md",
|
|
24
|
+
buttonClass,
|
|
25
|
+
className,
|
|
26
|
+
...props
|
|
27
|
+
}: ButtonProps) => {
|
|
28
|
+
return (
|
|
29
|
+
<button
|
|
30
|
+
className={twMerge(
|
|
31
|
+
buttonStyles.base,
|
|
32
|
+
buttonStyles.sizes[size],
|
|
33
|
+
buttonStyles.variants[variant],
|
|
34
|
+
className,
|
|
35
|
+
buttonClass
|
|
36
|
+
)}
|
|
37
|
+
{...props}
|
|
38
|
+
>
|
|
39
|
+
{children}
|
|
40
|
+
</button>
|
|
41
|
+
);
|
|
25
42
|
};
|
|
@@ -1,10 +1,31 @@
|
|
|
1
|
-
import React, { type ReactNode } from "react";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
1
|
+
import React, { type HTMLAttributes, type ReactNode } from "react";
|
|
2
|
+
import { twMerge } from "tailwind-merge";
|
|
3
|
+
import { cardStyles } from "../globalStyle";
|
|
4
|
+
|
|
5
|
+
interface CardProps extends HTMLAttributes<HTMLDivElement> {
|
|
6
|
+
children?: ReactNode;
|
|
7
|
+
cardClass?: string;
|
|
8
|
+
interactive?: boolean;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export function Card({
|
|
12
|
+
children,
|
|
13
|
+
cardClass,
|
|
14
|
+
className,
|
|
15
|
+
interactive = false,
|
|
16
|
+
...props
|
|
17
|
+
}: CardProps) {
|
|
18
|
+
return (
|
|
19
|
+
<div
|
|
20
|
+
className={twMerge(
|
|
21
|
+
cardStyles.base,
|
|
22
|
+
interactive ? cardStyles.interactive : "",
|
|
23
|
+
className,
|
|
24
|
+
cardClass
|
|
25
|
+
)}
|
|
26
|
+
{...props}
|
|
27
|
+
>
|
|
28
|
+
{children}
|
|
29
|
+
</div>
|
|
30
|
+
);
|
|
10
31
|
}
|
|
@@ -1,16 +1,25 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) Grampro Business Services and affiliates.
|
|
3
|
-
*
|
|
4
|
-
* This source code is licensed under the MIT license found in the
|
|
5
|
-
* LICENSE file in the root directory of this source tree.
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
import React, { type InputHTMLAttributes } from "react";
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Grampro Business Services and affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import React, { type InputHTMLAttributes } from "react";
|
|
9
|
+
import { twMerge } from "tailwind-merge";
|
|
10
|
+
|
|
11
|
+
export const Checkbox = ({
|
|
12
|
+
className,
|
|
13
|
+
...props
|
|
14
|
+
}: InputHTMLAttributes<HTMLInputElement>) => {
|
|
15
|
+
return (
|
|
16
|
+
<input
|
|
17
|
+
type="checkbox"
|
|
18
|
+
className={twMerge(
|
|
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
|
+
className
|
|
21
|
+
)}
|
|
22
|
+
{...props}
|
|
23
|
+
/>
|
|
24
|
+
);
|
|
16
25
|
};
|
|
@@ -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;
|
|
@@ -325,14 +325,14 @@ export const DatePicker = ({
|
|
|
325
325
|
key={index}
|
|
326
326
|
onClick={() => !isDisabled && selectDate(day)}
|
|
327
327
|
disabled={isDisabled}
|
|
328
|
-
className={`text-center text-xs p-1 w-8 h-8 cursor-pointer rounded-md
|
|
328
|
+
className={`text-center text-xs p-1 w-8 h-8 cursor-pointer rounded-md transition duration-150 ease-in-out ${
|
|
329
329
|
isSelected
|
|
330
|
-
? "bg-black text-white hover:bg-
|
|
331
|
-
: ""
|
|
330
|
+
? "bg-black text-white hover:bg-zinc-900 dark:bg-white dark:text-black dark:hover:bg-zinc-200"
|
|
331
|
+
: "hover:bg-gray-200 dark:hover:bg-zinc-800"
|
|
332
332
|
} ${
|
|
333
333
|
isDisabled
|
|
334
|
-
? "bg-gray-100 text-gray-400 cursor-not-allowed"
|
|
335
|
-
: "
|
|
334
|
+
? "bg-gray-100 text-gray-400 cursor-not-allowed dark:bg-zinc-900 dark:text-zinc-600"
|
|
335
|
+
: ""
|
|
336
336
|
}`}
|
|
337
337
|
>
|
|
338
338
|
{day.getDate()}
|
|
@@ -345,7 +345,7 @@ export const DatePicker = ({
|
|
|
345
345
|
<button
|
|
346
346
|
type="button"
|
|
347
347
|
onClick={goToToday}
|
|
348
|
-
className="text-black hover:text-
|
|
348
|
+
className="text-black hover:text-zinc-650 transition duration-150 ease-in-out dark:text-zinc-400 dark:hover:text-zinc-200 font-semibold"
|
|
349
349
|
>
|
|
350
350
|
Today
|
|
351
351
|
</button>
|
|
@@ -362,3 +362,4 @@ export const DatePicker = ({
|
|
|
362
362
|
</div>
|
|
363
363
|
);
|
|
364
364
|
};
|
|
365
|
+
|