gbs-add-block 0.0.83 → 0.0.84

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.83)
1
+ # GBS Building Blocks 2.0 (v0.0.84)
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.83)
9
+ ## What's New 🎉 (Ver 0.0.84)
10
10
 
11
11
  - Updated for bug fixes.
12
- - New Component Card & SideBar Added
12
+ - New Component Card, Tabs & SideBar Added
13
13
 
14
14
  ## Authors
15
15
 
package/index.cjs CHANGED
@@ -22,6 +22,7 @@ const CONFIG = {
22
22
  "Modal",
23
23
  "Spinner",
24
24
  "Toast",
25
+ "Tabs",
25
26
  "Uploader",
26
27
  "FormRenderer",
27
28
  "MaterialInput",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gbs-add-block",
3
- "version": "0.0.83",
3
+ "version": "0.0.84",
4
4
  "description": "React Component Library",
5
5
  "type": "module",
6
6
  "files": [
@@ -0,0 +1,52 @@
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 { useState } from "react";
9
+ import { TabsProps } from "./types";
10
+
11
+ export function Tabs({
12
+ tabs,
13
+ defaultTabId,
14
+ renderContent,
15
+ onChange,
16
+ className = "",
17
+ }: TabsProps) {
18
+ const [activeTabId, setActiveTabId] = useState<string>(
19
+ defaultTabId || (tabs.length > 0 ? tabs[0].id : "")
20
+ );
21
+
22
+ const handleTabChange = (tabId: string) => {
23
+ setActiveTabId(tabId);
24
+ if (onChange) {
25
+ onChange(tabId);
26
+ }
27
+ };
28
+
29
+ return (
30
+ <div className={`w-full ${className}`}>
31
+ <nav className="flex border-b border-gray-200">
32
+ {tabs.map((tab) => (
33
+ <button
34
+ key={tab.id}
35
+ disabled={tab.disabled}
36
+ className={`px-4 py-2 text-sm font-medium transition-colors ${
37
+ tab.disabled
38
+ ? "text-gray-300 cursor-not-allowed"
39
+ : activeTabId === tab.id
40
+ ? "border-b-2 border-black text-black"
41
+ : "text-gray-500 hover:text-gray-700 hover:border-gray-300"
42
+ }`}
43
+ onClick={() => !tab.disabled && handleTabChange(tab.id)}
44
+ >
45
+ {tab.label}
46
+ </button>
47
+ ))}
48
+ </nav>
49
+ <div className="pt-4">{renderContent(activeTabId)}</div>
50
+ </div>
51
+ );
52
+ }
@@ -0,0 +1,15 @@
1
+ import { ReactNode } from "react";
2
+
3
+ export interface TabItem {
4
+ id: string;
5
+ label: string;
6
+ disabled?: boolean;
7
+ }
8
+
9
+ export interface TabsProps {
10
+ tabs: TabItem[];
11
+ defaultTabId?: string;
12
+ renderContent: (activeTabId: string) => ReactNode;
13
+ onChange?: (tabId: string) => void;
14
+ className?: string;
15
+ }