@codebit-programando-solucoes/codebit-web-antd 1.1.32 → 1.1.33
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.
|
@@ -139,4 +139,10 @@ import { FC } from 'react';
|
|
|
139
139
|
* }
|
|
140
140
|
* ```;
|
|
141
141
|
*/
|
|
142
|
-
export
|
|
142
|
+
export interface CssTokenBridgeProps {
|
|
143
|
+
/** Optional ID of the container element to receive the CSS variables. */
|
|
144
|
+
containerId?: string;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
/** CssTokenBridge component definition. */
|
|
148
|
+
export const CssTokenBridge: FC<CssTokenBridgeProps>;
|
|
@@ -23,4 +23,8 @@ type CodebitThemeProviderProps = {
|
|
|
23
23
|
children: React.ReactNode;
|
|
24
24
|
/** Whether to persist theme preference in localStorage (default: `true`) */
|
|
25
25
|
storeThemeInLocalStorage?: boolean;
|
|
26
|
+
/** ID of the root container element where theme classes are applied (default: `'root'`) */
|
|
27
|
+
containerId?: string;
|
|
28
|
+
/** Optional explicit theme override. When set, the provider uses this value instead of internal detection. */
|
|
29
|
+
forcedTheme?: 'dark' | 'light' | null;
|
|
26
30
|
} & ConfigProviderProps;
|
package/dist/index.cjs
CHANGED
|
@@ -797,10 +797,10 @@ var __webpack_exports__ = {};
|
|
|
797
797
|
tableContainer: null,
|
|
798
798
|
actions: null
|
|
799
799
|
};
|
|
800
|
-
const CssTokenBridge = ()=>{
|
|
800
|
+
const CssTokenBridge = ({ containerId })=>{
|
|
801
801
|
const { token } = external_antd_namespaceObject.theme.useToken();
|
|
802
802
|
(0, external_react_.useLayoutEffect)(()=>{
|
|
803
|
-
const root = document.documentElement;
|
|
803
|
+
const root = containerId ? document.getElementById(containerId) ?? document.documentElement : document.documentElement;
|
|
804
804
|
root.style.setProperty('--antd-color-bg-base', token['colorBgBase']);
|
|
805
805
|
root.style.setProperty('--antd-color-bg-container', token['colorBgContainer']);
|
|
806
806
|
root.style.setProperty('--antd-color-bg-elevated', token['colorBgElevated']);
|
|
@@ -888,10 +888,14 @@ var __webpack_exports__ = {};
|
|
|
888
888
|
root.style.setProperty('--antd-border-radius', `${token['borderRadius']}px`);
|
|
889
889
|
root.style.setProperty('--antd-border-radius-lg', `${token['borderRadiusLG']}px`);
|
|
890
890
|
}, [
|
|
891
|
+
containerId,
|
|
891
892
|
token
|
|
892
893
|
]);
|
|
893
894
|
return null;
|
|
894
895
|
};
|
|
896
|
+
CssTokenBridge.propTypes = {
|
|
897
|
+
containerId: external_prop_types_default().string
|
|
898
|
+
};
|
|
895
899
|
const TableContainer_module = {
|
|
896
900
|
tableContainer: "tableContainer-EhNwOm"
|
|
897
901
|
};
|
|
@@ -980,9 +984,10 @@ var __webpack_exports__ = {};
|
|
|
980
984
|
...external_antd_namespaceObject.Card.propTypes
|
|
981
985
|
};
|
|
982
986
|
const CodebitThemeContext = /*#__PURE__*/ (0, external_react_.createContext)(null);
|
|
983
|
-
const CodebitThemeProvider = ({ children, storeThemeInLocalStorage = true, ...props })=>{
|
|
987
|
+
const CodebitThemeProvider = ({ children, storeThemeInLocalStorage = true, containerId = 'root', forcedTheme = null, ...props })=>{
|
|
984
988
|
const hasLoaded = (0, external_react_.useRef)(false);
|
|
985
989
|
const [isDarkMode, setIsDarkMode] = (0, external_react_.useState)(()=>{
|
|
990
|
+
if (forcedTheme) return 'dark' === forcedTheme;
|
|
986
991
|
try {
|
|
987
992
|
if (storeThemeInLocalStorage) {
|
|
988
993
|
const savedTheme = localStorage?.getItem('theme');
|
|
@@ -993,27 +998,39 @@ var __webpack_exports__ = {};
|
|
|
993
998
|
hasLoaded.current = true;
|
|
994
999
|
}
|
|
995
1000
|
});
|
|
1001
|
+
(0, external_react_.useEffect)(()=>{
|
|
1002
|
+
if (forcedTheme) {
|
|
1003
|
+
const mode = 'dark' === forcedTheme;
|
|
1004
|
+
setIsDarkMode(mode);
|
|
1005
|
+
}
|
|
1006
|
+
}, [
|
|
1007
|
+
forcedTheme
|
|
1008
|
+
]);
|
|
996
1009
|
const toggleTheme = ()=>{
|
|
997
1010
|
setIsDarkMode((prev)=>!prev);
|
|
998
1011
|
};
|
|
999
1012
|
(0, external_react_.useEffect)(()=>{
|
|
1000
|
-
const
|
|
1013
|
+
const target = document.getElementById(containerId);
|
|
1014
|
+
if (!target) return;
|
|
1001
1015
|
if (isDarkMode) {
|
|
1002
1016
|
document.documentElement.classList.add('dark-theme');
|
|
1003
|
-
|
|
1017
|
+
target.classList.add('dark-theme');
|
|
1004
1018
|
} else {
|
|
1005
1019
|
document.documentElement.classList.remove('dark-theme');
|
|
1006
|
-
|
|
1020
|
+
target.classList.remove('dark-theme');
|
|
1007
1021
|
}
|
|
1008
1022
|
document.documentElement.style.setProperty('--color-primary', isDarkMode ? '#589C75' : '#29D266');
|
|
1009
1023
|
}, [
|
|
1010
|
-
isDarkMode
|
|
1024
|
+
isDarkMode,
|
|
1025
|
+
containerId
|
|
1011
1026
|
]);
|
|
1012
1027
|
(0, external_react_.useEffect)(()=>{
|
|
1013
1028
|
if (hasLoaded.current && storeThemeInLocalStorage) localStorage.setItem('theme', isDarkMode ? 'dark' : 'light');
|
|
1029
|
+
if (hasLoaded.current && storeThemeInLocalStorage && !forcedTheme) localStorage.setItem('theme', isDarkMode ? 'dark' : 'light');
|
|
1014
1030
|
}, [
|
|
1015
1031
|
isDarkMode,
|
|
1016
|
-
storeThemeInLocalStorage
|
|
1032
|
+
storeThemeInLocalStorage,
|
|
1033
|
+
forcedTheme
|
|
1017
1034
|
]);
|
|
1018
1035
|
const themeContextValue = (0, external_react_.useMemo)(()=>({
|
|
1019
1036
|
isDarkMode,
|
|
@@ -1056,7 +1073,9 @@ var __webpack_exports__ = {};
|
|
|
1056
1073
|
},
|
|
1057
1074
|
...props,
|
|
1058
1075
|
children: [
|
|
1059
|
-
/*#__PURE__*/ (0, jsx_runtime.jsx)(CssTokenBridge, {
|
|
1076
|
+
/*#__PURE__*/ (0, jsx_runtime.jsx)(CssTokenBridge, {
|
|
1077
|
+
containerId: containerId
|
|
1078
|
+
}),
|
|
1060
1079
|
children
|
|
1061
1080
|
]
|
|
1062
1081
|
})
|
|
@@ -1064,7 +1083,13 @@ var __webpack_exports__ = {};
|
|
|
1064
1083
|
};
|
|
1065
1084
|
CodebitThemeProvider.propTypes = {
|
|
1066
1085
|
children: external_prop_types_default().node.isRequired,
|
|
1067
|
-
storeThemeInLocalStorage: external_prop_types_default().bool
|
|
1086
|
+
storeThemeInLocalStorage: external_prop_types_default().bool,
|
|
1087
|
+
containerId: external_prop_types_default().string,
|
|
1088
|
+
forcedTheme: external_prop_types_default().oneOf([
|
|
1089
|
+
'dark',
|
|
1090
|
+
'light',
|
|
1091
|
+
null
|
|
1092
|
+
])
|
|
1068
1093
|
};
|
|
1069
1094
|
const LoggedMainContainer_module = {
|
|
1070
1095
|
layout: "layout-mL5o6I",
|