UNPKG

@ozen-ui/kit

Version:

React component library

31 lines (30 loc) 2.08 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.Typography = exports.cnTypography = void 0; var tslib_1 = require("tslib"); require("./Typography.css"); var react_1 = tslib_1.__importStar(require("react")); var useThemeProps_1 = require("../../hooks/useThemeProps"); var classname_1 = require("../../utils/classname"); var polymorphicComponentWithRef_1 = require("../../utils/polymorphicComponentWithRef"); var constants_1 = require("./constants"); var utils_1 = require("./utils"); exports.cnTypography = (0, classname_1.cn)('Typography'); exports.Typography = (0, polymorphicComponentWithRef_1.polymorphicComponentWithRef)(function (inProps, ref) { var props = (0, useThemeProps_1.useThemeProps)({ props: inProps, name: 'Typography', }); var _a = props.variant, variant = _a === void 0 ? constants_1.TYPOGRAPHY_DEFAULT_VARIANT : _a, _b = props.color, color = _b === void 0 ? constants_1.TYPOGRAPHY_DEFAULT_COLOR : _b, _c = props.noWrap, noWrap = _c === void 0 ? constants_1.TYPOGRAPHY_DEFAULT_NO_WRAP : _c, _d = props.defaultMargin, defaultMargin = _d === void 0 ? constants_1.TYPOGRAPHY_DEFAULT_DEFAULT_MARGIN : _d, as = props.as, children = props.children, align = props.align, display = props.display, className = props.className, other = tslib_1.__rest(props, ["variant", "color", "noWrap", "defaultMargin", "as", "children", "align", "display", "className"]); // Устанавливает варианту соответсвующий тэг по умолчанию var Tag = (0, react_1.useMemo)(function () { return as || (variant && utils_1.matchVariantToTag[variant]) || 'p'; }, [as, variant]); return (react_1.default.createElement(Tag, tslib_1.__assign({ className: (0, exports.cnTypography)({ variant: variant, defaultMargin: defaultMargin, color: color, align: align, noWrap: noWrap, display: display, }, [className]), ref: ref }, other), children)); }); exports.Typography.displayName = 'Typography';