ikoncomponents 1.7.4 → 1.7.6

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.
@@ -22,6 +22,7 @@ export interface Software {
22
22
  visible: boolean;
23
23
  defaultSoftware: boolean;
24
24
  order: number;
25
+ displayName: string;
25
26
  }
26
27
  export interface User {
27
28
  userId: string;
@@ -13,6 +13,7 @@ import Link from "next/link";
13
13
  import { jwtDecode } from "jwt-decode";
14
14
  import { Icon } from "../icon";
15
15
  import { useRefresh } from "./RefreshContext";
16
+ import { ProviderWrapper } from "../provider-wrapper";
16
17
  export const MainSidebar = ({ baseUrl, platformUrl, }) => {
17
18
  const [user, setUser] = React.useState();
18
19
  const [accounts, setAccounts] = React.useState([]);
@@ -96,24 +97,24 @@ export const MainSidebar = ({ baseUrl, platformUrl, }) => {
96
97
  throw error;
97
98
  }
98
99
  };
99
- return (_jsx(TooltipProvider, { delayDuration: 0, children: _jsxs("aside", { className: "fixed left-0 top-0 z-20 h-screen w-12 border-r border-border bg-sidebar text-sidebar-foreground flex flex-col items-center py-4 ", children: [_jsxs(DropdownMenu, { children: [_jsx(DropdownMenuTrigger, { asChild: true, children: _jsx(Button, { variant: "default", className: "mb-4 h-8 w-8 rounded-lg p-0", disabled: !selectedAccount, children: _jsx("span", { className: "text-base font-medium text-accent-foreground", children: selectedAccount
100
- ? getInitials(selectedAccount.accountName)
101
- : "..." }) }) }), _jsxs(DropdownMenuContent, { className: "w-55", side: "right", sideOffset: 8, align: "start", children: [_jsx("div", { className: "px-2 py-1.5 text-xs font-semibold text-foreground", children: "Accounts" }), accounts.map((account) => (_jsxs(DropdownMenuItem, { className: "flex items-center justify-between cursor-pointer", onClick: async () => {
102
- try {
103
- setSelectedAccount(account);
104
- console.log(account.accountId);
105
- await switchAccount(account.accountId, baseUrl);
106
- window.location.reload();
107
- }
108
- catch (error) {
109
- console.error("Switch account failed", error);
110
- }
111
- }, children: [_jsxs("div", { className: "flex items-center gap-2", children: [_jsx("div", { className: "h-6 w-6 rounded bg-primary/10 flex items-center justify-center", children: _jsx("span", { className: "text-xs font-medium text-primary", children: getInitials(account.accountName) }) }), _jsx("span", { className: "text-sm", children: account.accountName })] }), (selectedAccount === null || selectedAccount === void 0 ? void 0 : selectedAccount.accountId) === account.accountId && (_jsx(Check, { className: "h-4 w-4 text-primary" }))] }, account.accountId)))] })] }), _jsx("nav", { className: "flex flex-col gap-1", children: _jsxs(Tooltip, { children: [_jsx(TooltipTrigger, { asChild: true, className: "h-8 w-8", children: _jsx(Button, { variant: "ghost", size: "icon", className: "h-10 w-10", asChild: true, children: _jsxs(Link, { href: `${platformUrl}/home`, children: [_jsx(Home, { className: "h-8 w-8" }), _jsx("span", { className: "sr-only", children: "Home" })] }) }) }), _jsx(TooltipContent, { side: "right", sideOffset: 5, children: "Home" })] }, "home") }), _jsx("nav", { className: "flex flex-col gap-1 flex-1", children: softwares.map((software) => {
112
- var _a, _b;
113
- const hasIcon = Boolean(software.icon && software.icon.trim() !== "");
114
- return (_jsxs(Tooltip, { children: [_jsx(TooltipTrigger, { asChild: true, className: "h-8 w-8", children: _jsx(Button, { variant: "ghost", size: "icon", className: "h-10 w-10", asChild: true, children: _jsxs(Link, { href: (_a = software.url) !== null && _a !== void 0 ? _a : "#", children: [hasIcon ? (_jsx(Icon, { name: toPascalCase((_b = software.icon) !== null && _b !== void 0 ? _b : ""), className: "h-8 w-8" })) : (_jsx(FolderCode, { className: "h-8 w-8" })), _jsx("span", { className: "sr-only", children: software.softwareName })] }) }) }), _jsx(TooltipContent, { side: "right", sideOffset: 5, children: software.softwareName })] }, software.softwareName));
115
- }) }), _jsxs(Tooltip, { children: [_jsx(TooltipTrigger, { asChild: true, className: "h-8 w-8", children: _jsx(Button, { variant: "ghost", className: "h-10 w-10", asChild: true, children: _jsxs(Link, { href: `${platformUrl}/settings`, children: [_jsx(Settings, { className: "h-8 w-8" }), _jsx("span", { className: "sr-only", children: "Settings" })] }) }) }), _jsx(TooltipContent, { side: "right", sideOffset: 5, children: "Settings" })] }, "settings"), _jsxs(DropdownMenu, { children: [_jsx(DropdownMenuTrigger, { asChild: true, children: _jsx(Button, { variant: "ghost", size: "icon", className: "h-10 w-10", children: _jsx(CircleUserRound, { className: "h-8 w-8" }) }) }), _jsxs(DropdownMenuContent, { className: "w-55 p-0", side: "right", sideOffset: 8, children: [_jsxs("div", { className: "flex items-start gap-3 p-4 bg-card", children: [_jsx(CircleUserRound, { className: "h-8 w-8" }), _jsxs("div", { className: "flex flex-col gap-0.5 flex-1 min-w-0", children: [_jsx("p", { className: "text-sm font-bold text-foreground blue-dark:text-muted-foreground truncate", children: user === null || user === void 0 ? void 0 : user.userName }), _jsx("p", { className: "text-xs text-muted-foreground truncate", children: user === null || user === void 0 ? void 0 : user.userEmail }), _jsx("p", { className: "text-sm text-muted-foreground font-semibold", children: selectedAccount === null || selectedAccount === void 0 ? void 0 : selectedAccount.accountName })] })] }), _jsx(DropdownMenuSeparator, { className: "my-0" }), _jsxs(DropdownMenuItem, { onClick: async () => {
116
- await clearAllCookieSession();
117
- redirect(`${platformUrl}/login.html`);
118
- }, className: "flex items-center gap-2 px-4 py-3 cursor-pointer focus:bg-destructive dark:focus:bg-destructive blue-dark:focus:bg-destructive", children: [_jsx(LogOut, { className: "h-4 w-4 text-foreground" }), _jsx("span", { children: "Log out" })] })] })] })] }) }));
100
+ return (_jsx(ProviderWrapper, { baseUrl: "", platformUrl: "", children: _jsx(TooltipProvider, { delayDuration: 0, children: _jsxs("aside", { className: "fixed left-0 top-0 z-20 h-screen w-12 border-r border-border bg-sidebar text-sidebar-foreground flex flex-col items-center py-4 ", children: [_jsxs(DropdownMenu, { children: [_jsx(DropdownMenuTrigger, { asChild: true, children: _jsx(Button, { variant: "default", className: "mb-4 h-8 w-8 rounded-lg p-0", disabled: !selectedAccount, children: _jsx("span", { className: "text-base font-medium text-accent-foreground", children: selectedAccount
101
+ ? getInitials(selectedAccount.accountName)
102
+ : "..." }) }) }), _jsxs(DropdownMenuContent, { className: "w-55", side: "right", sideOffset: 8, align: "start", children: [_jsx("div", { className: "px-2 py-1.5 text-xs font-semibold text-foreground", children: "Accounts" }), accounts.map((account) => (_jsxs(DropdownMenuItem, { className: "flex items-center justify-between cursor-pointer", onClick: async () => {
103
+ try {
104
+ setSelectedAccount(account);
105
+ console.log(account.accountId);
106
+ await switchAccount(account.accountId, baseUrl);
107
+ window.location.reload();
108
+ }
109
+ catch (error) {
110
+ console.error("Switch account failed", error);
111
+ }
112
+ }, children: [_jsxs("div", { className: "flex items-center gap-2", children: [_jsx("div", { className: "h-6 w-6 rounded bg-primary/10 flex items-center justify-center", children: _jsx("span", { className: "text-xs font-medium text-primary", children: getInitials(account.accountName) }) }), _jsx("span", { className: "text-sm", children: account.accountName })] }), (selectedAccount === null || selectedAccount === void 0 ? void 0 : selectedAccount.accountId) === account.accountId && (_jsx(Check, { className: "h-4 w-4 text-primary" }))] }, account.accountId)))] })] }), _jsx("nav", { className: "flex flex-col gap-1", children: _jsxs(Tooltip, { children: [_jsx(TooltipTrigger, { asChild: true, className: "h-8 w-8", children: _jsx(Button, { variant: "ghost", size: "icon", className: "h-10 w-10", asChild: true, children: _jsxs(Link, { href: `${platformUrl}/home`, children: [_jsx(Home, { className: "h-8 w-8" }), _jsx("span", { className: "sr-only", children: "Home" })] }) }) }), _jsx(TooltipContent, { side: "right", sideOffset: 5, children: "Home" })] }, "home") }), _jsx("nav", { className: "flex flex-col gap-1 flex-1", children: softwares.map((software) => {
113
+ var _a, _b;
114
+ const hasIcon = Boolean(software.icon && software.icon.trim() !== "");
115
+ return (_jsxs(Tooltip, { children: [_jsx(TooltipTrigger, { asChild: true, className: "h-8 w-8", children: _jsx(Button, { variant: "ghost", size: "icon", className: "h-10 w-10", asChild: true, children: _jsxs(Link, { href: (_a = software.url) !== null && _a !== void 0 ? _a : "#", children: [hasIcon ? (_jsx(Icon, { name: toPascalCase((_b = software.icon) !== null && _b !== void 0 ? _b : ""), className: "h-8 w-8" })) : (_jsx(FolderCode, { className: "h-8 w-8" })), _jsx("span", { className: "sr-only", children: software.displayName })] }) }) }), _jsx(TooltipContent, { side: "right", sideOffset: 5, children: software.displayName })] }, software.displayName));
116
+ }) }), _jsxs(Tooltip, { children: [_jsx(TooltipTrigger, { asChild: true, className: "h-8 w-8", children: _jsx(Button, { variant: "ghost", className: "h-10 w-10", asChild: true, children: _jsxs(Link, { href: `${platformUrl}/settings`, children: [_jsx(Settings, { className: "h-8 w-8" }), _jsx("span", { className: "sr-only", children: "Settings" })] }) }) }), _jsx(TooltipContent, { side: "right", sideOffset: 5, children: "Settings" })] }, "settings"), _jsxs(DropdownMenu, { children: [_jsx(DropdownMenuTrigger, { asChild: true, children: _jsx(Button, { variant: "ghost", size: "icon", className: "h-10 w-10", children: _jsx(CircleUserRound, { className: "h-8 w-8" }) }) }), _jsxs(DropdownMenuContent, { className: "w-55 p-0", side: "right", sideOffset: 8, children: [_jsxs("div", { className: "flex items-start gap-3 p-4 bg-card", children: [_jsx(CircleUserRound, { className: "h-8 w-8" }), _jsxs("div", { className: "flex flex-col gap-0.5 flex-1 min-w-0", children: [_jsx("p", { className: "text-sm font-bold text-foreground blue-dark:text-muted-foreground truncate", children: user === null || user === void 0 ? void 0 : user.userName }), _jsx("p", { className: "text-xs text-muted-foreground truncate", children: user === null || user === void 0 ? void 0 : user.userEmail }), _jsx("p", { className: "text-sm text-muted-foreground font-semibold", children: selectedAccount === null || selectedAccount === void 0 ? void 0 : selectedAccount.accountName })] })] }), _jsx(DropdownMenuSeparator, { className: "my-0" }), _jsxs(DropdownMenuItem, { onClick: async () => {
117
+ await clearAllCookieSession();
118
+ redirect(`${platformUrl}/login.html`);
119
+ }, className: "flex items-center gap-2 px-4 py-3 cursor-pointer focus:bg-destructive dark:focus:bg-destructive blue-dark:focus:bg-destructive", children: [_jsx(LogOut, { className: "h-4 w-4 text-foreground" }), _jsx("span", { children: "Log out" })] })] })] })] }) }) }));
119
120
  };
