gbs-add-block 0.0.63 → 0.0.65

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.63)
1
+ # GBS Building Blocks 2.0 (v0.0.65)
2
2
 
3
3
  Latest and upgraded version of GBS building blocks with headless UI and removed dependencies.
4
4
 
@@ -6,10 +6,10 @@ 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.63)
9
+ ## What's New 🎉 (Ver 0.0.65)
10
10
 
11
11
  - Updated for bug fixes.
12
- - New component "Skeleton" & "Navbar" Added.
12
+ - New component "Skeleton", "Breadcrumb" & "Navbar" Added.
13
13
  - Planned Deprecation of Current Grid Component and Adding Beta version for the New Data Grid.
14
14
 
15
15
  ## Authors
package/index.js CHANGED
@@ -27,6 +27,7 @@ const CONFIG = {
27
27
  "Skeleton",
28
28
  "Navbar",
29
29
  "DataGrid",
30
+ "BreadCrumb",
30
31
  ],
31
32
  // Define component dependencies
32
33
  dependencies: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gbs-add-block",
3
- "version": "0.0.63",
3
+ "version": "0.0.65",
4
4
  "description": "React Component Library",
5
5
  "files": [
6
6
  "index.js",
@@ -0,0 +1,64 @@
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 from "react";
9
+ import { useLocation } from "@grampro/headless-helpers";
10
+ import Icon from "../icon/Icon";
11
+ import { rightArrow } from "../icon/iconPaths";
12
+ import { BreadcrumbsProps } from "./types";
13
+
14
+ export const Breadcrumb = ({
15
+ showHome = true,
16
+ rootPath = "/",
17
+ homeLabel = "Home",
18
+ transformLabel,
19
+ className = "",
20
+ activeLinkClass = "font-medium text-gray-900 dark:text-white",
21
+ inactiveLinkClass = "text-gray-500 hover:text-gray-700",
22
+ }: BreadcrumbsProps) => {
23
+ const { pathSegments } = useLocation({
24
+ showHome,
25
+ rootPath,
26
+ homeLabel,
27
+ transformLabel,
28
+ });
29
+
30
+ if (pathSegments.length === 0) {
31
+ return null;
32
+ }
33
+
34
+ return (
35
+ <nav aria-label="Breadcrumb" className={className}>
36
+ <ol className="flex flex-wrap items-center">
37
+ {pathSegments.map((segment, index) => {
38
+ const isLast = index === pathSegments.length - 1;
39
+ return (
40
+ <li key={index} className="flex items-center">
41
+ <>
42
+ <a
43
+ href={segment.path}
44
+ className={isLast ? activeLinkClass : inactiveLinkClass}
45
+ >
46
+ {segment.label}
47
+ </a>
48
+ <span className="mx-2 text-gray-400">
49
+ <Icon
50
+ elements={rightArrow}
51
+ dimensions={{ width: 14, height: 14 }}
52
+ svgClass={
53
+ "stroke-black fill-none dark:stroke-white cursor-pointer"
54
+ }
55
+ />
56
+ </span>
57
+ </>
58
+ </li>
59
+ );
60
+ })}
61
+ </ol>
62
+ </nav>
63
+ );
64
+ };
@@ -0,0 +1,10 @@
1
+ export type BreadcrumbsProps = {
2
+ homeLabel?: string;
3
+ showHome?: boolean;
4
+ transformLabel?: (segment: string) => string;
5
+ rootPath?: string;
6
+ className?: string;
7
+ separator?: string | React.ReactNode;
8
+ activeLinkClass?: string;
9
+ inactiveLinkClass?: string;
10
+ };
@@ -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
@@ -148,7 +148,14 @@ const GridBody = () => {
148
148
  </td>
149
149
  )}
150
150
  {workingColumns.map((column, colIndex) => (
151
- <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
+ >
152
159
  {renderCell(rowData, column, rowIndex)}
153
160
  </td>
154
161
  ))}
@@ -23,7 +23,7 @@ const Pagination = () => {
23
23
  } = useGridPagination();
24
24
 
25
25
  return (
26
- <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">
27
27
  <div className="flex flex-1 space-x-1">
28
28
  <button onClick={goToFirstPage} disabled={currentPage === 0}>
29
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
  };