@codebit-programando-solucoes/codebit-web-antd 1.1.5 → 1.1.16

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.
@@ -0,0 +1,89 @@
1
+ import { FC } from 'react';
2
+
3
+ /**
4
+ * A bridge component that syncs Ant Design theme tokens to CSS custom properties. This component doesn't render anything visible but sets CSS variables on the document root
5
+ * element, making Ant Design tokens available for use in regular CSS files.
6
+ *
7
+ * The following CSS variables are exposed:
8
+ *
9
+ * **Color tokens:**
10
+ *
11
+ * - --antd-color-bg-container (Background for containers)
12
+ * - --antd-color-bg-elevated (Background for elevated surfaces)
13
+ * - --antd-color-bg-layout (Background for layout)
14
+ * - --antd-color-border (Border color)
15
+ * - --antd-color-primary (Primary brand color)
16
+ * - --antd-color-text (Main text color)
17
+ * - --antd-color-text-secondary (Secondary text color)
18
+ * - --antd-color-split (Split/divider color)
19
+ *
20
+ * **Margin tokens:**
21
+ *
22
+ * - --antd-margin-xxs: 4px (Smallest margin for very tight spacing)
23
+ * - --antd-margin-xs: 8px (Extra small margin for compact layouts)
24
+ * - --antd-margin-sm: 12px (Small margin for close proximity elements)
25
+ * - --antd-margin: 16px (Base/default margin, most commonly used)
26
+ * - --antd-margin-md: 20px (Medium-large margin for breathing room)
27
+ * - --antd-margin-lg: 24px (Large margin for significant spacing)
28
+ * - --antd-margin-xl: 32px (Extra large margin for strong separation)
29
+ * - --antd-margin-xxl: 48px (Largest margin for major section breaks)
30
+ *
31
+ * **Padding tokens:**
32
+ *
33
+ * - --antd-padding-xxs: 4px (Smallest padding for minimal inner spacing)
34
+ * - --antd-padding-xs: 8px (Extra small padding for tight content)
35
+ * - --antd-padding-sm: 12px (Small padding for compact components)
36
+ * - --antd-padding: 16px (Base/default padding, most commonly used)
37
+ * - --antd-padding-md: 20px (Medium-large padding for comfortable spacing)
38
+ * - --antd-padding-lg: 24px (Large padding for spacious containers)
39
+ * - --antd-padding-xl: 32px (Extra large padding for major containers)
40
+ *
41
+ * **Font size tokens:**
42
+ *
43
+ * - --antd-font-size-sm: 12px (Small text, captions, labels)
44
+ * - --antd-font-size: 14px (Base font size, body text)
45
+ * - --antd-font-size-lg: 16px (Large text, emphasis)
46
+ * - --antd-font-size-xl: 20px (Extra large text, subheadings)
47
+ *
48
+ * **Line height tokens:**
49
+ *
50
+ * - --antd-line-height (Base line height)
51
+ * - --antd-line-height-lg (Large line height)
52
+ *
53
+ * **Control height tokens:**
54
+ *
55
+ * - --antd-control-height-sm (Small control height)
56
+ * - --antd-control-height (Base control height)
57
+ * - --antd-control-height-lg (Large control height)
58
+ *
59
+ * **Border radius tokens:**
60
+ *
61
+ * - --antd-border-radius-sm (Small border radius)
62
+ * - --antd-border-radius (Base border radius)
63
+ * - --antd-border-radius-lg (Large border radius)
64
+ *
65
+ * @example
66
+ * ```tsx
67
+ * // Place this component at the root level of your app
68
+ * function App() {
69
+ * return (
70
+ * <>
71
+ * <CssTokenBridge />
72
+ * <YourAppContent />
73
+ * </>
74
+ * );
75
+ * }
76
+ * ```;
77
+ *
78
+ * @example
79
+ * ```css
80
+ * // Use the exposed CSS variables in your stylesheets
81
+ * .my-component {
82
+ * background-color: var(--antd-color-bg-container);
83
+ * padding: var(--antd-padding-md);
84
+ * color: var(--antd-color-text);
85
+ * font-size: var(--antd-font-size);
86
+ * }
87
+ * ```;
88
+ */
89
+ export const CssTokenBridge: FC;
@@ -0,0 +1,15 @@
1
+ import { JSX, ReactNode } from 'react';
2
+ import { CardProps } from 'antd';
3
+
4
+ export interface FilterContainerProps extends Omit<CardProps, 'children'> {
5
+ /** The content to be rendered inside the card */
6
+ children: ReactNode;
7
+ }
8
+
9
+ /**
10
+ * FilterContainer component that wraps content in an Ant Design Card with custom padding. This component is typically used to contain filter controls and form elements.
11
+ *
12
+ * @param props - Component props
13
+ * @returns A Card component with custom padding styles
14
+ */
15
+ export function FilterContainer(props: FilterContainerProps): JSX.Element;
@@ -0,0 +1,22 @@
1
+ import { JSX, ReactNode } from 'react';
2
+
3
+ /** Props for the ListCard component */
4
+ export interface ListCardProps {
5
+ /** The title to display in the card header */
6
+ title: string;
7
+
8
+ /** Optional callback function to clear filters */
9
+ onClearFilters?: (() => void) | null;
10
+
11
+ /** Container element for header components */
12
+ headerContainer?: ReactNode | null;
13
+
14
+ /** Container element for the table component */
15
+ tableContainer?: ReactNode | null;
16
+
17
+ /** Optional actions to display to the right of clear filters button */
18
+ actions?: ReactNode | null;
19
+ }
20
+
21
+ /** ListCard component - A card layout for displaying lists with filters and tables. */
22
+ export function ListCard(props: ListCardProps): JSX.Element;
@@ -0,0 +1,42 @@
1
+ import { JSX, ReactElement } from 'react';
2
+ import type { TableProps } from 'antd';
3
+
4
+ /**
5
+ * Check if a node is or contains pagination element
6
+ *
7
+ * @param node - The DOM node to check
8
+ * @returns True if the node is or contains a pagination element
9
+ */
10
+ export function isPaginationNode(node: Node): boolean;
11
+
12
+ /**
13
+ * Check if mutation contains pagination nodes
14
+ *
15
+ * @param mutation - The mutation record to check
16
+ * @returns True if the mutation contains pagination nodes
17
+ */
18
+ export function hasPaginationInMutation(mutation: MutationRecord): boolean;
19
+
20
+ /** Props for the TableContainer component */
21
+ export interface TableContainerProps {
22
+ /** The table component to be wrapped (typically an Ant Design Table) */
23
+ children: ReactElement<TableProps<any>>;
24
+ }
25
+
26
+ /**
27
+ * TableContainer component that automatically adjusts table scroll height based on available space and pagination presence.
28
+ *
29
+ * This component wraps an Ant Design table and calculates the optimal scroll height by measuring the container, table header, and pagination heights. It observes DOM mutations to
30
+ * detect pagination changes and recalculates on window resize events.
31
+ *
32
+ * @example
33
+ * ```tsx
34
+ * <TableContainer>
35
+ * <Table dataSource={data} columns={columns} pagination={{ pageSize: 10 }} />
36
+ * </TableContainer>
37
+ * ```;
38
+ *
39
+ * @param props - Component props
40
+ * @returns A container div with the enhanced table component
41
+ */
42
+ export function TableContainer(props: TableContainerProps): JSX.Element;
@@ -1,3 +1,7 @@
1
1
  export * from './LoggedMainContainer';
