@beyondcorp/beyond-ui 1.0.85 → 1.0.87

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.
@@ -5,16 +5,27 @@ import { Button } from '../Button/Button.js';
5
5
  import { useAuth } from '../../contexts/AuthContext.js';
6
6
 
7
7
  const LogoutButton = React.forwardRef(({ className, onLogout, ...props }, ref) => {
8
- // Use provided onLogout prop, or fallback to context
9
- const context = useAuth ? useAuth() : undefined;
8
+ // Only call useAuth if onLogout prop is not provided
9
+ let contextLogout;
10
+ if (!onLogout) {
11
+ try {
12
+ const context = useAuth();
13
+ if (context.logout) {
14
+ contextLogout = context.logout;
15
+ }
16
+ }
17
+ catch {
18
+ // If context is missing, contextLogout remains undefined
19
+ }
20
+ }
10
21
  const handleClick = (e) => {
11
22
  if (props.onClick)
12
23
  props.onClick(e);
13
24
  if (onLogout) {
14
25
  onLogout();
15
26
  }
16
- else if (context?.logout) {
17
- context.logout();
27
+ else if (contextLogout) {
28
+ contextLogout();
18
29
  }
19
30
  };
20
31
  return (jsxs(Button, { ref: ref, variant: "danger", size: "sm", className: className, onClick: handleClick, ...props, children: [jsx(LogOut, { className: "h-3 w-3 mr-1" }), "Logout"] }));
@@ -1 +1 @@
1
- {"version":3,"file":"LogoutButton.js","sources":["../../../src/components/Sidebar/LogoutButton.tsx"],"sourcesContent":["import * as React from \"react\";\r\nimport { LogOut } from \"lucide-react\";\r\nimport { Button } from \"../Button\";\r\nimport { useAuth } from \"../../contexts/AuthContext\";\r\n\r\n/**\r\n * LogoutButton\r\n * - Dual API: context-aware (uses useAuth) and stateless (accepts onLogout prop).\r\n * - If onLogout prop is provided, uses it; otherwise, falls back to useAuth.\r\n * - Theme-agnostic, reusable.\r\n */\r\nexport interface LogoutButtonProps extends React.ButtonHTMLAttributes<HTMLButtonElement> {\r\n onLogout?: () => void;\r\n}\r\n\r\nexport const LogoutButton = React.forwardRef<HTMLButtonElement, LogoutButtonProps>(\r\n ({ className, onLogout, ...props }, ref) => {\r\n // Use provided onLogout prop, or fallback to context\r\n const context = useAuth ? useAuth() : undefined;\r\n const handleClick = (e: React.MouseEvent<HTMLButtonElement>) => {\r\n if (props.onClick) props.onClick(e);\r\n if (onLogout) {\r\n onLogout();\r\n } else if (context?.logout) {\r\n context.logout();\r\n }\r\n };\r\n return (\r\n <Button\r\n ref={ref}\r\n variant=\"danger\"\r\n size=\"sm\"\r\n className={className}\r\n onClick={handleClick}\r\n {...props}\r\n >\r\n <LogOut className=\"h-3 w-3 mr-1\" />\r\n Logout\r\n </Button>\r\n );\r\n }\r\n);\r\n\r\nLogoutButton.displayName = \"LogoutButton\";"],"names":["_jsxs","_jsx"],"mappings":";;;;;;MAea,YAAY,GAAG,KAAK,CAAC,UAAU,CAC1C,CAAC,EAAE,SAAS,EAAE,QAAQ,EAAE,GAAG,KAAK,EAAE,EAAE,GAAG,KAAI;;AAEzC,IAAA,MAAM,OAAO,GAAG,OAAO,GAAG,OAAO,EAAE,GAAG,SAAS;AAC/C,IAAA,MAAM,WAAW,GAAG,CAAC,CAAsC,KAAI;QAC7D,IAAI,KAAK,CAAC,OAAO;AAAE,YAAA,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC;QACnC,IAAI,QAAQ,EAAE;AACZ,YAAA,QAAQ,EAAE;QACZ;AAAO,aAAA,IAAI,OAAO,EAAE,MAAM,EAAE;YAC1B,OAAO,CAAC,MAAM,EAAE;QAClB;AACF,IAAA,CAAC;AACD,IAAA,QACEA,IAAA,CAAC,MAAM,EAAA,EACL,GAAG,EAAE,GAAG,EACR,OAAO,EAAC,QAAQ,EAChB,IAAI,EAAC,IAAI,EACT,SAAS,EAAE,SAAS,EACpB,OAAO,EAAE,WAAW,EAAA,GAChB,KAAK,EAAA,QAAA,EAAA,CAETC,GAAA,CAAC,MAAM,EAAA,EAAC,SAAS,EAAC,cAAc,EAAA,CAAG,EAAA,QAAA,CAAA,EAAA,CAE5B;AAEb,CAAC;AAGH,YAAY,CAAC,WAAW,GAAG,cAAc;;;;"}
1
+ {"version":3,"file":"LogoutButton.js","sources":["../../../src/components/Sidebar/LogoutButton.tsx"],"sourcesContent":["import * as React from \"react\";\r\nimport { LogOut } from \"lucide-react\";\r\nimport { Button } from \"../Button\";\r\nimport { useAuth } from \"../../contexts/AuthContext\";\r\n\r\n/**\r\n * LogoutButton\r\n * - Dual API: context-aware (uses useAuth) and stateless (accepts onLogout prop).\r\n * - If onLogout prop is provided, uses it; otherwise, falls back to useAuth.\r\n * - Theme-agnostic, reusable.\r\n */\r\nexport interface LogoutButtonProps extends React.ButtonHTMLAttributes<HTMLButtonElement> {\r\n onLogout?: () => void;\r\n}\r\n\r\nexport const LogoutButton = React.forwardRef<HTMLButtonElement, LogoutButtonProps>(\r\n ({ className, onLogout, ...props }, ref) => {\r\n // Only call useAuth if onLogout prop is not provided\r\n let contextLogout: (() => void) | undefined;\r\n if (!onLogout) {\r\n try {\r\n const context = useAuth();\r\n if (context.logout) {\r\n contextLogout = context.logout;\r\n }\r\n } catch {\r\n // If context is missing, contextLogout remains undefined\r\n }\r\n }\r\n const handleClick = (e: React.MouseEvent<HTMLButtonElement>) => {\r\n if (props.onClick) props.onClick(e);\r\n if (onLogout) {\r\n onLogout();\r\n } else if (contextLogout) {\r\n contextLogout();\r\n }\r\n };\r\n return (\r\n <Button\r\n ref={ref}\r\n variant=\"danger\"\r\n size=\"sm\"\r\n className={className}\r\n onClick={handleClick}\r\n {...props}\r\n >\r\n <LogOut className=\"h-3 w-3 mr-1\" />\r\n Logout\r\n </Button>\r\n );\r\n }\r\n);\r\n\r\nLogoutButton.displayName = \"LogoutButton\";"],"names":["_jsxs","_jsx"],"mappings":";;;;;;MAea,YAAY,GAAG,KAAK,CAAC,UAAU,CAC1C,CAAC,EAAE,SAAS,EAAE,QAAQ,EAAE,GAAG,KAAK,EAAE,EAAE,GAAG,KAAI;;AAEzC,IAAA,IAAI,aAAuC;IAC3C,IAAI,CAAC,QAAQ,EAAE;AACb,QAAA,IAAI;AACF,YAAA,MAAM,OAAO,GAAG,OAAO,EAAE;AACzB,YAAA,IAAI,OAAO,CAAC,MAAM,EAAE;AAClB,gBAAA,aAAa,GAAG,OAAO,CAAC,MAAM;YAChC;QACF;AAAE,QAAA,MAAM;;QAER;IACF;AACA,IAAA,MAAM,WAAW,GAAG,CAAC,CAAsC,KAAI;QAC7D,IAAI,KAAK,CAAC,OAAO;AAAE,YAAA,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC;QACnC,IAAI,QAAQ,EAAE;AACZ,YAAA,QAAQ,EAAE;QACZ;aAAO,IAAI,aAAa,EAAE;AACxB,YAAA,aAAa,EAAE;QACjB;AACF,IAAA,CAAC;AACD,IAAA,QACEA,IAAA,CAAC,MAAM,EAAA,EACL,GAAG,EAAE,GAAG,EACR,OAAO,EAAC,QAAQ,EAChB,IAAI,EAAC,IAAI,EACT,SAAS,EAAE,SAAS,EACpB,OAAO,EAAE,WAAW,EAAA,GAChB,KAAK,EAAA,QAAA,EAAA,CAETC,GAAA,CAAC,MAAM,EAAA,EAAC,SAAS,EAAC,cAAc,EAAA,CAAG,EAAA,QAAA,CAAA,EAAA,CAE5B;AAEb,CAAC;AAGH,YAAY,CAAC,WAAW,GAAG,cAAc;;;;"}
@@ -5,9 +5,19 @@ import { Button } from '../Button/Button.js';
5
5
  import { useAuth } from '../../contexts/AuthContext.js';
6
6
 
7
7
  const ProfileButton = React.forwardRef(({ className, user, ...props }, ref) => {
8
- // Use provided user prop, or fallback to context
9
- const context = useAuth ? useAuth() : undefined;
10
- user || context?.user || {};
8
+ // Only call useAuth if user prop is not provided
9
+ let displayUser = user;
10
+ if (!displayUser) {
11
+ try {
12
+ const context = useAuth();
13
+ if (context.user) {
14
+ displayUser = context.user;
15
+ }
16
+ }
17
+ catch {
18
+ // If context is missing, displayUser remains undefined
19
+ }
20
+ }
11
21
  return (jsxs(Button, { ref: ref, variant: "secondary", size: "sm", className: className, ...props, children: [jsx(User, { className: "h-3 w-3 mr-1" }), "Profile"] }));
12
22
  });
13
23
  ProfileButton.displayName = "ProfileButton";
@@ -1 +1 @@
1
- {"version":3,"file":"ProfileButton.js","sources":["../../../src/components/Sidebar/ProfileButton.tsx"],"sourcesContent":["import * as React from \"react\";\r\nimport { User } from \"lucide-react\";\r\nimport { Button } from \"../Button\";\r\nimport { useAuth } from \"../../contexts/AuthContext\";\r\n\r\n/**\r\n * ProfileButton\r\n * - Dual API: context-aware (uses useAuth) and stateless (accepts user/onClick props).\r\n * - If user prop is provided, uses it; otherwise, falls back to useAuth.\r\n * - Theme-agnostic, reusable.\r\n */\r\nexport interface ProfileButtonProps extends React.ButtonHTMLAttributes<HTMLButtonElement> {\r\n user?: { name?: string; email?: string };\r\n}\r\n\r\nexport const ProfileButton = React.forwardRef<HTMLButtonElement, ProfileButtonProps>(\r\n ({ className, user, ...props }, ref) => {\r\n // Use provided user prop, or fallback to context\r\n const context = useAuth ? useAuth() : undefined;\r\n const displayUser = user || context?.user || {};\r\n return (\r\n <Button\r\n ref={ref}\r\n variant=\"secondary\"\r\n size=\"sm\"\r\n className={className}\r\n {...props}\r\n >\r\n <User className=\"h-3 w-3 mr-1\" />\r\n Profile\r\n </Button>\r\n );\r\n }\r\n);\r\n\r\nProfileButton.displayName = \"ProfileButton\";"],"names":["_jsxs","_jsx"],"mappings":";;;;;;MAea,aAAa,GAAG,KAAK,CAAC,UAAU,CAC3C,CAAC,EAAE,SAAS,EAAE,IAAI,EAAE,GAAG,KAAK,EAAE,EAAE,GAAG,KAAI;;AAErC,IAAA,MAAM,OAAO,GAAG,OAAO,GAAG,OAAO,EAAE,GAAG,SAAS;IAC3B,IAAI,IAAI,OAAO,EAAE,IAAI,IAAI;AAC7C,IAAA,QACEA,IAAA,CAAC,MAAM,EAAA,EACL,GAAG,EAAE,GAAG,EACR,OAAO,EAAC,WAAW,EACnB,IAAI,EAAC,IAAI,EACT,SAAS,EAAE,SAAS,EAAA,GAChB,KAAK,aAETC,GAAA,CAAC,IAAI,EAAA,EAAC,SAAS,EAAC,cAAc,EAAA,CAAG,EAAA,SAAA,CAAA,EAAA,CAE1B;AAEb,CAAC;AAGH,aAAa,CAAC,WAAW,GAAG,eAAe;;;;"}
1
+ {"version":3,"file":"ProfileButton.js","sources":["../../../src/components/Sidebar/ProfileButton.tsx"],"sourcesContent":["import * as React from \"react\";\r\nimport { User } from \"lucide-react\";\r\nimport { Button } from \"../Button\";\r\nimport { useAuth } from \"../../contexts/AuthContext\";\r\n\r\n/**\r\n * ProfileButton\r\n * - Dual API: context-aware (uses useAuth) and stateless (accepts user/onClick props).\r\n * - If user prop is provided, uses it; otherwise, falls back to useAuth.\r\n * - Theme-agnostic, reusable.\r\n */\r\nexport interface ProfileButtonProps extends React.ButtonHTMLAttributes<HTMLButtonElement> {\r\n user?: { name?: string; email?: string };\r\n}\r\n\r\nexport const ProfileButton = React.forwardRef<HTMLButtonElement, ProfileButtonProps>(\r\n ({ className, user, ...props }, ref) => {\r\n // Only call useAuth if user prop is not provided\r\n let displayUser = user;\r\n if (!displayUser) {\r\n try {\r\n const context = useAuth();\r\n if (context.user) {\r\n displayUser = context.user;\r\n }\r\n } catch {\r\n // If context is missing, displayUser remains undefined\r\n }\r\n }\r\n return (\r\n <Button\r\n ref={ref}\r\n variant=\"secondary\"\r\n size=\"sm\"\r\n className={className}\r\n {...props}\r\n >\r\n <User className=\"h-3 w-3 mr-1\" />\r\n Profile\r\n </Button>\r\n );\r\n }\r\n);\r\n\r\nProfileButton.displayName = \"ProfileButton\";"],"names":["_jsxs","_jsx"],"mappings":";;;;;;MAea,aAAa,GAAG,KAAK,CAAC,UAAU,CAC3C,CAAC,EAAE,SAAS,EAAE,IAAI,EAAE,GAAG,KAAK,EAAE,EAAE,GAAG,KAAI;;IAErC,IAAI,WAAW,GAAG,IAAI;IACtB,IAAI,CAAC,WAAW,EAAE;AAChB,QAAA,IAAI;AACF,YAAA,MAAM,OAAO,GAAG,OAAO,EAAE;AACzB,YAAA,IAAI,OAAO,CAAC,IAAI,EAAE;AAChB,gBAAA,WAAW,GAAG,OAAO,CAAC,IAAI;YAC5B;QACF;AAAE,QAAA,MAAM;;QAER;IACF;AACA,IAAA,QACEA,IAAA,CAAC,MAAM,EAAA,EACL,GAAG,EAAE,GAAG,EACR,OAAO,EAAC,WAAW,EACnB,IAAI,EAAC,IAAI,EACT,SAAS,EAAE,SAAS,EAAA,GAChB,KAAK,aAETC,GAAA,CAAC,IAAI,EAAA,EAAC,SAAS,EAAC,cAAc,EAAA,CAAG,EAAA,SAAA,CAAA,EAAA,CAE1B;AAEb,CAAC;AAGH,aAAa,CAAC,WAAW,GAAG,eAAe;;;;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@beyondcorp/beyond-ui",
3
- "version": "1.0.85",
3
+ "version": "1.0.87",
4
4
  "description": "A comprehensive React UI component library built with TypeScript, TailwindCSS, and CVA",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",