最近一次搜索:{keyword || '尚未输入'}
+ + > + ); +}; diff --git a/src/select/index.md b/src/select/index.md new file mode 100644 index 000000000..605750aef --- /dev/null +++ b/src/select/index.md @@ -0,0 +1,27 @@ +--- +title: Select 选择器 +group: 组件 +toc: content +demo: + cols: 2 +--- + +# Select 选择器 + +基于 antd Select,增加多选区域限高和自动滚动,并统一加载、空状态展示。搜索时支持中文输入法:合成输入期间不调用 `onSearch`,合成结束后发送完整内容,并抑制紧随其后的同值搜索回调。 + +## 示例 + +多选区域限高
+中文搜索
+加载与空状态
+
+## API
+
+### Select
+
+其余属性沿用 antd Select。
+
+| 参数 | 说明 | 类型 | 默认值 |
+| ------- | ---------------------------------------------------------------------------------- | -------- | ------ |
+| maxRows | 选择器最大展示行数。大于 0 时启用限高和选中后自动滚动;未设置或小于等于 0 时不启用 | `number` | - |
diff --git a/src/select/index.scss b/src/select/index.scss
new file mode 100644
index 000000000..053f368ea
--- /dev/null
+++ b/src/select/index.scss
@@ -0,0 +1,17 @@
+$prefix: "dtc-select";
+
+.#{$prefix} {
+ &--scroll {
+ .ant-select-selector {
+ max-height: inherit;
+ overflow-y: auto;
+ }
+ }
+ &__scroll-dropdown {
+ .ant-select-item-empty {
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ }
+ }
+}
diff --git a/src/select/index.tsx b/src/select/index.tsx
new file mode 100644
index 000000000..d77e17477
--- /dev/null
+++ b/src/select/index.tsx
@@ -0,0 +1,99 @@
+import React, { useRef } from 'react';
+import { Select as OriginSelect, SelectProps, Spin } from 'antd';
+import { BaseOptionType, DefaultOptionType } from 'antd/lib/select';
+import classNames from 'classnames';
+import { Empty } from 'dt-react-component';
+
+import './index.scss';
+
+interface ExtendedSelectProps<
+ ValueType = any,
+ OptionType extends BaseOptionType | DefaultOptionType = DefaultOptionType
+> extends SelectProps