2
2
  export * from './ThemeToggle';
3
3
  export * from './ErrorRetry';
4
+ export * from './ListCard';
5
+ export * from './CssTokenBridge';
6
+ export * from './TableContainer';
7
+ export * from './FilterContainer.jsx';
@@ -13,15 +13,15 @@ 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[];
24
+ roles?: string[];
25
25
  }
26
26
 
27
27
  /** Context type for Codebit configuration */
@@ -29,7 +29,7 @@ export interface CodebitConfigContextType {
29
29
  /** Array of menu items */
30
30
  menuItems: MenuItem[];
31
31
  /** Current user object */
32
- user: UserType;
32
+ user: LoggedUser;
33
33
  /** Logout handler */
34
34
  onLogout: () => void | Promise<void>;
35
35
  /** Function to toggle the theme */
@@ -40,17 +40,14 @@ export interface CodebitConfigContextType {
40
40
  version?: string;
41
41
  /** Show version in menu */
42
42
  showVersion?: boolean;
43
- /** OAuth callback URL for authentication */
44
- oauthCallbackUrl: string;
43
+ /** Internationalization instance */
44
+ i18n?: import('i18next').i18n;
45
45
  /** Optional secondary sidebar content */
46
46
  secondarySidebar?: React.ReactNode;
47
47
  /** Width of the secondary sidebar */
48
48
  secondarySidebarWidth?: number;
49
49
  }
50
50
 
51
- /** Context for Codebit configuration */
52
- export const CodebitConfigContext: React.Context<CodebitConfigContextType | null>;
53
-
54
51
  /** Props for the CodebitConfigProvider component */
55
52
  export interface CodebitConfigProviderProps {
56
53
  /** Child components */
@@ -58,15 +55,9 @@ export interface CodebitConfigProviderProps {
58
55
  /** Menu items configuration */
59
56
  menuItems: MenuItem[];
60
57
  /** Current user object */
61
- user: UserType;
58
+ user: LoggedUser;
62
59
  /** Logout handler */
63
60
  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
61
  /** Application version. Default is '1.0' */
71
62
  version?: string;
72
63
  /** Show version in menu. Default is true */
@@ -75,6 +66,8 @@ export interface CodebitConfigProviderProps {
75
66
  secondarySidebar?: React.ReactNode;
76
67
  /** Width of the secondary sidebar */
77
68
  secondarySidebarWidth?: number;
69
+ /** Controls theme persistence in localStorage. Default is `true` */
70
+ storeThemeInLocalStorage?: boolean;
78
71
  }
79
72
 
80
73
  /**
@@ -88,3 +81,6 @@ export interface CodebitConfigProviderProps {
88
81
  export function CodebitConfigProvider(
89
82
  props: CodebitConfigProviderProps,
90
83
  ): React.JSX.Element;
84
+
85
+ /** Context for Codebit configuration */
86
+ export const CodebitConfigContext: React.Context<CodebitConfigContextType | null>;