UNPKG

@alicloud/console-components

Version:

Alibaba Cloud React Components

34 lines (33 loc) 1.51 kB
var __assign = (this && this.__assign) || function () { __assign = Object.assign || function(t) { for (var s, i = 1, n = arguments.length; i < n; i++) { s = arguments[i]; for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p]; } return t; }; return __assign.apply(this, arguments); }; import React, { forwardRef } from 'react'; import hoistNonReactStatics from 'hoist-non-react-statics'; import { Select as FusionSelect } from '@alifd/next'; import { useCssThemeIsWind } from '../../../hook'; import { hocPopup } from '../../../hoc'; import SelectAutoComplete from './select-auto-complete'; function Select(props, ref) { var _a; var themeIsWind = useCssThemeIsWind(); var menuProps = (function () { if (!themeIsWind) { return props.menuProps; } return __assign({ isSelectIconRight: true }, props.menuProps); })(); return React.createElement(FusionSelect, __assign({}, __assign(__assign({}, props), { autoWidth: (_a = props.autoWidth) !== null && _a !== void 0 ? _a : themeIsWind, // xconsole 以及其他大部分主题,select 下拉 menu 的 padding 较大,不能 autoWidth,否则内容区域太短 menuProps: menuProps, ref: ref }))); } var SelectWithRefWithHoc = hocPopup(forwardRef(Select)); hoistNonReactStatics(SelectWithRefWithHoc, FusionSelect); SelectWithRefWithHoc.AutoComplete = SelectAutoComplete; export default SelectWithRefWithHoc;