@codebit-programando-solucoes/codebit-web-antd 1.1.9 → 1.1.20

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.
@@ -40,10 +40,18 @@ import { FC } from 'react';
40
40
  *
41
41
  * **Font size tokens:**
42
42
  *
43
+ * - --antd-font-size-xxs: 8px (Micro text, accessibility disclaimers, disabled elements)
44
+ * - --antd-font-size-xs: 10px (Extra small text, fine print, legal disclaimers)
43
45
  * - --antd-font-size-sm: 12px (Small text, captions, labels)
44
46
  * - --antd-font-size: 14px (Base font size, body text)
45
47
  * - --antd-font-size-lg: 16px (Large text, emphasis)
46
48
  * - --antd-font-size-xl: 20px (Extra large text, subheadings)
49
+ * - --antd-font-size-xxl: 24px (Largest base text size for prominent content)
50
+ * - --antd-font-size-heading1: 38px (Primary heading - main page titles)
51
+ * - --antd-font-size-heading2: 30px (Secondary heading - section titles)
52
+ * - --antd-font-size-heading3: 24px (Tertiary heading - subsections)
53
+ * - --antd-font-size-heading4: 20px (Quaternary heading - component titles)
54
+ * - --antd-font-size-heading5: 16px (Quinary heading - labels and captions)
47
55
  *
48
56
  * **Line height tokens:**
49
57
  *
@@ -64,6 +72,7 @@ import { FC } from 'react';
64
72
  *
65
73
  * @example
66
74
  * ```tsx
75
+ *
67
76
  * // Place this component at the root level of your app
68
77
  * function App() {
69
78
  * return (
@@ -77,6 +86,7 @@ import { FC } from 'react';
77
86
  *
78
87
  * @example
79
88
  * ```css
89
+ *
80
90
  * // Use the exposed CSS variables in your stylesheets
