UNPKG

@alifd/meet-react

Version:

Fusion Mobile React UI System Component

45 lines 3.04 kB
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); } 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 _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); } function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); } import { __rest } from "tslib"; import classNames from 'classnames'; import React, { createElement, forwardRef, useContext } from "react"; import Checkbox from '../checkbox'; import List from '../list'; import SelectContext from './context'; var Option = function Option(props, ref) { var _props$disabled = props.disabled, disabled = _props$disabled === void 0 ? false : _props$disabled, children = props.children, className = props.className, value = props.value, _props$isNew = props.isNew, isNew = _props$isNew === void 0 ? false : _props$isNew, _props$onClick = props.onClick, _onClick = _props$onClick === void 0 ? function () {} : _props$onClick, _props$selected = props.selected, selected = _props$selected === void 0 ? false : _props$selected, title = props.title, others = __rest(props, ["disabled", "children", "className", "value", "isNew", "onClick", "selected", "title"]); var _useContext = useContext(SelectContext), prefix = _useContext.prefix; var clsPrefix = "".concat(prefix, "select-option"); return /*#__PURE__*/React.createElement(List.Item, _extends({}, others, { className: classNames(clsPrefix, className, _defineProperty({}, "".concat(clsPrefix, "--disabled"), disabled)), title: children || title, media: /*#__PURE__*/React.createElement(List.ItemMedia, null, /*#__PURE__*/React.createElement(Checkbox, { checked: selected, disabled: disabled || isNew, className: "".concat(clsPrefix, "-checkbox") })), onClick: function onClick() { if (!disabled) { _onClick(value); } } })); }; Option.displayName = 'SelectOption'; export default /*#__PURE__*/forwardRef(Option);