UNPKG

zp-bee

Version:

zp-bee,是一款基于 Dumi,由 React + TypeScript 开发的组件库 🎉。

111 lines (94 loc) 4.23 kB
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty"; var __rest = this && this.__rest || function (s, e) { var t = {}; for (var p in s) { if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p]; } if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) { if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]]; } return t; }; import React from 'react'; import omit from 'rc-util/lib/omit'; import classNames from 'classnames'; import RcSelect, { Option, OptGroup } from 'rc-select'; import getIcons from './utils/iconUtil'; import { ConfigContext } from '../bee-config'; var SECRET_COMBOBOX_MODE_DO_NOT_USE = 'SECRET_COMBOBOX_MODE_DO_NOT_USE'; var InternalSelect = function InternalSelect(_a, ref) { var _classNames2; var customizePrefixCls = _a.prefixCls, _a$bordered = _a.bordered, bordered = _a$bordered === void 0 ? true : _a$bordered, className = _a.className, getPopupContainer = _a.getPopupContainer, dropdownClassName = _a.dropdownClassName, _a$listHeight = _a.listHeight, listHeight = _a$listHeight === void 0 ? 256 : _a$listHeight, _a$listItemHeight = _a.listItemHeight, listItemHeight = _a$listItemHeight === void 0 ? 24 : _a$listItemHeight, notFoundContent = _a.notFoundContent, props = __rest(_a, ["prefixCls", "bordered", "className", "getPopupContainer", "dropdownClassName", "listHeight", "listItemHeight", "notFoundContent"]); var _React$useContext = React.useContext(ConfigContext), getContextPopupContainer = _React$useContext.getPopupContainer, getPrefixCls = _React$useContext.getPrefixCls, renderEmpty = _React$useContext.renderEmpty, direction = _React$useContext.direction, virtual = _React$useContext.virtual, dropdownMatchSelectWidth = _React$useContext.dropdownMatchSelectWidth; var prefixCls = getPrefixCls('select', customizePrefixCls); var rootPrefixCls = getPrefixCls(); var mode = React.useMemo(function () { var m = props.mode; if (m === 'combobox') { return undefined; } if (m === SECRET_COMBOBOX_MODE_DO_NOT_USE) { return 'combobox'; } return m; }, [props.mode]); var isMultiple = mode === 'multiple' || mode === 'tags'; // ===================== Empty ===================== var mergedNotFound; if (notFoundContent !== undefined) { mergedNotFound = notFoundContent; } else if (mode === 'combobox') { mergedNotFound = null; } else { mergedNotFound = renderEmpty('Select'); } // ===================== Icons ===================== var _getIcons = getIcons(Object.assign(Object.assign({}, props), { multiple: isMultiple, prefixCls: prefixCls })), suffixIcon = _getIcons.suffixIcon, itemIcon = _getIcons.itemIcon, removeIcon = _getIcons.removeIcon, clearIcon = _getIcons.clearIcon; var selectProps = omit(props, ['suffixIcon', 'itemIcon']); var rcSelectRtlDropDownClassName = classNames(dropdownClassName, _defineProperty({}, "".concat(prefixCls, "-dropdown-").concat(direction), direction === 'rtl')); var mergedClassName = classNames((_classNames2 = {}, _defineProperty(_classNames2, "".concat(prefixCls, "-rtl"), direction === 'rtl'), _defineProperty(_classNames2, "".concat(prefixCls, "-borderless"), !bordered), _classNames2), className); return /*#__PURE__*/React.createElement(RcSelect, Object.assign({ ref: ref }, selectProps, { prefixCls: prefixCls, listHeight: listHeight, listItemHeight: listItemHeight, mode: mode, direction: direction, inputIcon: suffixIcon, menuItemSelectedIcon: itemIcon, removeIcon: removeIcon, clearIcon: clearIcon, notFoundContent: mergedNotFound, className: mergedClassName, getPopupContainer: getPopupContainer || getContextPopupContainer })); }; var SelectRef = /*#__PURE__*/React.forwardRef(InternalSelect); var Select = SelectRef; Select.SECRET_COMBOBOX_MODE_DO_NOT_USE = SECRET_COMBOBOX_MODE_DO_NOT_USE; Select.Option = Option; Select.OptGroup = OptGroup; export default Select;