hi-tm 0.20.3 → 0.20.5
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.
|
@@ -136,6 +136,7 @@ const DropDown = ({ label, data, valueHandler, placeholder, required, textError,
|
|
|
136
136
|
${isOpen && textError === null && !disable && selectedItem
|
|
137
137
|
? 'rotate-180'
|
|
138
138
|
: 'rotate-0'}
|
|
139
|
+
${disable ? "pointer-events-none" : ""}
|
|
139
140
|
absolute left-1 top-1/2 transform -translate-y-1/2
|
|
140
141
|
transition-transform duration-300 flex-shrink-0
|
|
141
142
|
`, onClick: (e) => {
|
|
@@ -1,17 +1,22 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
2
|
+
interface Badge {
|
|
3
|
+
tabId: number;
|
|
4
|
+
count: number;
|
|
5
|
+
badgeColor: string;
|
|
6
|
+
textColor: string;
|
|
7
|
+
}
|
|
8
|
+
interface Tab {
|
|
9
|
+
id: number;
|
|
10
|
+
content: string;
|
|
11
|
+
name: string;
|
|
12
|
+
}
|
|
13
|
+
declare const Tabs: ({ data, badges, tabHandler, inLineCSS, onClick, activeId, renderTab, }: {
|
|
14
|
+
data: Tab[];
|
|
15
|
+
badges?: Badge[];
|
|
16
|
+
tabHandler?: (tab: Tab) => void;
|
|
13
17
|
inLineCSS?: object;
|
|
14
18
|
onClick?: (id: number) => void;
|
|
15
19
|
activeId?: number;
|
|
20
|
+
renderTab?: (tab: Tab, badge?: Badge) => React.ReactNode;
|
|
16
21
|
}) => React.JSX.Element;
|
|
17
22
|
export default Tabs;
|
|
@@ -34,9 +34,8 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
34
34
|
})();
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
36
|
const react_1 = __importStar(require("react"));
|
|
37
|
-
const Tabs = ({ data, tabHandler, inLineCSS, onClick, activeId, }) => {
|
|
37
|
+
const Tabs = ({ data, badges = [], tabHandler, inLineCSS, onClick, activeId, renderTab, }) => {
|
|
38
38
|
const [activeTab, setActiveTab] = (0, react_1.useState)(0);
|
|
39
|
-
// Effect to update active tab when activeId prop changes
|
|
40
39
|
(0, react_1.useEffect)(() => {
|
|
41
40
|
if (activeId !== undefined) {
|
|
42
41
|
const index = data.findIndex((tab) => tab.id === activeId);
|
|
@@ -45,12 +44,17 @@ const Tabs = ({ data, tabHandler, inLineCSS, onClick, activeId, }) => {
|
|
|
45
44
|
}
|
|
46
45
|
}
|
|
47
46
|
}, [activeId, data]);
|
|
48
|
-
return (react_1.default.createElement("ul", { style: inLineCSS || {}, className: "flex flex-row items-center justify-start
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
47
|
+
return (react_1.default.createElement("ul", { style: inLineCSS || {}, className: "flex flex-row items-center justify-start bg-white gap-5", dir: "rtl" }, data.map((tab, index) => {
|
|
48
|
+
const badge = badges.find((b) => b.tabId === tab.id);
|
|
49
|
+
return (react_1.default.createElement("li", { key: index, className: `flex h-full w-fit cursor-pointer flex-row items-center justify-center px-[10px] pb-1 ${activeTab === index ? "border-b-2 border-blue-500" : ""}`, onClick: () => {
|
|
50
|
+
setActiveTab(index);
|
|
51
|
+
if (tabHandler)
|
|
52
|
+
tabHandler(tab);
|
|
53
|
+
if (onClick)
|
|
54
|
+
onClick(tab.id);
|
|
55
|
+
} }, renderTab ? (renderTab(tab, badge)) : (react_1.default.createElement("div", { className: "flex items-center gap-2" },
|
|
56
|
+
tab.content,
|
|
57
|
+
badge && (react_1.default.createElement("span", { className: `inline-flex items-center justify-center px-2 py-1 text-xs font-bold leading-none rounded-full ${badge.textColor} ${badge.badgeColor}` }, badge.count))))));
|
|
58
|
+
})));
|
|
55
59
|
};
|
|
56
60
|
exports.default = Tabs;
|