UNPKG

@ozen-ui/kit

Version:

React component library

24 lines (23 loc) 2.24 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.Card = exports.cnCard = void 0; var tslib_1 = require("tslib"); require("./Card.css"); var react_1 = tslib_1.__importDefault(require("react")); var useThemeProps_1 = require("../../hooks/useThemeProps"); var classname_1 = require("../../utils/classname"); var polymorphicComponentWithRef_1 = require("../../utils/polymorphicComponentWithRef"); var Paper_1 = require("../Paper"); var utils_1 = require("./utils"); exports.cnCard = (0, classname_1.cn)('Card'); exports.Card = (0, polymorphicComponentWithRef_1.polymorphicComponentWithRef)(function (inProps, ref) { var props = (0, useThemeProps_1.useThemeProps)({ props: inProps, name: 'Card' }); var _a = props.size, size = _a === void 0 ? 'm' : _a, _b = props.disabled, disabled = _b === void 0 ? false : _b, _c = props.interactive, interactive = _c === void 0 ? false : _c, _d = props.borderWidth, borderWidth = _d === void 0 ? 's' : _d, _e = props.borderVariant, borderVariant = _e === void 0 ? 'solid' : _e, _f = props.borderColor, borderColor = _f === void 0 ? 'standard' : _f, _g = props.backgroundColor, backgroundColor = _g === void 0 ? 'standard' : _g, _h = props.as, Tag = _h === void 0 ? 'div' : _h, className = props.className, children = props.children, other = tslib_1.__rest(props, ["size", "disabled", "interactive", "borderWidth", "borderVariant", "borderColor", "backgroundColor", "as", "className", "children"]); var shouldBeInteractive = !disabled && interactive; var shouldShowBorder = borderWidth !== 'none'; return (react_1.default.createElement(Paper_1.Paper, tslib_1.__assign({ as: Tag, radius: utils_1.matchBorderRadiusPaperToCard[size], background: utils_1.matchBackgroundColorPaperToCard[backgroundColor] }, (shouldBeInteractive && { tabIndex: 0 }), { "aria-disabled": disabled }, other, { ref: ref, className: (0, exports.cnCard)(tslib_1.__assign({ size: size, disabled: disabled, interactive: shouldBeInteractive, backgroundColor: backgroundColor, borderWidth: borderWidth }, (shouldShowBorder && { borderVariant: borderVariant, borderColor: borderColor, })), [className]) }), children)); }); exports.Card.displayName = 'Card';