UNPKG

@ozen-ui/kit

Version:

React component library

20 lines (19 loc) 1.19 kB
import { __assign, __rest } from "tslib"; import './ThemeProvider.css'; import React from 'react'; import { useDeprecatedTheme } from '../../hooks/useDeprecated'; import { cn } from '../../utils/classname'; import { polymorphicComponentWithRef } from '../../utils/polymorphicComponentWithRef'; import { THEME_DEFAULT_TAG } from './constants'; import { ThemeProviderContext } from './ThemeProviderContext'; export var cnThemeProvider = cn('Theme'); /** * @deprecated Компонент устарел. Для замены используйте компонент <OzenProvider> */ export var ThemeProvider = polymorphicComponentWithRef(function (_a, ref) { var children = _a.children, theme = _a.theme, className = _a.className, _b = _a.as, Tag = _b === void 0 ? THEME_DEFAULT_TAG : _b, other = __rest(_a, ["children", "theme", "className", "as"]); useDeprecatedTheme(); return (React.createElement(ThemeProviderContext.Provider, { value: theme }, React.createElement(Tag, __assign({ className: cnThemeProvider(theme === null || theme === void 0 ? void 0 : theme.tokens, [className]) }, other, { ref: ref }), children))); }); ThemeProvider.displayName = 'ThemeProvider';