UNPKG

@braineet/ui

Version:

Braineet design system

41 lines 1.99 kB
var _excluded = ["children", "label", "icon", "leftSection", "rightSection", "classNames", "size", "isTruncated"]; function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); } function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; } import React from 'react'; import Icon from '../icon'; import Text from '../text'; import { OptionStyled, OptionLabel } from './option.sc'; import { jsx as _jsx } from "react/jsx-runtime"; import { 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' };