@@ -9,7 +9,6 @@ import { useEffect, useState } from "react";
9
9
  import { useIsMobile } from "../../hooks/use-mobile";
10
10
  export function CustomTabs({ children, tabArray, pathName, tabListClass = "", tabListInnerClass = "", tabListButtonClass = "", tabContentClass = "", headerEndComponent, onTabChange, isSeperatePage = false, }) {
11
11
  var _a, _b;
12
- // const pathName = usePathname();
13
12
  const [itemToDisplay, setItemToDisplay] = useState(5);
14
13
  const isMobile = useIsMobile();
15
14
  const [visibleTabs, setVisibleTabs] = useState([]);
@@ -33,18 +32,36 @@ export function CustomTabs({ children, tabArray, pathName, tabListClass = "", ta
33
32
  onTabChange === null || onTabChange === void 0 ? void 0 : onTabChange(tabId);
34
33
  };
35
34
  const handleGroupedTabSelect = (tab) => {
36
- setVisibleTabs((prev) => {
37
- const updatedTabs = [...prev];
38
- const replacedTab = updatedTabs.pop();
39
- if (replacedTab) {
40
- setGroupedTabs((prevGrouped) => [
41
- ...prevGrouped.filter((t) => t.tabId !== tab.tabId),
42
- replacedTab,
43
- ]);
44
- }
45
- return [...updatedTabs, tab];
46
- });
35
+ const replacedTab = visibleTabs[visibleTabs.length - 1];
36
+ const newVisibleTabs = [...visibleTabs.slice(0, -1), tab];
37
+ const newGroupedTabs = [
38
+ ...groupedTabs.filter((t) => t.tabId !== tab.tabId),
39
+ ...(replacedTab ? [replacedTab] : []),
40
+ ];
41
+ setVisibleTabs(newVisibleTabs);
42
+ setGroupedTabs(newGroupedTabs);
47
43
  handleTabChange(tab.tabId);
48
44
  };
49
- return (_jsxs(TabsComp, { value: activeTab, onValueChange: handleTabChange, className: "w-full h-full flex flex-col", children: [_jsxs(TabsList, { className: `flex justify-between items-center ${tabListClass}`, children: [_jsxs("div", { className: `flex w-full ${tabListInnerClass}`, children: [visibleTabs.map((tab) => (_jsx(TabsTrigger, { value: tab.tabId, className: tabListButtonClass, children: tab.tabName }, tab.tabId))), groupedTabs.length > 0 && (_jsxs(DropdownMenu, { children: [_jsx(DropdownMenuTrigger, { asChild: true, children: _jsx(TextButton, { variant: "outline", size: 'smIcon', className: "mt-1", children: _jsx(EllipsisVertical, {}) }) }), _jsx(DropdownMenuContent, { children: groupedTabs.map((tab) => (_jsx(DropdownMenuItem, { onClick: () => handleGroupedTabSelect(tab), children: tab.tabName }, tab.tabId))) })] }))] }), headerEndComponent && _jsx("div", { children: headerEndComponent })] }), children ? (_jsx(TabsContent, { value: activeTab, className: `mt-3 flex-grow overflow-auto h-full w-full ${tabContentClass}`, children: _jsx(Card, { className: "h-full w-full p-3", children: children }) })) : (tabArray.map((tab) => (_jsx(TabsContent, { value: tab.tabId, className: `mt-3 flex-grow overflow-auto h-full w-full ${tabContentClass}`, children: _jsx(Card, { className: "h-full w-full p-3", children: tab === null || tab === void 0 ? void 0 : tab.tabContent }) }, tab.tabId))))] }));
45
+ return (_jsxs(TabsComp, { value: activeTab, onValueChange: handleTabChange, className: "w-full h-full flex flex-col", children: [_jsxs("div", { className: `flex items-center justify-between ${tabListClass}`, children: [_jsx(TabsList, { className: `
46
+ h-auto bg-transparent p-0 border-0
47
+ flex items-center
48
+ `, children: _jsxs("div", { className: `
49
+ flex items-center gap-0.5
50
+ border border-border rounded-lg p-1
51
+ ${tabListInnerClass}
52
+ `, children: [visibleTabs.map((tab) => (_jsxs(TabsTrigger, { value: tab.tabId, className: `
53
+ flex items-center gap-1.5
54
+ px-3 py-1.5 h-auto
55
+ text-sm font-medium rounded-md
56
+ text-muted-foreground
57
+ border border-transparent
58
+ bg-transparent shadow-none
59
+ hover:text-foreground hover:bg-muted
60
+ data-[state=active]:bg-accent
61
+ data-[state=active]:text-foreground
62
+ data-[state=active]:border-border
63
+ data-[state=active]:shadow-none
64
+ transition-all duration-150
65
+ ${tabListButtonClass}
66
+ `, children: [tab.icon && (_jsx("span", { className: "size-4 flex items-center justify-center shrink-0", children: tab.icon })), tab.tabName] }, tab.tabId))), groupedTabs.length > 0 && (_jsxs(DropdownMenu, { children: [_jsx(DropdownMenuTrigger, { asChild: true, children: _jsx(TextButton, { variant: "ghost", size: "smIcon", children: _jsx(EllipsisVertical, { className: "size-4" }) }) }), _jsx(DropdownMenuContent, { align: "end", children: groupedTabs.map((tab) => (_jsxs(DropdownMenuItem, { onClick: () => handleGroupedTabSelect(tab), className: "flex items-center gap-2", children: [tab.icon && (_jsx("span", { className: "size-4 flex items-center justify-center shrink-0", children: tab.icon })), tab.tabName] }, tab.tabId))) })] }))] }) }), headerEndComponent && _jsx("div", { children: headerEndComponent })] }), children ? (_jsx(TabsContent, { value: activeTab, className: `mt-3 flex-grow overflow-auto h-full w-full ${tabContentClass}`, children: _jsx(Card, { className: "h-full w-full p-3", children: children }) })) : (tabArray.map((tab) => (_jsx(TabsContent, { value: tab.tabId, className: `mt-3 flex-grow overflow-auto h-full w-full ${tabContentClass}`, children: _jsx(Card, { className: "h-full w-full p-3", children: tab === null || tab === void 0 ? void 0 : tab.tabContent }) }, tab.tabId))))] }));
50
67
  }
@@ -4,6 +4,7 @@ export interface TabArray {
4
4
  default: boolean;
5
5
  tabContent?: React.ReactNode;
6
6
  url?: string;
7
+ icon?: React.ReactNode;
7
8
  }
8
9
  export interface TabProps {
9
10
  children?: React.ReactNode;
@@ -1,2 +1 @@
1
- ;
2
1
  export {};
package/dist/styles.css CHANGED
@@ -927,6 +927,9 @@
927
927
  .w-\[220px\] {
928
928
  width: 220px;
929
929
  }
930
+ .w-\[400px\] {
931
+ width: 400px;
932
+ }
930
933
  .w-auto {
931
934
  width: auto;
932
935
  }
@@ -4201,11 +4204,32 @@
4201
4204
  }
4202
4205
  }
