@kubit-ui-web/react-components
Version:
Kubit React Components is a customizable, accessible library of React web components, designed to enhance your application's user experience
37 lines (36 loc) • 2.53 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.ThemeProvider = void 0;
const jsx_runtime_1 = require("react/jsx-runtime");
const is_prop_valid_1 = __importDefault(require("@emotion/is-prop-valid"));
const styled_components_1 = require("styled-components");
const errorBoundaryProvider_1 = require("../errorBoundary/errorBoundaryProvider");
const genericComponentsProvider_1 = require("../genericComponents/genericComponentsProvider");
const global_style_1 = require("../global.style/global.style");
const themeInformation_1 = require("../themeInformation/themeInformation");
/**
* @name ThemeProvider
* @description
* ThemeProvider is a wrapper component that provides the theme to all components in its subtree via the context API.
* It should be used once at the root of your React component tree.
* @example
* <ThemeProvider styles={theme}>
* <App />
* </ThemeProvider>
* @param {React.ReactNode} children - React children
* @param {DefaultTheme} styles - Theme object
* @param {GenericComponentsType} genericComponents - Generic components
* @param {string} country - Country
* @param {unknown} regex - Regex
* @param {CSSProp} customGlobalStyles - Custom global styles
* @param {ThemeInformation} themeInformation - Theme information
* @returns {JSX.Element} - ThemeProvider component
*/
const ThemeProvider = ({ children, styles, customGlobalStyles, genericComponents, themeInformation, customFonts, showErrors = false, idCreateModal = null, customFallback, }) => {
return ((0, jsx_runtime_1.jsx)(themeInformation_1.ThemeInformationProvider, { value: themeInformation, children: (0, jsx_runtime_1.jsxs)(genericComponentsProvider_1.GenericComponentsProvider, { value: genericComponents, children: [(0, jsx_runtime_1.jsx)(global_style_1.GlobalStyle, { custom: customGlobalStyles, customFonts: customFonts }), (0, jsx_runtime_1.jsx)(styled_components_1.StyleSheetManager, { enableVendorPrefixes: true, shouldForwardProp: is_prop_valid_1.default, children: (0, jsx_runtime_1.jsx)(errorBoundaryProvider_1.ErrorBoundaryProvider, { customFallback: customFallback, idCreateModal: idCreateModal, showErrorMessage: showErrors, children: (0, jsx_runtime_1.jsx)(styled_components_1.ThemeProvider, { theme: styles, children: children }) }) })] }) }));
};
exports.ThemeProvider = ThemeProvider;
//# sourceMappingURL=themeProvider.js.map