@codebit-programando-solucoes/codebit-web-antd 1.1.39 → 1.1.41

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.
@@ -1,8 +1,11 @@
1
1
  import { FC } from 'react';
2
2
 
3
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.
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
5
+ * `document.documentElement` (always) and, when `containerId` is given and found, additionally on that container element, making Ant Design tokens available for use in regular
6
+ * CSS files. Writing to `document.documentElement` unconditionally — not just the scoped container — means the variables are also reachable by content antd portals outside
7
+ * `containerId` (e.g. a `Dropdown`/`Modal`/`Tooltip` popup, which mounts as a child of `document.body` by default); scoped consumers still get the more specific, closer value
8
+ * from `containerId` since it wins the normal CSS-inheritance cascade over `document.documentElement`.
6
9
  *
7
10
  * The following CSS variables are exposed:
8
11
  *
@@ -56,7 +59,6 @@ import { FC } from 'react';
56
59
  * - --antd-color-fill-alter-active (Alternate fill active state)
57
60
  * - --antd-color-fill-alter-selected (Alternate fill selected state)
58
61
  * - --antd-color-fill-alter-disabled (Alternate fill disabled state)
59
- * - --antd-color-fill-disabled (General fill disabled state)
60
62
  * - --antd-color-white (Pure white)
61
63
  * - --antd-color-black (Pure black)
62
64
  *
@@ -98,11 +100,13 @@ import { FC } from 'react';
98
100
  *
99
101
  * **Line height tokens:**
100
102
  *
103
+ * - --antd-line-height-sm (Smaller line height for tight text)
101
104
  * - --antd-line-height (Base line height)
102
105
  * - --antd-line-height-lg (Large line height)
103
106
  *
104
107
  * **Control height tokens:**
105
108
  *
109
+ * - --antd-control-height-xs (Extra small control height, e.g. a small tag)
106
110
  * - --antd-control-height-sm (Small control height)
107
111
  * - --antd-control-height (Base control height)
108
112
  * - --antd-control-height-lg (Large control height)
@@ -113,6 +117,11 @@ import { FC } from 'react';
113
117
  * - --antd-border-radius (Base border radius)
114
118
  * - --antd-border-radius-lg (Large border radius)
115
119
  *
