From 100a3b39ef85523c1fd6c35c4b5a608740236b19 Mon Sep 17 00:00:00 2001
From: tangjinzhou <415800467@qq.com>
Date: Tue, 27 Feb 2018 19:08:49 +0800
Subject: [PATCH] add auto-complete
---
components/_util/vue-types/index.js | 2 +-
components/auto-complete/InputElement.vue | 31 ++++++
components/auto-complete/index.vue | 124 ++++++++++++++++++++++
components/auto-complete/style/index.js | 4 +
components/auto-complete/style/index.less | 79 ++++++++++++++
components/select/index.vue | 15 ++-
components/vc-select/PropTypes.js | 5 +-
contributors.md | 14 +--
8 files changed, 260 insertions(+), 14 deletions(-)
create mode 100644 components/auto-complete/InputElement.vue
create mode 100644 components/auto-complete/index.vue
create mode 100644 components/auto-complete/style/index.js
create mode 100644 components/auto-complete/style/index.less
diff --git a/components/_util/vue-types/index.js b/components/_util/vue-types/index.js
index 5d2a8e5f6..4c9997c05 100644
--- a/components/_util/vue-types/index.js
+++ b/components/_util/vue-types/index.js
@@ -1,5 +1,5 @@
import isPlainObject from 'lodash.isplainobject'
-import { noop, toType, getType, isFunction, validateType, isInteger, isArray, warn } from './utils'
+import { toType, getType, isFunction, validateType, isInteger, isArray, warn } from './utils'
const VuePropTypes = {
diff --git a/components/auto-complete/InputElement.vue b/components/auto-complete/InputElement.vue
new file mode 100644
index 000000000..55a059ac3
--- /dev/null
+++ b/components/auto-complete/InputElement.vue
@@ -0,0 +1,31 @@
+
diff --git a/components/auto-complete/index.vue b/components/auto-complete/index.vue
new file mode 100644
index 000000000..38bfedcaf
--- /dev/null
+++ b/components/auto-complete/index.vue
@@ -0,0 +1,124 @@
+
diff --git a/components/auto-complete/style/index.js b/components/auto-complete/style/index.js
new file mode 100644
index 000000000..83c9edd2b
--- /dev/null
+++ b/components/auto-complete/style/index.js
@@ -0,0 +1,4 @@
+import '../../style/index.less'
+import './index.less'
+
+import '../../select/style'
diff --git a/components/auto-complete/style/index.less b/components/auto-complete/style/index.less
new file mode 100644
index 000000000..a8105799c
--- /dev/null
+++ b/components/auto-complete/style/index.less
@@ -0,0 +1,79 @@
+@import "../../style/themes/default";
+@import "../../style/mixins/index";
+@import "../../input/style/mixin";
+
+@input-prefix-cls: ~"@{ant-prefix}-input";
+@select-prefix-cls: ~"@{ant-prefix}-select";
+@autocomplete-prefix-cls: ~"@{select-prefix-cls}-auto-complete";
+
+.@{autocomplete-prefix-cls} {
+ .reset-component;
+
+ &.@{select-prefix-cls} {
+ .@{select-prefix-cls} {
+ &-selection {
+ border: 0;
+ box-shadow: none;
+ &__rendered {
+ margin-left: 0;
+ margin-right: 0;
+ height: 100%;
+ line-height: @input-height-base;
+ }
+ &__placeholder {
+ margin-left: (@input-padding-horizontal-base + 1px);
+ margin-right: (@input-padding-horizontal-base + 1px);
+ }
+
+ &--single {
+ height: auto;
+ }
+ }
+ }
+
+ // Fix https://github.com/ant-design/ant-design/issues/7800
+ .@{select-prefix-cls}-search--inline {
+ position: static;
+ float: left;
+ }
+
+ &-allow-clear {
+ .@{select-prefix-cls}-selection:hover .@{select-prefix-cls}-selection__rendered {
+ margin-right: 0 !important;
+ }
+ }
+
+ .@{input-prefix-cls} {
+ background: transparent;
+ border-width: @border-width-base;
+ line-height: @line-height-base;
+ height: @input-height-base;
+ &:focus,
+ &:hover {
+ .hover;
+ }
+ }
+
+ &-lg {
+ .@{select-prefix-cls}-selection__rendered {
+ line-height: @input-height-lg;
+ }
+ .@{input-prefix-cls} {
+ padding-top: @input-padding-vertical-lg;
+ padding-bottom: @input-padding-vertical-lg;
+ height: @input-height-lg;
+ }
+ }
+
+ &-sm {
+ .@{select-prefix-cls}-selection__rendered {
+ line-height: @input-height-sm;
+ }
+ .@{input-prefix-cls} {
+ padding-top: @input-padding-vertical-sm;
+ padding-bottom: @input-padding-vertical-sm;
+ height: @input-height-sm;
+ }
+ }
+ }
+}
diff --git a/components/select/index.vue b/components/select/index.vue
index 02d9c7dcd..e5672e7d8 100644
--- a/components/select/index.vue
+++ b/components/select/index.vue
@@ -26,12 +26,23 @@ const AbstractSelectProps = {
PropTypes.func,
]),
}
+const Value = PropTypes.shape({
+ key: String,
+}).loose
const SelectValue = PropTypes.oneOfType([
PropTypes.string,
- PropTypes.array,
- PropTypes.object,
+
+ PropTypes.arrayOf(PropTypes.oneOfType([
+ Value,
+ String,
+ ])),
+ Value,
])
+export {
+ AbstractSelectProps,
+ SelectValue,
+}
const SelectProps = {
...AbstractSelectProps,
diff --git a/components/vc-select/PropTypes.js b/components/vc-select/PropTypes.js
index acbbcc7d9..ef8794027 100644
--- a/components/vc-select/PropTypes.js
+++ b/components/vc-select/PropTypes.js
@@ -34,10 +34,7 @@ export const SelectPropTypes = {
dropdownStyle: PropTypes.object,
maxTagTextLength: PropTypes.number,
maxTagCount: PropTypes.number,
- maxTagPlaceholder: PropTypes.oneOfType([
- PropTypes.node,
- PropTypes.func,
- ]),
+ maxTagPlaceholder: PropTypes.any,
tokenSeparators: PropTypes.arrayOf(PropTypes.string),
getInputElement: PropTypes.func,
showAction: PropTypes.arrayOf(PropTypes.string),
diff --git a/contributors.md b/contributors.md
index 8be397727..767cf632b 100644
--- a/contributors.md
+++ b/contributors.md
@@ -16,25 +16,25 @@ Divider | done
notification | done
message | done
Select | done
-Carousel
-Mention
-Input | done |select完成后补全demo
+Input | done
InputNumber
AutoComplete
-Upload
-Form
+Modal
+Alert
Calendar
DatePicker
TimePicker
+Upload
+Form
+Carousel
+Mention
##万
Grid
Col
Affix
-Alert
BackTop
Layout
-Modal
Anchor
Tree
TreeSelect