@codebit-programando-solucoes/codebit-web-antd 1.1.29 → 1.1.32
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.
|
@@ -8,14 +8,57 @@ import { FC } from 'react';
|
|
|
8
8
|
*
|
|
9
9
|
* **Color tokens:**
|
|
10
10
|
*
|
|
11
|
-
* - --antd-color-bg-
|
|
12
|
-
* - --antd-color-bg-
|
|
13
|
-
* - --antd-color-bg-
|
|
14
|
-
* - --antd-color-
|
|
11
|
+
* - --antd-color-bg-base (Base background color - page background)
|
|
12
|
+
* - --antd-color-bg-container (Background for containers like cards and panels)
|
|
13
|
+
* - --antd-color-bg-elevated (Background for elevated surfaces like modals)
|
|
14
|
+
* - --antd-color-bg-layout (Background for layout components)
|
|
15
|
+
* - --antd-color-bg-mask (Overlay mask background)
|
|
16
|
+
* - --antd-color-bg-spotlight (Spotlight background for focus rings)
|
|
17
|
+
* - --antd-color-border (Base border color)
|
|
18
|
+
* - --antd-color-border-secondary (Secondary border color)
|
|
19
|
+
* - --antd-color-border-hover (Border color on hover state)
|
|
20
|
+
* - --antd-color-border-disabled (Disabled border color)
|
|
15
21
|
* - --antd-color-primary (Primary brand color)
|
|
22
|
+
* - --antd-color-success (Success state color)
|
|
23
|
+
* - --antd-color-success-bg (Success background color)
|
|
24
|
+
* - --antd-color-success-border (Success border color)
|
|
25
|
+
* - --antd-color-success-text (Success text color)
|
|
26
|
+
* - --antd-color-error (Error state color)
|
|
27
|
+
* - --antd-color-error-bg (Error background color)
|
|
28
|
+
* - --antd-color-error-border (Error border color)
|
|
29
|
+
* - --antd-color-error-text (Error text color)
|
|
30
|
+
* - --antd-color-warning (Warning state color)
|
|
31
|
+
* - --antd-color-warning-bg (Warning background color)
|
|
32
|
+
* - --antd-color-warning-border (Warning border color)
|
|
33
|
+
* - --antd-color-warning-text (Warning text color)
|
|
34
|
+
* - --antd-color-info (Informational state color)
|
|
35
|
+
* - --antd-color-info-bg (Info background color)
|
|
36
|
+
* - --antd-color-info-border (Info border color)
|
|
37
|
+
* - --antd-color-info-text (Info text color)
|
|
16
38
|
* - --antd-color-text (Main text color)
|
|
17
39
|
* - --antd-color-text-secondary (Secondary text color)
|
|
40
|
+
* - --antd-color-text-tertiary (Tertiary text color)
|
|
41
|
+
* - --antd-color-text-quaternary (Quaternary text color)
|
|
42
|
+
* - --antd-color-text-disabled (Disabled text color)
|
|
18
43
|
* - --antd-color-split (Split/divider color)
|
|
44
|
+
* - --antd-color-link (Link color)
|
|
45
|
+
* - --antd-color-link-hover (Link hover color)
|
|
46
|
+
* - --antd-color-link-active (Link active color)
|
|
47
|
+
* - --antd-color-fill (General fill color for interactions)
|
|
48
|
+
* - --antd-color-fill-secondary (Secondary fill color for subtle backgrounds)
|
|
49
|
+
* - --antd-color-fill-tertiary (Tertiary fill color for very subtle backgrounds)
|
|
50
|
+
* - --antd-color-fill-quaternary (Quaternary fill color for minimal backgrounds)
|
|
51
|
+
* - --antd-color-fill-content (Content fill color)
|
|
52
|
+
* - --antd-color-fill-content-hover (Content fill hover state)
|
|
53
|
+
* - --antd-color-fill-content-selected (Content fill selected state)
|
|
54
|
+
* - --antd-color-fill-alter (Alternate fill color for alternating rows)
|
|
55
|
+
* - --antd-color-fill-alter-hover (Alternate fill hover state)
|
|
56
|
+
* - --antd-color-fill-alter-active (Alternate fill active state)
|
|
57
|
+
* - --antd-color-fill-alter-selected (Alternate fill selected state)
|
|
58
|
+
* - --antd-color-fill-alter-disabled (Alternate fill disabled state)
|
|
59
|
+
* - --antd-color-fill-disabled (General fill disabled state)
|
|
60
|
+
* - --antd-color-white (Pure white)
|
|
61
|
+
* - --antd-color-black (Pure black)
|
|
19
62
|
*
|
|
20
63
|
* **Margin tokens:**
|
|
21
64
|
*
|
|
@@ -40,18 +83,18 @@ import { FC } from 'react';
|
|
|
40
83
|
*
|
|
41
84
|
* **Font size tokens:**
|
|
42
85
|
*
|
|
43
|
-
* - --antd-font-size-xxs: 8px (Micro text, accessibility disclaimers
|
|
44
|
-
* - --antd-font-size-xs: 10px (Extra small text, fine print
|
|
86
|
+
* - --antd-font-size-xxs: 8px (Micro text, accessibility disclaimers)
|
|
87
|
+
* - --antd-font-size-xs: 10px (Extra small text, fine print)
|
|
45
88
|
* - --antd-font-size-sm: 12px (Small text, captions, labels)
|
|
46
89
|
* - --antd-font-size: 14px (Base font size, body text)
|
|
47
90
|
* - --antd-font-size-lg: 16px (Large text, emphasis)
|
|
48
91
|
* - --antd-font-size-xl: 20px (Extra large text, subheadings)
|
|
49
|
-
* - --antd-font-size-xxl: 24px (Largest base text size
|
|
50
|
-
* - --antd-font-size-heading1: 38px (Primary heading
|
|
51
|
-
* - --antd-font-size-heading2: 30px (Secondary heading
|
|
52
|
-
* - --antd-font-size-heading3: 24px (Tertiary heading
|
|
53
|
-
* - --antd-font-size-heading4: 20px (Quaternary heading
|
|
54
|
-
* - --antd-font-size-heading5: 16px (Quinary heading
|
|
92
|
+
* - --antd-font-size-xxl: 24px (Largest base text size)
|
|
93
|
+
* - --antd-font-size-heading1: 38px (Primary heading)
|
|
94
|
+
* - --antd-font-size-heading2: 30px (Secondary heading)
|
|
95
|
+
* - --antd-font-size-heading3: 24px (Tertiary heading)
|
|
96
|
+
* - --antd-font-size-heading4: 20px (Quaternary heading)
|
|
97
|
+
* - --antd-font-size-heading5: 16px (Quinary heading)
|
|
55
98
|
*
|
|
56
99
|
* **Line height tokens:**
|
|
57
100
|
*
|
|
@@ -72,7 +115,6 @@ import { FC } from 'react';
|
|
|
72
115
|
*
|
|
73
116
|
* @example
|
|
74
117
|
* ```tsx
|
|
75
|
-
*
|
|
76
118
|
* // Place this component at the root level of your app
|
|
77
119
|
* function App() {
|
|
78
120
|
* return (
|
|
@@ -86,13 +128,14 @@ import { FC } from 'react';
|
|
|
86
128
|
*
|
|
87
129
|
* @example
|
|
88
130
|
* ```css
|
|
131
|
+
* // Use the exposed CSS variables
|
|
132
|
+
* .table-row:nth-child(odd) {
|
|
133
|
+
* background-color: var(--antd-color-fill-alter);
|
|
134
|
+
* }
|
|
89
135
|
*
|
|
90
|
-
*
|
|
91
|
-
*
|
|
136
|
+
* .card {
|
|
137
|
+
* border: 1px solid var(--antd-color-border);
|
|
92
138
|
* background-color: var(--antd-color-bg-container);
|
|
93
|
-
* padding: var(--antd-padding-md);
|
|
94
|
-
* color: var(--antd-color-text);
|
|
95
|
-
* font-size: var(--antd-font-size);
|
|
96
139
|
* }
|
|
97
140
|
* ```;
|
|
98
141
|
*/
|
|
@@ -1,7 +1,18 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import type { MenuProps } from 'antd';
|
|
3
2
|
import type { ItemType } from 'antd/es/menu/interface';
|
|
4
3
|
|
|
4
|
+
/** The configuration context for Codebit application, providing access to session and UI settings. */
|
|
5
|
+
export const CodebitConfigContext: React.Context<CodebitConfigContextType | null>;
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Provider component for Codebit configuration and session management.
|
|
9
|
+
*
|
|
10
|
+
* @param props - Configuration provider properties.
|
|
11
|
+
*/
|
|
12
|
+
export function CodebitConfigProvider(
|
|
13
|
+
props: CodebitConfigProviderProps,
|
|
14
|
+
): React.ReactElement;
|
|
15
|
+
|
|
5
16
|
/** Menu item configuration */
|
|
6
17
|
export type MenuItem = ItemType & {
|
|
7
18
|
/** Array of roles that can access this item */
|
|
@@ -20,9 +31,6 @@ export interface LoggedUser {
|
|
|
20
31
|
roles?: string[];
|
|
21
32
|
}
|
|
22
33
|
|
|
23
|
-
/** The configuration context for Codebit application, providing access to session and UI settings. */
|
|
24
|
-
export const CodebitConfigContext: React.Context<CodebitConfigContextType | null>;
|
|
25
|
-
|
|
26
34
|
/** Context type definition for Codebit configuration. */
|
|
27
35
|
export interface CodebitConfigContextType {
|
|
28
36
|
/**
|
|
@@ -49,8 +57,8 @@ export interface CodebitConfigContextType {
|
|
|
49
57
|
secondarySidebar?: (user?: LoggedUser) => React.ReactNode | null;
|
|
50
58
|
/** Width of the secondary sidebar in pixels (default: 280). */
|
|
51
59
|
secondarySidebarWidth?: number;
|
|
52
|
-
/**
|
|
53
|
-
bottomMenuItems?:
|
|
60
|
+
/** Function that returns menu items configuration for items displayed above the logout button in the bottom menu. */
|
|
61
|
+
bottomMenuItems?: (user?: LoggedUser) => MenuItem[];
|
|
54
62
|
/**
|
|
55
63
|
* Function invoked when a menu item is clicked. Receives the item's key and **must return a boolean**.
|
|
56
64
|
*
|
|
@@ -60,15 +68,6 @@ export interface CodebitConfigContextType {
|
|
|
60
68
|
onMenuClick?: (key: string) => boolean;
|
|
61
69
|
}
|
|
62
70
|
|
|
63
|
-
/**
|
|
64
|
-
* Provider component for Codebit configuration and session management.
|
|
65
|
-
*
|
|
66
|
-
* @param props - Configuration provider properties.
|
|
67
|
-
*/
|
|
68
|
-
export function CodebitConfigProvider(
|
|
69
|
-
props: CodebitConfigProviderProps,
|
|
70
|
-
): React.ReactElement;
|
|
71
|
-
|
|
72
71
|
/** Properties for the CodebitConfigProvider component. */
|
|
73
72
|
export interface CodebitConfigProviderProps {
|
|
74
73
|
/** Child components that will have access to the configuration context. */
|
|
@@ -83,8 +82,8 @@ export interface CodebitConfigProviderProps {
|
|
|
83
82
|
secondarySidebar?: (user: LoggedUser) => React.ReactNode | null;
|
|
84
83
|
/** Width of the secondary sidebar in pixels (default: 280). */
|
|
85
84
|
secondarySidebarWidth?: number;
|
|
86
|
-
/**
|
|
87
|
-
bottomMenuItems?:
|
|
85
|
+
/** Function that returns bottom‑menu items. */
|
|
86
|
+
bottomMenuItems?: (user?: LoggedUser) => MenuItem[];
|
|
88
87
|
/** Function to handle user logout. */
|
|
89
88
|
doLogout: () => Promise<void>;
|
|
90
89
|
/** Function to check login status and return user data. */
|
package/dist/index.cjs
CHANGED
|
@@ -329,7 +329,7 @@ var __webpack_exports__ = {};
|
|
|
329
329
|
const codebit_web_namespaceObject = require("@codebit-programando-solucoes/codebit-web");
|
|
330
330
|
const logger = new codebit_web_namespaceObject.Logger('CodebitConfigContext');
|
|
331
331
|
const CodebitConfigContext = /*#__PURE__*/ (0, external_react_.createContext)(null);
|
|
332
|
-
function CodebitConfigProvider({ children, menuItems, version = '1.0', showVersion = ()=>true, secondarySidebar, secondarySidebarWidth = 280, bottomMenuItems
|
|
332
|
+
function CodebitConfigProvider({ children, menuItems, version = '1.0', showVersion = ()=>true, secondarySidebar, secondarySidebarWidth = 280, bottomMenuItems, doLogout, checkLogin, onMenuClick }) {
|
|
333
333
|
const [isLogged, setIsLogged] = (0, external_react_.useState)(null);
|
|
334
334
|
const [user, setUser] = (0, external_react_.useState)(null);
|
|
335
335
|
const logout = async ()=>{
|
|
@@ -398,7 +398,7 @@ var __webpack_exports__ = {};
|
|
|
398
398
|
showVersion: external_prop_types_default().func,
|
|
399
399
|
secondarySidebar: external_prop_types_default().func,
|
|
400
400
|
secondarySidebarWidth: external_prop_types_default().number,
|
|
401
|
-
bottomMenuItems: external_prop_types_default().
|
|
401
|
+
bottomMenuItems: external_prop_types_default().func,
|
|
402
402
|
doLogout: external_prop_types_default().func.isRequired,
|
|
403
403
|
checkLogin: external_prop_types_default().func.isRequired,
|
|
404
404
|
onMenuClick: external_prop_types_default().func
|
|
@@ -801,14 +801,57 @@ var __webpack_exports__ = {};
|
|
|
801
801
|
const { token } = external_antd_namespaceObject.theme.useToken();
|
|
802
802
|
(0, external_react_.useLayoutEffect)(()=>{
|
|
803
803
|
const root = document.documentElement;
|
|
804
|
+
root.style.setProperty('--antd-color-bg-base', token['colorBgBase']);
|
|
804
805
|
root.style.setProperty('--antd-color-bg-container', token['colorBgContainer']);
|
|
805
806
|
root.style.setProperty('--antd-color-bg-elevated', token['colorBgElevated']);
|
|
806
807
|
root.style.setProperty('--antd-color-bg-layout', token['colorBgLayout']);
|
|
807
|
-
root.style.setProperty('--antd-color-
|
|
808
|
+
root.style.setProperty('--antd-color-bg-mask', token['colorBgMask']);
|
|
809
|
+
root.style.setProperty('--antd-color-bg-spotlight', token['colorBgSpotlight']);
|
|
808
810
|
root.style.setProperty('--antd-color-primary', token['colorPrimary']);
|
|
811
|
+
root.style.setProperty('--antd-color-success', token['colorSuccess']);
|
|
812
|
+
root.style.setProperty('--antd-color-success-bg', token['colorSuccessBg']);
|
|
813
|
+
root.style.setProperty('--antd-color-success-border', token['colorSuccessBorder']);
|
|
814
|
+
root.style.setProperty('--antd-color-success-text', token['colorSuccessText']);
|
|
815
|
+
root.style.setProperty('--antd-color-warning', token['colorWarning']);
|
|
816
|
+
root.style.setProperty('--antd-color-warning-bg', token['colorWarningBg']);
|
|
817
|
+
root.style.setProperty('--antd-color-warning-border', token['colorWarningBorder']);
|
|
818
|
+
root.style.setProperty('--antd-color-warning-text', token['colorWarningText']);
|
|
819
|
+
root.style.setProperty('--antd-color-error', token['colorError']);
|
|
820
|
+
root.style.setProperty('--antd-color-error-bg', token['colorErrorBg']);
|
|
821
|
+
root.style.setProperty('--antd-color-error-border', token['colorErrorBorder']);
|
|
822
|
+
root.style.setProperty('--antd-color-error-text', token['colorErrorText']);
|
|
823
|
+
root.style.setProperty('--antd-color-info', token['colorInfo']);
|
|
824
|
+
root.style.setProperty('--antd-color-info-bg', token['colorInfoBg']);
|
|
825
|
+
root.style.setProperty('--antd-color-info-border', token['colorInfoBorder']);
|
|
826
|
+
root.style.setProperty('--antd-color-info-text', token['colorInfoText']);
|
|
809
827
|
root.style.setProperty('--antd-color-text', token['colorText']);
|
|
810
828
|
root.style.setProperty('--antd-color-text-secondary', token['colorTextSecondary']);
|
|
829
|
+
root.style.setProperty('--antd-color-text-tertiary', token['colorTextTertiary']);
|
|
830
|
+
root.style.setProperty('--antd-color-text-quaternary', token['colorTextQuaternary']);
|
|
831
|
+
root.style.setProperty('--antd-color-text-disabled', token['colorTextDisabled']);
|
|
832
|
+
root.style.setProperty('--antd-color-border', token['colorBorder']);
|
|
833
|
+
root.style.setProperty('--antd-color-border-secondary', token['colorBorderSecondary']);
|
|
834
|
+
root.style.setProperty('--antd-color-border-hover', token['colorBorderHover']);
|
|
835
|
+
root.style.setProperty('--antd-color-border-secondary-hover', token['colorBorderSecondaryHover']);
|
|
836
|
+
root.style.setProperty('--antd-color-border-disabled', token['colorBorderDisabled']);
|
|
811
837
|
root.style.setProperty('--antd-color-split', token['colorSplit']);
|
|
838
|
+
root.style.setProperty('--antd-color-link', token['colorLink']);
|
|
839
|
+
root.style.setProperty('--antd-color-link-hover', token['colorLinkHover']);
|
|
840
|
+
root.style.setProperty('--antd-color-link-active', token['colorLinkActive']);
|
|
841
|
+
root.style.setProperty('--antd-color-fill', token['colorFill']);
|
|
842
|
+
root.style.setProperty('--antd-color-fill-secondary', token['colorFillSecondary']);
|
|
843
|
+
root.style.setProperty('--antd-color-fill-tertiary', token['colorFillTertiary']);
|
|
844
|
+
root.style.setProperty('--antd-color-fill-quaternary', token['colorFillQuaternary']);
|
|
845
|
+
root.style.setProperty('--antd-color-fill-content', token['colorFillContent']);
|
|
846
|
+
root.style.setProperty('--antd-color-fill-content-hover', token['colorFillContentHover']);
|
|
847
|
+
root.style.setProperty('--antd-color-fill-content-selected', token['colorFillContentSelected']);
|
|
848
|
+
root.style.setProperty('--antd-color-fill-alter', token['colorFillAlter']);
|
|
849
|
+
root.style.setProperty('--antd-color-fill-alter-hover', token['colorFillAlterHover']);
|
|
850
|
+
root.style.setProperty('--antd-color-fill-alter-active', token['colorFillAlterActive']);
|
|
851
|
+
root.style.setProperty('--antd-color-fill-alter-selected', token['colorFillAlterSelected']);
|
|
852
|
+
root.style.setProperty('--antd-color-fill-alter-disabled', token['colorFillAlterDisabled']);
|
|
853
|
+
root.style.setProperty('--antd-color-white', token['colorWhite']);
|
|
854
|
+
root.style.setProperty('--antd-color-black', token['colorBlack']);
|
|
812
855
|
root.style.setProperty('--antd-margin-xxs', `${token['marginXXS']}px`);
|
|
813
856
|
root.style.setProperty('--antd-margin-xs', `${token['marginXS']}px`);
|
|
814
857
|
root.style.setProperty('--antd-margin-sm', `${token['marginSM']}px`);
|
|
@@ -1057,12 +1100,12 @@ var __webpack_exports__ = {};
|
|
|
1057
1100
|
const navigate = (0, external_react_router_namespaceObject.useNavigate)();
|
|
1058
1101
|
const location = (0, external_react_router_namespaceObject.useLocation)();
|
|
1059
1102
|
if (!configCodebit || !configTheme) throw new Error('LoggedContainer must be used within CodebitConfigProvider and CodebitThemeContext');
|
|
1060
|
-
const { logout, user, menuItems, version, showVersion, secondarySidebar, secondarySidebarWidth = 280, bottomMenuItems
|
|
1103
|
+
const { logout, user, menuItems, version, showVersion, secondarySidebar, secondarySidebarWidth = 280, bottomMenuItems, onMenuClick } = configCodebit;
|
|
1061
1104
|
const { isDarkMode } = configTheme;
|
|
1062
1105
|
const theme = isDarkMode ? 'dark' : 'light';
|
|
1063
1106
|
const allMenuItems = (0, external_react_.useMemo)(()=>[
|
|
1064
1107
|
...menuItems(user),
|
|
1065
|
-
...bottomMenuItems
|
|
1108
|
+
...bottomMenuItems?.(user) ?? []
|
|
1066
1109
|
], [
|
|
1067
1110
|
menuItems,
|
|
1068
1111
|
user,
|
|
@@ -1076,8 +1119,19 @@ var __webpack_exports__ = {};
|
|
|
1076
1119
|
menuItems,
|
|
1077
1120
|
user
|
|
1078
1121
|
]);
|
|
1122
|
+
const filteredBottomMenuItems = (0, external_react_.useMemo)(()=>{
|
|
1123
|
+
if (!bottomMenuItems) return [];
|
|
1124
|
+
return bottomMenuItems(user).filter((item)=>{
|
|
1125
|
+
if (!item.roles) return true;
|
|
1126
|
+
if (!user?.roles) return false;
|
|
1127
|
+
return item.roles.some((role)=>user.roles.includes(role));
|
|
1128
|
+
});
|
|
1129
|
+
}, [
|
|
1130
|
+
bottomMenuItems,
|
|
1131
|
+
user
|
|
1132
|
+
]);
|
|
1079
1133
|
const memoizedBottomMenuItems = (0, external_react_.useMemo)(()=>[
|
|
1080
|
-
...
|
|
1134
|
+
...filteredBottomMenuItems,
|
|
1081
1135
|
{
|
|
1082
1136
|
key: MENU_KEY_APP_LOGOUT,
|
|
1083
1137
|
icon: /*#__PURE__*/ (0, jsx_runtime.jsx)(icons_namespaceObject.LogoutOutlined, {}),
|
|
@@ -1085,7 +1139,7 @@ var __webpack_exports__ = {};
|
|
|
1085
1139
|
danger: true
|
|
1086
1140
|
}
|
|
1087
1141
|
], [
|
|
1088
|
-
|
|
1142
|
+
filteredBottomMenuItems,
|
|
1089
1143
|
t
|
|
1090
1144
|
]);
|
|
1091
1145
|
const [selectedKeys, setSelectedKeys] = (0, external_react_.useState)('');
|