120
+ * **Shadow tokens:**
121
+ *
122
+ * - --antd-shadow (Default shadow for elevated containers)
123
+ * - --antd-shadow-lg (Enhanced shadow for stronger visual separation — also what antd's own Dropdown/Popover/Modal use)
124
+ *
116
125
  * @example
117
126
  * ```tsx
118
127
  * // Place this component at the root level of your app
@@ -140,7 +149,7 @@ import { FC } from 'react';
140
149
  * ```;
141
150
  */
142
151
  export interface CssTokenBridgeProps {
143
- /** Optional ID of the container element to receive the CSS variables. */
152
+ /** Optional ID of a container element to additionally receive the CSS variables (in addition to `document.documentElement`, which always receives them). */
144
153
  containerId?: string;
145
154
  }
146
155
 
@@ -17,6 +17,7 @@ export interface LoggedMainContainerProps {
17
17
  * - Role‑based menu filtering
18
18
  * - User logout functionality
19
19
  * - Application version display
20
+ * - Header user-profile avatar/dropdown (see `UserMenu`), built from the `userMenuItems` config function
20
21
  *
21
22
  * This component must be used within a `CodebitConfigProvider` and `CodebitThemeContext` context to access configuration such as menu items, user data, and theme settings.
22
23
  *
@@ -0,0 +1,24 @@
1
+ import { ReactNode } from 'react';
2
+ import type { LoggedUser, MenuItem } from '../contexts';
3
+
4
+ /** Props for the UserMenu component */
5
+ export interface UserMenuProps {
6
+ /** Currently logged-in user, or `null`/`undefined` when not available. */
7
+ user?: LoggedUser | null;
8
+ /** Items rendered in the dropdown, already role-filtered by the caller. When empty, only the avatar is rendered (no dropdown). */
9
+ items?: MenuItem[];
10
+ /** Called with the clicked item's key. */
11
+ onItemClick?: (key: string) => void;
12
+ /** Icon shown next to the avatar to indicate the dropdown affordance. Defaults to `<DownOutlined />`. */
13
+ caretIcon?: ReactNode;
14
+ }
15
+
16
+ /**
17
+ * Header user-profile control. Renders the current user's avatar and, when `items` is non-empty, a dropdown showing the user's name/subtitle followed by the given menu items (e.g.
18
+ * a "Minhas preferências" entry supplied by the host application).
19
+ *
20
+ * @param props - Component props
21
+ * @returns React.JSX.Element - Avatar, optionally wrapped in a Dropdown
22
+ * @component
23
+ */
24
+ export function UserMenu(props: UserMenuProps): React.JSX.Element;
@@ -1,5 +1,6 @@
1
1
  export * from './LoggedMainContainer';
2
2
  export * from './ThemeToggle';
3
+ export * from './UserMenu';
3
4
  export * from './ErrorRetry';
4
5
  export * from './ListCard';
5
6
  export * from './CssTokenBridge';
@@ -29,6 +29,8 @@ export interface LoggedUser {
29
29
  id?: string;
30
30
  /** User roles/permissions */
31
31
  roles?: string[];
32
+ /** Short label shown under the user's name in the header user menu (e.g. a role/department name). */
33
+ subtitle?: string;
32
34
  }
33
35
 
34
36
  /** Context type definition for Codebit configuration. */
@@ -60,10 +62,21 @@ export interface CodebitConfigContextType {
60
62
  /** Function that returns menu items configuration for items displayed above the logout button in the bottom menu. */
61
63
  bottomMenuItems?: (user?: LoggedUser) => MenuItem[];
62
64
  /**
63
- * Function invoked when a menu item is clicked. Receives the item's key and **must return a boolean**.
65
+ * Function that returns menu items configuration for the header user-menu dropdown (opened by clicking the user avatar next to the theme toggle). Takes an optional
66
+ * `LoggedUser` object as parameter and returns an array of `MenuItem` objects. Clicks on these items invoke `onMenuClick` with the item's key, but — unlike
67
+ * `menuItems`/`bottomMenuItems` — never trigger the built-in navigation/logout behavior; the host application is fully responsible for reacting to the click (e.g. opening a
68
+ * modal).
69
+ */
70
+ userMenuItems?: (user?: LoggedUser) => MenuItem[];
71
+ /**
72
+ * Function invoked when a menu item is clicked. Receives the item's key.
73
+ *
74
+ * For clicks originating from `menuItems`/`bottomMenuItems` (sidebar navigation), the return value controls the built-in behavior:
75
+ *
76
+ * - Returning **`false`** cancels the internal action (navigation or logout).
77
+ * - Returning **`true`** (or any other truthy value) lets the internal processing continue as usual.
64
78
  *
65
- * - If the callback returns **`false`**, the internal action associated with the click (e.g., navigation, logout) will be **canceled**.
66
- * - If it returns **`true`** or any other truthy value, the internal processing will **continue** as usual.
79
+ * For clicks originating from `userMenuItems` (header user-menu dropdown), there is no built-in action to cancel — the return value is ignored for these clicks.
67
80
  */
68
81
  onMenuClick?: (key: string) => boolean;
69
82
  }
@@ -84,6 +97,11 @@ export interface CodebitConfigProviderProps {
84
97
  secondarySidebarWidth?: number;
85
98
  /** Function that returns bottom‑menu items. */
86
99
  bottomMenuItems?: (user?: LoggedUser) => MenuItem[];
100
+ /**
101
+ * Function that returns items for the header user-menu dropdown (e.g. a "Minhas preferências" entry). Clicks on these items invoke `onMenuClick` but never trigger the
102
+ * built-in navigation/logout behavior — the host application is fully responsible for reacting to the click (e.g. opening a modal).
103
+ */
104
+ userMenuItems?: (user?: LoggedUser) => MenuItem[];
87
105
  /** Function to handle user logout. */
88
106
  doLogout: () => Promise<void>;
89
107
  /** Function to check login status and return user data. */
@@ -91,8 +109,12 @@ export interface CodebitConfigProviderProps {
91
109
  /**
92
110
  * Callback executed when a menu item is clicked. Receives the item's key.
93
111
  *
112
+ * For `menuItems`/`bottomMenuItems` clicks (sidebar navigation):
113
+ *
94
114
  * - Return **`false`** to **prevent** the default internal handling (navigation, logout, etc.).
95
115
  * - Return **`true`** (or any truthy value) to allow the default processing to proceed.
116
+ *
117
+ * For `userMenuItems` clicks (header user-menu dropdown), the return value is ignored — there is no default action to prevent.
96
118
  */
97
119
  onMenuClick?: (key: string) => boolean;
98
120
  }