gbs-add-block 0.0.62 → 0.0.64

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.62)
1
+ # GBS Building Blocks 2.0 (v0.0.64)
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.62)
9
+ ## What's New 🎉 (Ver 0.0.64)
10
10
 
11
11
  - Updated for bug fixes.
12
12
  - New component "Skeleton" & "Navbar" Added.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gbs-add-block",
3
- "version": "0.0.62",
3
+ "version": "0.0.64",
4
4
  "description": "React Component Library",
5
5
  "files": [
6
6
  "index.js",
@@ -87,7 +87,7 @@ export const GridProvider: React.FC<{
87
87
  onSelectRow,
88
88
  isFetching,
89
89
  tableHeaderStyle = "text-left px-2 py-4 bg-zinc-200 dark:bg-zinc-800",
90
- gridContainerClass = "flex flex-col min-w-screen rounded-md overflow-hidden",
90
+ gridContainerClass = "flex flex-col rounded-md overflow-hidden",
91
91
  gridColumnStyleSelectAll = "px-4 text-xs",
92
92
  gridColumnStyle = "p-2 text-xs",
93
93
  rowChange = () => {},
@@ -9,7 +9,7 @@
9
9
  */
10
10
 
11
11
  import { GridMemoised as GridComponent } from "./layout";
12
- import React, { memo } from "react";
12
+ import { memo } from "react";
13
13
 
14
14
  const Grid = memo(GridComponent, (prevProps, nextProps) => {
15
15
  // Custom comparison function
@@ -1,152 +1,3 @@
1
- // import React from "react";
2
- // import Icon from "../../icon/Icon";
3
- // import { listFilter } from "../../icon/iconPaths";
4
- // import FilterPopup from "./FilterPopup";
5
- // import { Column, GridBodyProps } from "../type";
6
-
7
- // const GridBody: React.FC<GridBodyProps> = ({
8
- // selectAll,
9
- // handleSelectAll,
10
- // workingColumns,
11
- // tableHeaderStyle,
12
- // toggleFilterPopup,
13
- // activeFilterArray,
14
- // handleFilterAction,
15
- // workingDataSource,
16
- // isFetching,
17
- // currentPage,
18
- // pageSettings,
19
- // gridColumnStyleSelectAll,
20
- // isRowSelected,
21
- // handleSelect,
22
- // gridColumnStyle,
23
- // rowChange,
24
- // }) => {
25
- // const renderCell = (rowData: any, column: Column, rowIndex: number) => {
26
- // const cellValue = rowData[column.field];
27
-
28
- // if (column.template) {
29
- // return (
30
- // <column.template
31
- // rowData={rowData}
32
- // rowIndex={rowIndex + currentPage * pageSettings.pageNumber}
33
- // rowChange={(changes: any) => rowChange?.(changes)}
34
- // />
35
- // );
36
- // }
37
-
38
- // if (column.tooltip) {
39
- // return (
40
- // <span title={cellValue?.toString()}>
41
- // {cellValue && cellValue.length > 10
42
- // ? `${cellValue.slice(0, 10)}...`
43
- // : cellValue}
44
- // </span>
45
- // );
46
- // }
47
-
48
- // return cellValue;
49
- // };
50
-
51
- // return (
52
- // <div className="overflow-x-auto">
53
- // <table className="min-w-full">
54
- // <thead>
55
- // <tr>
56
- // {selectAll && (
57
- // <th className="text-left border-b border-t bg-gray-50 px-4 py-4 dark:bg-gray-700 dark:text-white">
58
- // <input type="checkbox" onChange={handleSelectAll} />
59
- // </th>
60
- // )}
61
- // {workingColumns.map((column, colIndex) => (
62
- // <th
63
- // key={colIndex}
64
- // className={tableHeaderStyle}
65
- // style={{ width: column.width ? `${column.width}px` : "auto" }}
66
- // >
67
- // <div className="flex items-center relative">
68
- // {column.headerText || column.field}
69
- // {column.filter && !column.template && (
70
- // <>
71
- // <button onClick={() => toggleFilterPopup(colIndex)}>
72
- // <Icon
73
- // dimensions={{ width: "12", height: "12" }}
74
- // elements={listFilter}
75
- // svgClass={`ml-2 fill-none dark:stroke-white ${
76
- // activeFilterArray.some(
77
- // (filter) => filter.filterColumn === column.field
78
- // )
79
- // ? "stroke-red-400"
80
- // : "stroke-black"
81
- // }`}
82
- // />
83
- // </button>
84
- // <FilterPopup
85
- // show={column.showFilterPopup ?? false}
86
- // columnHeader={column.field}
87
- // filterAction={(action: any) =>
88
- // handleFilterAction(action, colIndex)
89
- // }
90
- // />
91
- // </>
92
- // )}
93
- // </div>
94
- // </th>
95
- // ))}
96
- // </tr>
97
- // </thead>
98
- // <tbody>
99
- // {workingDataSource.length > 0 && !isFetching ? (
100
- // workingDataSource
101
- // .slice(
102
- // currentPage * pageSettings.pageNumber,
103
- // (currentPage + 1) * pageSettings.pageNumber
104
- // )
105
- // .map((rowData, rowIndex) => (
106
- // <tr
107
- // key={rowIndex}
108
- // className="hover:bg-gray-50 dark:hover:bg-gray-900 cursor-pointer"
109
- // >
110
- // {selectAll && (
111
- // <td className={gridColumnStyleSelectAll}>
112
- // <input
113
- // type="checkbox"
114
- // checked={isRowSelected(rowData)}
115
- // onChange={() => handleSelect(rowData)}
116
- // />
117
- // </td>
118
- // )}
119
- // {workingColumns.map((column, colIndex) => (
120
- // <td
121
- // key={colIndex}
122
- // className={gridColumnStyle}
123
- // style={{
124
- // width: column.width ? `${column.width}px` : "auto",
125
- // }}
126
- // >
127
- // {renderCell(rowData, column, rowIndex)}
128
- // </td>
129
- // ))}
130
- // </tr>
131
- // ))
132
- // ) : (
133
- // <tr>
134
- // <td
135
- // colSpan={workingColumns.length}
136
- // className="text-center p-4 border-b text-sm"
137
- // >
138
- // {isFetching ? "Fetching Data Please Wait..." : "No Data Found"}
139
- // </td>
140
- // </tr>
141
- // )}
142
- // </tbody>
143
- // </table>
144
- // </div>
145
- // );
146
- // };
147
-
148
- // export default GridBody;
149
-
150
1
  import React from "react";
151
2
  import { useGridContext } from "../context/GridContext";
152
3
  import { useGridFilter, useGridRowSelection } from "../hooks/GridHooks";
@@ -281,8 +132,8 @@ const GridBody = () => {
281
132
  isRowSelected(rowData)
282
133
  ? "bg-blue-100 dark:bg-blue-900"
283
134
  : rowIndex % 2 === 0
284
- ? "bg-gray-50 dark:bg-zinc-800"
285
- : "bg-white dark:bg-zinc-900"
135
+ ? "bg-gray-50 dark:bg-zinc-800 cursor-pointer hover:bg-zinc-200 dark:hover:bg-zinc-700"
136
+ : "bg-white dark:bg-zinc-900 cursor-pointer hover:bg-zinc-200 dark:hover:bg-zinc-700"
286
137
  }
287
138
  onClick={() => rowChange(rowData)}
288
139
  >
@@ -297,7 +148,14 @@ const GridBody = () => {
297
148
  </td>
298
149
  )}
299
150
  {workingColumns.map((column, colIndex) => (
300
- <td key={colIndex} className={gridColumnStyle}>
151
+ <td
152
+ key={colIndex}
153
+ className={gridColumnStyle}
154
+ style={{
155
+ width: column.width ? `${column.width}px` : "auto",
156
+ maxWidth: column.width ? `${column.width}px` : "auto",
157
+ }}
158
+ >
301
159
  {renderCell(rowData, column, rowIndex)}
302
160
  </td>
303
161
  ))}
@@ -1,125 +1,3 @@
1
- // import React from "react";
2
- // import Icon from "../../icon/Icon";
3
- // import {
4
- // leftArrow,
5
- // leftArrows,
6
- // rightArrow,
7
- // rightArrows,
8
- // } from "../../icon/iconPaths";
9
- // import { PaginationProps } from "../type";
10
-
11
- // export default function Pagination({
12
- // goToFirstPage,
13
- // currentPage,
14
- // prevPage,
15
- // pageStart,
16
- // goToPage,
17
- // workingDataSource,
18
- // pageEnd,
19
- // totalPages,
20
- // nextPage,
21
- // goToEndPage,
22
- // }: PaginationProps) {
23
- // return (
24
- // <div className="flex p-2 justify-between dark:text-white text-xs mt-4">
25
- // <div className="flex gap-4">
26
- // <button
27
- // onClick={goToFirstPage}
28
- // className={`${
29
- // currentPage === 0
30
- // ? "text-gray-200 dark:text-gray-700 cursor-pointer"
31
- // : ""
32
- // }`}
33
- // >
34
- // <Icon
35
- // elements={leftArrows}
36
- // svgClass={`${
37
- // currentPage === 0
38
- // ? "stroke-gray-200 fill-none dark:stroke-gray-700 cursor-pointer"
39
- // : "stroke-black fill-none dark:stroke-white cursor-pointer"
40
- // }`}
41
- // />
42
- // </button>
43
- // <button onClick={prevPage}>
44
- // <Icon
45
- // elements={leftArrow}
46
- // svgClass={`${
47
- // currentPage === 0
48
- // ? "stroke-gray-200 fill-none dark:stroke-gray-700 cursor-pointer"
49
- // : "stroke-black fill-none dark:stroke-white cursor-pointer"
50
- // }`}
51
- // />
52
- // </button>
53
- // <div className="flex flex-row gap-3 items-center">
54
- // {pageStart > 0 && (
55
- // <button
56
- // className="p-1 w-5 h-5 flex items-center justify-center rounded-full cursor-pointer"
57
- // onClick={() => goToPage(pageStart - 1)}
58
- // >
59
- // ...
60
- // </button>
61
- // )}
62
- // {workingDataSource.length > 0 &&
63
- // Array.from({ length: pageEnd - pageStart }).map((_, i) => (
64
- // <button
65
- // key={i}
66
- // onClick={() => goToPage(pageStart + i)}
67
- // className={`${
68
- // pageStart + i === currentPage
69
- // ? "font-bold text-white p-2 h-6 bg-black flex items-center justify-center rounded-md w-auto dark:bg-white dark:text-black"
70
- // : ""
71
- // }`}
72
- // >
73
- // {pageStart + i + 1}
74
- // </button>
75
- // ))}
76
- // {pageEnd < totalPages && (
77
- // <button onClick={() => goToPage(pageEnd)}>...</button>
78
- // )}
79
- // </div>
80
- // <button
81
- // onClick={nextPage}
82
- // className={`${
83
- // currentPage === totalPages - 1 || workingDataSource.length <= 0
84
- // ? "text-gray-200 dark:text-gray-700 cursor-pointer"
85
- // : ""
86
- // }`}
87
- // >
88
- // <Icon
89
- // elements={rightArrow}
90
- // svgClass={`${
91
- // currentPage === totalPages - 1 || workingDataSource.length <= 0
92
- // ? "stroke-gray-200 fill-none dark:stroke-gray-700 cursor-pointer"
93
- // : "stroke-black fill-none dark:stroke-white cursor-pointer"
94
- // }`}
95
- // />
96
- // </button>
97
- // <button
98
- // onClick={goToEndPage}
99
- // className={`${
100
- // currentPage === totalPages - 1 || workingDataSource.length <= 0
101
- // ? "text-gray-200 dark:text-gray-700 cursor-pointer"
102
- // : ""
103
- // }`}
104
- // >
105
- // <Icon
106
- // elements={rightArrows}
107
- // svgClass={`${
108
- // currentPage === totalPages - 1 || workingDataSource.length <= 0
109
- // ? "stroke-gray-200 fill-none dark:stroke-gray-700 cursor-pointer"
110
- // : "stroke-black fill-none dark:stroke-white cursor-pointer"
111
- // }`}
112
- // />
113
- // </button>
114
- // </div>
115
- // <div className="flex text-xs">
116
- // {currentPage + 1} of {totalPages} pages ({workingDataSource.length})
117
- // items
118
- // </div>
119
- // </div>
120
- // );
121
- // }
122
-
123
1
  import React from "react";
124
2
  import { useGridPagination } from "../hooks/GridHooks";
125
3
  import Icon from "../../icon/Icon";
@@ -145,7 +23,7 @@ const Pagination = () => {
145
23
  } = useGridPagination();
146
24
 
147
25
  return (
148
- <div className="flex flex-wrap justify-between items-center text-xs px-2 py-4 bg-white dark:bg-zinc-900 gap-2 md:gap-4">
26
+ <div className="flex flex-wrap justify-between items-center text-xs px-2 py-4 bg-zinc-100 dark:bg-zinc-900 gap-2 md:gap-4">
149
27
  <div className="flex flex-1 space-x-1">
150
28
  <button onClick={goToFirstPage} disabled={currentPage === 0}>
151
29
  <Icon
@@ -27,7 +27,34 @@ const GridToolbar = () => {
27
27
  }
28
28
 
29
29
  return (
30
- <div className="flex bg-white dark:bg-zinc-900 justify-end space-x-2 px-2 py-4">
30
+ <div className="flex bg-zinc-100 dark:bg-zinc-900 justify-end space-x-2 px-2 py-4">
31
+ {/* Search input */}
32
+ {enableSearch && (
33
+ <div className="flex">
34
+ <input
35
+ type="search"
36
+ value={searchParam}
37
+ onChange={handleSearchInput}
38
+ placeholder="Search..."
39
+ className="outline-none p-2 text-xs rounded-lg max-sm:hidden dark:bg-zinc-800 bg-zinc-200"
40
+ onKeyDown={(event: React.KeyboardEvent<HTMLInputElement>) => {
41
+ if (event.key === "Enter") {
42
+ handleSearch(searchParam);
43
+ }
44
+ }}
45
+ />
46
+ <button
47
+ className="rounded-lg w-10 flex items-center justify-center cursor-pointer"
48
+ onClick={() => handleSearch(searchParam)}
49
+ >
50
+ <Icon
51
+ elements={search}
52
+ svgClass={"stroke-gray-500 fill-none dark:stroke-white"}
53
+ />{" "}
54
+ </button>
55
+ </div>
56
+ )}
57
+
31
58
  {/* Export buttons */}
32
59
  {(enableExcelExport || enablePdfExport) && (
33
60
  <div className="flex space-x-2">
@@ -59,33 +86,6 @@ const GridToolbar = () => {
59
86
  )}
60
87
  </div>
61
88
  )}
62
-
63
- {/* Search input */}
64
- {enableSearch && (
65
- <div className="flex">
66
- <input
67
- type="search"
68
- value={searchParam}
69
- onChange={handleSearchInput}
70
- placeholder="Search..."
71
- className="outline-none p-2 text-xs font-normal rounded-lg max-sm:hidden dark:bg-zinc-800 bg-zinc-100"
72
- onKeyDown={(event: React.KeyboardEvent<HTMLInputElement>) => {
73
- if (event.key === "Enter") {
74
- handleSearch(searchParam);
75
- }
76
- }}
77
- />
78
- <button
79
- className="rounded-lg w-10 flex items-center justify-center "
80
- onClick={() => handleSearch(searchParam)}
81
- >
82
- <Icon
83
- elements={search}
84
- svgClass={"stroke-gray-500 fill-none dark:stroke-white"}
85
- />{" "}
86
- </button>
87
- </div>
88
- )}
89
89
  </div>
90
90
  );
91
91
  };
@@ -1,14 +1,3 @@
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
- * Extended Documentation for Grid can be found at
7
- * https://psychedelic-step-e70.notion.site/Data-GRID-by-GBS-R-D-20ff97c899d24bc590215a6196435fa3
8
- */
9
-
10
- "use client";
11
-
12
1
  import React, { forwardRef, useImperativeHandle } from "react";
13
2
  import type { GridProps } from "../type";
14
3
  import Pagination from "./GridPagination";