@codebit-programando-solucoes/codebit-web-antd 1.1.16 → 1.1.21
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.
- package/dist/components/CssTokenBridge.d.ts +10 -0
- package/dist/components/LoggedMainContainer.d.ts +3 -2
- package/dist/components/ThemeToggle.d.ts +4 -5
- package/dist/components/index.d.ts +1 -1
- package/dist/contexts/CodebitConfigContext.d.ts +50 -50
- package/dist/contexts/CodebitThemeContext.d.ts +26 -0
- package/dist/contexts/index.d.ts +1 -0
- package/dist/hooks/index.d.ts +2 -0
- package/dist/hooks/useErrorMessage.d.ts +46 -0
- package/dist/hooks/useErrorModal.d.ts +27 -0
- package/dist/index.cjs +574 -492
- package/dist/index.css +60 -60
- package/dist/index.d.ts +1 -1
- package/dist/public-pages/ChangePassword.d.ts +36 -24
- package/dist/public-pages/ForgotPassword.d.ts +36 -28
- package/dist/public-pages/HandleError.d.ts +2 -3
- package/dist/public-pages/Login.d.ts +32 -29
- package/dist/public-pages/LoginContainer.d.ts +13 -13
- package/package.json +13 -11
- package/dist/theme/CodebitTheme.d.ts +0 -5
- package/dist/theme/index.d.ts +0 -1
|
@@ -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
|
|
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
|
|
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
|
|
7
|
+
* @throws Error If used outside `CodebitThemeContext` context
|
|
8
|
+
* @component
|
|
10
9
|
*/
|
|
11
|
-
export const ThemeToggle: () =>
|
|
10
|
+
export const ThemeToggle: () => JSX.Element;
|
|
@@ -24,63 +24,63 @@ export interface LoggedUser {
|
|
|
24
24
|
roles?: string[];
|
|
25
25
|
}
|
|
26
26
|
|
|
27
|
-
/**
|
|
28
|
-
export
|
|
29
|
-
/** Array of menu items */
|
|
30
|
-
menuItems: MenuItem[];
|
|
31
|
-
/** Current user object */
|
|
32
|
-
user: LoggedUser;
|
|
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
|
-
/** Internationalization instance */
|
|
44
|
-
i18n?: import('i18next').i18n;
|
|
45
|
-
/** Optional secondary sidebar content */
|
|
46
|
-
secondarySidebar?: React.ReactNode;
|
|
47
|
-
/** Width of the secondary sidebar */
|
|
48
|
-
secondarySidebarWidth?: number;
|
|
49
|
-
}
|
|
27
|
+
/** The configuration context for Codebit application, providing access to session and UI settings. */
|
|
28
|
+
export const CodebitConfigContext: React.Context<CodebitConfigContextType | null>;
|
|
50
29
|
|
|
51
|
-
/**
|
|
52
|
-
export interface
|
|
53
|
-
/**
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
user
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
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). */
|
|
68
53
|
secondarySidebarWidth?: number;
|
|
69
|
-
/** Controls theme persistence in localStorage. Default is `true` */
|
|
70
|
-
storeThemeInLocalStorage?: boolean;
|
|
71
54
|
}
|
|
72
55
|
|
|
73
56
|
/**
|
|
74
|
-
*
|
|
75
|
-
*
|
|
76
|
-
* 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.
|
|
77
58
|
*
|
|
78
|
-
* @param props -
|
|
79
|
-
* @returns JSX.Element - Provider wrapper
|
|
59
|
+
* @param props - Configuration provider properties.
|
|
80
60
|
*/
|
|
81
61
|
export function CodebitConfigProvider(
|
|
82
62
|
props: CodebitConfigProviderProps,
|
|
83
|
-
): React.
|
|
63
|
+
): React.ReactElement;
|
|
84
64
|
|
|
85
|
-
/**
|
|
86
|
-
export
|
|
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;
|
package/dist/contexts/index.d.ts
CHANGED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ApiError,
|
|
3
|
+
ApiNetworkError,
|
|
4
|
+
} from '@codebit-programando-solucoes/codebit-web';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Normalized status values used by UI components.
|
|
8
|
+
*
|
|
9
|
+
* - `'error'` – generic fallback status.
|
|
10
|
+
* - `403` – forbidden (often accompanied by a page‑reload action).
|
|
11
|
+
* - `404` – resource not found.
|
|
12
|
+
* - `500` – internal server error.
|
|
13
|
+
*/
|
|
14
|
+
export type ErrorStatus = 403 | 404 | 500 | 'error';
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Shape of the object returned by `getErrorMessage`.
|
|
18
|
+
*
|
|
19
|
+
* @property {string} errorMessage - Human‑readable description of the error.
|
|
20
|
+
* @property {ErrorStatus} status - Normalized status for UI handling.
|
|
21
|
+
* @property {string} retryText - Text displayed on the retry button.
|
|
22
|
+
* @property {(() => void) | null} onRetryAction - Callback invoked when the user clicks the retry button, or `null` when no action is required.
|
|
23
|
+
*/
|
|
24
|
+
export interface ErrorMessage {
|
|
25
|
+
errorMessage: string;
|
|
26
|
+
status: ErrorStatus;
|
|
27
|
+
retryText: string;
|
|
28
|
+
onRetryAction: (() => void) | null;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Accepted error types for `getErrorMessage`.
|
|
33
|
+
*
|
|
34
|
+
* - Standard JavaScript `Error`.
|
|
35
|
+
* - `ApiError` and `ApiNetworkError` exported from the Codebit Web package.
|
|
36
|
+
*/
|
|
37
|
+
export type AcceptedError = Error | ApiError | ApiNetworkError;
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Hook that returns a function to map an error object to an {@link ErrorMessage}.
|
|
41
|
+
*
|
|
42
|
+
* @returns {{ getErrorMessage: (error: AcceptedError) => ErrorMessage }}
|
|
43
|
+
*/
|
|
44
|
+
export function useErrorMessage(): {
|
|
45
|
+
getErrorMessage: (error: AcceptedError) => ErrorMessage;
|
|
46
|
+
};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { AcceptedError } from './useErrorMessage';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Hook that provides a function to display an error modal using Ant Design's `App` modal API. The hook integrates with Sentry for error reporting and with the library's
|
|
5
|
+
* translation utilities.
|
|
6
|
+
*
|
|
7
|
+
* @returns An object containing the `showErrorModal` function.
|
|
8
|
+
*/
|
|
9
|
+
export declare function useErrorModal(): UseErrorModalReturn;
|
|
10
|
+
|
|
11
|
+
/** Shape of the object returned by {@link useErrorModal}. */
|
|
12
|
+
export interface UseErrorModalReturn {
|
|
13
|
+
/**
|
|
14
|
+
* Shows an error modal.
|
|
15
|
+
*
|
|
16
|
+
* @param error - The error to be displayed. It can be any object that extends the native `Error` type.
|
|
17
|
+
* @param title - Optional custom title for the modal. If omitted, a default translated title is used.
|
|
18
|
+
* @param closeButtonText - Optional custom text for the modal's close button.
|
|
19
|
+
* @param onClose - Optional callback executed when the modal is closed. If not provided, the retry action derived from the error message will be used.
|
|
20
|
+
*/
|
|
21
|
+
showErrorModal(
|
|
22
|
+
error: AcceptedError,
|
|
23
|
+
title?: string,
|
|
24
|
+
closeButtonText?: string,
|
|
25
|
+
onClose?: () => void,
|
|
26
|
+
): void;
|
|
27
|
+
}
|