81
91
  * .my-component {
82
92
  * background-color: var(--antd-color-bg-container);
@@ -12,16 +12,17 @@ export interface LoggedMainContainerProps {
12
12
  * Provides a responsive layout with:
13
13
  *
14
14
  * - Collapsible sidebar navigation (desktop) or drawer menu (mobile)
15
+ * - Optional secondary sidebar/drawer for additional content
15
16
  * - Dynamic theme switching (light/dark mode)
16
17
  * - Role-based menu filtering
17
18
  * - User logout functionality
18
19
  * - Application version display
19
20
  *
20
- * This component must be used within a CodebitConfigProvider context to access configuration such as menu items, user data, and theme settings.
21
+ * This component must be used within a `CodebitConfigProvider` and `CodebitThemeContext` context to access configuration such as menu items, user data, and theme settings.
21
22
  *
22
23
  * @param props - Component props
23
24
  * @returns JSX.Element - Logged container layout
24
- * @throws Error if used CodebitConfigProvider context
25
+ * @throws Error if used outside `CodebitConfigProvider` and `CodebitThemeContext` contexts
25
26
  */
26
27
  export function LoggedMainContainer(
27
28
  props: LoggedMainContainerProps,
@@ -1,11 +1,10 @@
1
- import * as React from 'react';
1
+ import { JSX } from 'react';
2
2
 
3
3
  /**
4
4
  * Theme switcher component that toggles between light and dark modes.
5
5
  *
6
- * This component displays a switch with sun/moon icons and handles theme toggling based on the context. It can be used independently or integrated with a theme context.
7
- *
8
6
  * @returns JSX.Element - A Switch component with theme toggle functionality.
9
- * @throws Error if used outside CodebitConfigProvider context
7
+ * @throws Error If used outside `CodebitThemeContext` context
8
+ * @component
10
9
  */
11
- export const ThemeToggle: () => React.JSX.Element;
10
+ export const ThemeToggle: () => JSX.Element;
@@ -13,78 +13,74 @@ export interface MenuItem {
13
13
  }
14
14
 
15
15
  /** User object type */
16
- export interface UserType {
16
+ export interface LoggedUser {
17
17
  /** User's full name */
18
- name: string;
18
+ name?: string;
19
19
  /** User's email address */
20
- email: string;
20
+ email?: string;
21
21
  /** Unique user identifier */
22
- id: string;
22
+ id?: string;
23
23
  /** User roles/permissions */
24
- roles: string[];
25
- }
26
-
27
- /** Context type for Codebit configuration */
28
- export interface CodebitConfigContextType {
29
- /** Array of menu items */
30
- menuItems: MenuItem[];
31
- /** Current user object */
32
- user: UserType;
33
- /** Logout handler */
34
- onLogout: () => void | Promise<void>;
35
- /** Function to toggle the theme */
36
- toggleTheme: () => void;
37
- /** Current dark mode state */
38
- isDarkMode: boolean;
39
- /** Application version */
40
- version?: string;
41
- /** Show version in menu */
42
- showVersion?: boolean;
43
- /** OAuth callback URL for authentication */
44
- oauthCallbackUrl: string;
45
- /** Optional secondary sidebar content */
46
- secondarySidebar?: React.ReactNode;
47
- /** Width of the secondary sidebar */
48
- secondarySidebarWidth?: number;
24
+ roles?: string[];
49
25
  }
50
26
 
51
- /** Context for Codebit configuration */
27
+ /** The configuration context for Codebit application, providing access to session and UI settings. */
52
28
  export const CodebitConfigContext: React.Context<CodebitConfigContextType | null>;
53
29
 
54
- /** Props for the CodebitConfigProvider component */
55
- export interface CodebitConfigProviderProps {
56
- /** Child components */
57
- children: React.ReactNode;
58
- /** Menu items configuration */
59
- menuItems: MenuItem[];
60
- /** Current user object */
61
- user: UserType;
62
- /** Logout handler */
63
- onLogout: () => void | Promise<void>;
64
- /** Function to toggle the theme */
65
- toggleTheme: () => void;
66
- /** Current dark mode state */
67
- isDarkMode: boolean;
68
- /** OAuth callback URL for authentication */
69
- oauthCallbackUrl: string;
70
- /** Application version. Default is '1.0' */
71
- version?: string;
72
- /** Show version in menu. Default is true */
73
- showVersion?: boolean;
74
- /** Optional secondary sidebar content */
75
- secondarySidebar?: React.ReactNode;
76
- /** Width of the secondary sidebar */
30
+ /** Context type definition for Codebit configuration. */
31
+ export interface CodebitConfigContextType {
32
+ /**
33
+ * A function that returns menu items configuration for the sidebar based on the current user's context. Takes an optional `LoggedUser` object as parameter and returns an array
34
+ * of `MenuItem` objects.
35
+ */
36
+ menuItems: (user?: LoggedUser) => MenuItem[];
37
+ /** Indicates if the user is currently logged in. */
38
+ isLogged: boolean;
39
+ /** The current user object, null when not logged in. */
40
+ user: LoggedUser | null;
41
+ /** Logs out the current user and resets session state. */
42
+ logout: () => Promise<void>;
43
+ /** Application version string. */
44
+ version: string;
45
+ /**
46
+ * A function that determines whether to display the application version in the UI based on user context. Takes an optional `LoggedUser` object as parameter and returns a
47
+ * boolean value.
48
+ */
49
+ showVersion: (user?: LoggedUser) => boolean;
50
+ /** A function that returns optional secondary sidebar content based on the current user's context. Takes an optional `LoggedUser` object as parameter and returns React nodes. */
51
+ secondarySidebar?: (user?: LoggedUser) => React.ReactNode | null;
52
+ /** Width of the secondary sidebar in pixels (default: 280). */
77
53
  secondarySidebarWidth?: number;
78
54
  }
79
55
 
80
56
  /**
81
- * Configuration provider for Codebit components. Similar to Ant Design's ConfigProvider.
82
- *
83
- * Provides global configuration for theme, user data, menu items, and authentication settings to all child components within the provider tree.
57
+ * Provider component for Codebit configuration and session management.
84
58
  *
85
- * @param props - Component props
86
- * @returns JSX.Element - Provider wrapper
59
+ * @param props - Configuration provider properties.
87
60
  */
88
61
  export function CodebitConfigProvider(
89
62
  props: CodebitConfigProviderProps,
90
- ): React.JSX.Element;
63
+ ): React.ReactElement;
64
+
65
+ /** Properties for the CodebitConfigProvider component. */
66
+ export interface CodebitConfigProviderProps {
67
+ /** Child components that will have access to the configuration context. */
68
+ children: React.ReactNode;
69
+ /**
70
+ * A function that returns menu items configuration for the sidebar based on the current user's context. Takes an optional `LoggedUser` object as parameter and returns an array
71
+ * of `MenuItem` objects.
72
+ */
73
+ menuItems: (user?: LoggedUser) => MenuItem[];
74
+ /** Application version string (default: '1.0'). */
75
+ version?: string;
76
+ /** A function that determines whether to display the application version based on user context. Takes an optional `LoggedUser` object as parameter and returns a boolean value. */
77
+ showVersion?: (user?: LoggedUser) => boolean;
78
+ /** A function that returns optional secondary sidebar content based on user context. Takes an optional `LoggedUser` object as parameter and returns React nodes. */
79
+ secondarySidebar?: (user: LoggedUser) => React.ReactNode | null;
80
+ /** Width of the secondary sidebar in pixels (default: 280). */
81
+ secondarySidebarWidth?: number;
82
+ /** Function to handle user logout. */
83
+ doLogout: () => Promise<void>;
84
+ /** Function to check login status and return user data. */
85
+ checkLogin: () => Promise<any | null>;
86
+ }
@@ -0,0 +1,26 @@
1
+ import * as React from 'react';
2
+ import type { ConfigProviderProps } from 'antd';
3
+
4
+ /** Context for managing theme state in Codebit applications. Provides theme toggling and current theme state to components. */
5
+ export const CodebitThemeContext: React.Context<CodebitThemeContextProps | null>;
6
+
7
+ /** Provider component that wraps the application to enable theme management. */
8
+ export const CodebitThemeProvider: React.FC<CodebitThemeProviderProps>;
9
+
10
+ /** Context value type containing theme state and controls */
11
+ interface CodebitThemeContextProps {
12
+ /** Current theme state (`true` for dark mode) */
13
+ isDarkMode: boolean;
14
+ /** Toggles between dark and light themes */
15
+ toggleTheme: () => void;
16
+ /** Manually sets the theme state */
17
+ setIsDarkMode: (isDark: boolean) => void;
18
+ }
19
+
20
+ /** Properties for the theme provider component */
21
+ type CodebitThemeProviderProps = {
22
+ /** Child components that will have access to theme context */
23
+ children: React.ReactNode;
24
+ /** Whether to persist theme preference in localStorage (default: `true`) */
25
+ storeThemeInLocalStorage?: boolean;
26
+ } & ConfigProviderProps;
@@ -1 +1,2 @@
1
1
  export * from './CodebitConfigContext';
2
+ export * from './CodebitThemeContext';