UNPKG

@braineet/ui

Version:

Braineet design system

40 lines 1.79 kB
var _excluded = ["children", "label", "icon", "leftSection", "rightSection", "classNames", "size", "isTruncated"]; function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); } function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (-1 !== e.indexOf(n)) continue; t[n] = r[n]; } return t; } import React from 'react'; import Icon from '../icon'; import Text from '../text'; import { OptionStyled, OptionLabel } from './option.sc'; import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime"; export var Option = /*#__PURE__*/React.forwardRef(function (_ref, ref) { var children = _ref.children, label = _ref.label, icon = _ref.icon, leftSection = _ref.leftSection, rightSection = _ref.rightSection, classNames = _ref.classNames, size = _ref.size, isTruncated = _ref.isTruncated, props = _objectWithoutPropertiesLoose(_ref, _excluded); return /*#__PURE__*/_jsxs(OptionStyled, _extends({ $hasIcon: icon || !label }, props, { ref: ref, children: [leftSection, icon && typeof icon === 'string' ? /*#__PURE__*/_jsx(Icon, { name: icon, className: classNames.icon }) : icon, /*#__PURE__*/_jsxs(OptionLabel, { className: classNames.wrapper, children: [label && /*#__PURE__*/_jsx(Text, { className: classNames.label, size: size, isTruncated: isTruncated, children: label }), children] }), rightSection] })); }); Option.defaultProps = { classNames: {}, size: 'sm' };