4203
4206
  }
4207
+ .data-\[state\=active\]\:border-border {
4208
+ &[data-state="active"] {
4209
+ border-color: var(--border);
4210
+ }
4211
+ }
4212
+ .data-\[state\=active\]\:bg-accent {
4213
+ &[data-state="active"] {
4214
+ background-color: var(--accent);
4215
+ }
4216
+ }
4204
4217
  .data-\[state\=active\]\:bg-background {
4205
4218
  &[data-state="active"] {
4206
4219
  background-color: var(--background);
4207
4220
  }
4208
4221
  }
4222
+ .data-\[state\=active\]\:text-foreground {
4223
+ &[data-state="active"] {
4224
+ color: var(--foreground);
4225
+ }
4226
+ }
4227
+ .data-\[state\=active\]\:shadow-none {
4228
+ &[data-state="active"] {
4229
+ --tw-shadow: 0 0 #0000;
4230
+ box-shadow: var(--tw-inset-shadow), var(--tw-inset-ring-shadow), var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow);
4231
+ }
4232
+ }
4209
4233
  .data-\[state\=active\]\:shadow-sm {
4210
4234
  &[data-state="active"] {
4211
4235
  --tw-shadow: 0 1px 3px 0 var(--tw-shadow-color, rgb(0 0 0 / 0.1)), 0 1px 2px -1px var(--tw-shadow-color, rgb(0 0 0 / 0.1));