@megha-ui/react 1.3.134 → 1.3.136

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.
@@ -6,6 +6,7 @@ interface TabsProps {
6
6
  type?: "horizontal" | "vertical";
7
7
  showTabNumber?: boolean;
8
8
  showTabDescription?: boolean;
9
+ getActiveTab?: (tab: string) => void;
9
10
  }
10
11
  export declare const Tabs: React.FC<TabsProps>;
11
12
  interface TabListProps {
@@ -25,7 +26,6 @@ interface TabPanelProps {
25
26
  children: ReactNode;
26
27
  className?: string;
27
28
  padding?: string | number;
28
- getActiveTab?: (tab: string) => void;
29
29
  }
30
30
  export declare const TabPanel: React.FC<TabPanelProps>;
31
31
  export {};
@@ -1,8 +1,13 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { useState, createContext, useContext, useEffect, } from "react";
3
3
  const TabsContext = createContext(undefined);
4
- export const Tabs = ({ children, defaultActive, className, type = "horizontal", showTabNumber = false, showTabDescription = false, }) => {
4
+ export const Tabs = ({ children, defaultActive, className, type = "horizontal", showTabNumber = false, showTabDescription = false, getActiveTab, }) => {
5
5
  const [activeTab, setActiveTab] = useState(defaultActive || "");
6
+ useEffect(() => {
7
+ if (activeTab && getActiveTab) {
8
+ getActiveTab(activeTab);
9
+ }
10
+ }, [activeTab, getActiveTab]);
6
11
  return (_jsx(TabsContext.Provider, { value: {
7
12
  activeTab,
8
13
  setActiveTab,
@@ -40,9 +45,11 @@ export const Tab = ({ label, description, tabNumber }) => {
40
45
  }
41
46
  const { activeTab, setActiveTab, type, showTabNumber, showTabDescription } = context;
42
47
  const isActive = activeTab === label;
43
- return (_jsx("button", { onClick: () => setActiveTab(label), style: Object.assign({ padding: "0.65rem 0", cursor: "pointer", border: "none", textAlign: "left", width: type === "vertical" ? "100%" : "max-content", marginBottom: "0.25rem", borderRadius: "0.25rem", display: "flex", alignItems: "flex-start" }, (!showTabNumber && isActive
48
+ return (_jsx("button", { onClick: () => setActiveTab(label), style: Object.assign({ padding: "0.65rem 0", cursor: "pointer", border: "none", textAlign: "left", width: type === "vertical" ? "100%" : "max-content", marginBottom: "0.25rem", display: "flex", alignItems: "flex-start" }, (!showTabNumber && isActive
44
49
  ? { borderBottom: "3px solid var(--brand)" }
45
- : {})), children: _jsxs("div", { style: { display: "flex", alignItems: "center" }, children: [showTabNumber && (_jsx("span", { style: {
50
+ : {
51
+ borderRadius: "0.25rem",
52
+ })), children: _jsxs("div", { style: { display: "flex", alignItems: "center" }, children: [showTabNumber && (_jsx("span", { style: {
46
53
  fontWeight: 700,
47
54
  fontSize: "1rem",
48
55
  marginRight: "0.5rem",
@@ -61,18 +68,13 @@ export const Tab = ({ label, description, tabNumber }) => {
61
68
  fontSize: "0.85rem",
62
69
  }, children: description }))] })] }) }));
63
70
  };
64
- export const TabPanel = ({ label, children, className, padding, getActiveTab, }) => {
71
+ export const TabPanel = ({ label, children, className, padding, }) => {
65
72
  const context = useContext(TabsContext);
66
73
  if (!context) {
67
74
  throw new Error("TabPanel component must be used inside Tabs.");
68
75
  }
69
76
  const { activeTab } = context;
70
77
  const isActive = activeTab === label;
71
- useEffect(() => {
72
- if (activeTab && getActiveTab) {
73
- getActiveTab(activeTab);
74
- }
75
- }, [activeTab]);
76
78
  return isActive ? (_jsx("div", { className: className, style: {
77
79
  flex: 1,
78
80
  background: "var(--tab-panal-bg)",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@megha-ui/react",
3
- "version": "1.3.134",
3
+ "version": "1.3.136",
4
4
  "description": "A collection of reusable UI components for React applications, built with TypeScript.",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.js",