Browse Source

Merge remote-tracking branch 'eleme/dev' into carbon

# Conflicts:
#	examples/docs/en-US/input.md
#	examples/docs/zh-CN/input.md
Leopoldthecoder 7 years ago
parent
commit
b922664aa6

+ 1 - 0
examples/docs/en-US/i18n.md

@@ -206,6 +206,7 @@ Currently Element ships with the following languages:
   <li>Estonian (ee)</li>
   <li>Slovenian (sl)</li>
   <li>Arabic (ar)</li>
+  <li>Hebrew (he)</li>
 </ul>
 
 If your target language is not included, you are more than welcome to contribute: just add another language config [here](https://github.com/ElemeFE/element/tree/master/src/locale/lang) and create a pull request.

+ 2 - 1
examples/docs/en-US/input.md

@@ -669,7 +669,8 @@ Attribute | Description | Type | Options | Default
 | popper-class | custom class name for autocomplete's dropdown | string | — | — |
 | trigger-on-focus | whether show suggestions when input focus | boolean | — | true |
 | on-icon-click | hook function when clicking on the input icon | function | — | — |
-|name | same as `name` in native input | string | — | — |
+| name | same as `name` in native input | string | — | — |
+| select-when-unmatched | whether to emit a `select` event on enter when there is no autocomplete match | boolean | — | false |
 
 ### props
 | Attribute | Description | Type | Accepted Values | Default |

+ 27 - 1
examples/docs/en-US/tooltip.md

@@ -15,16 +15,42 @@
         width: 110px;
       }
     }
+    .el-tooltip + .el-tooltip {
+      margin-left: 15px;
+    }
     .box {
+      width: 400px;
+    
+      .top {
+        text-align: center;
+      }
+      
       .left {
         float: left;
         width: 110px;
       }
-
+      
       .right {
         float: right;
         width: 110px;
       }
+      
+      .bottom {
+        clear: both;
+        text-align: center;
+      }
+      
+      .item {
+        margin: 4px;
+      }
+      
+      .left .el-tooltip__popper,
+      .right .el-tooltip__popper {
+        padding: 8px 10px;
+      }
+      .el-tooltip {
+        margin-left: 0;
+      }
     }
   }
 </style>

+ 1 - 0
examples/docs/zh-CN/i18n.md

@@ -218,6 +218,7 @@ ElementLocale.i18n((key, value) => i18n.t(key, value))
   <li>爱沙尼亚语(ee)</li>
   <li>斯洛文尼亚语(sl)</li>
   <li>阿拉伯语(ar)</li>
+  <li>希伯来语(he)</li>
 </ul>
 
 如果你需要使用其他的语言,欢迎贡献 PR:只需在 [这里](https://github.com/ElemeFE/element/tree/master/src/locale/lang) 添加一个语言配置文件即可。

+ 7 - 6
examples/docs/zh-CN/input.md

@@ -825,6 +825,11 @@ export default {
 | focus | 在 Input 获得焦点时触发 | (event: Event) |
 | change | 在 Input 值改变时触发 | (value: string \| number) |
 
+### Input Methods
+| 方法名 | 说明 | 参数 |
+| ---- | ---- | ---- |
+| focus | 使 input 获取焦点 | - |
+
 ### Autocomplete Attributes
 
 | 参数          | 说明            | 类型            | 可选值                 | 默认值   |
@@ -840,8 +845,9 @@ export default {
 | on-icon-click | 点击图标的回调函数 | function | — | — |
 | icon          | 输入框尾部图标    | string          | — | — |
 | name | 原生属性 | string | — | — |
+| select-when-unmatched | 在输入没有任何匹配建议的情况下,按下回车是否触发 `select` 事件 | boolean | — | false |
 
-### Props
+### props
 | 参数     | 说明              | 类型   | 可选值 | 默认值 |
 | -------- | ----------------- | ------ | ------ | ------ |
 | value    | 指定选项的值为选项对象的某个属性值 | string | — | value |
@@ -851,8 +857,3 @@ export default {
 | 事件名称 | 说明 | 回调参数 |
 |---------|--------|---------|
 | select | 点击选中建议项时触发 | 选中建议项 |
-
-### Methods
-| 方法名 | 说明 | 参数 |
-| ---- | ---- | ---- |
-| focus | 使 input 获取焦点 | - |

+ 1 - 0
examples/docs/zh-CN/tooltip.md

@@ -215,3 +215,4 @@ tooltip 内不支持 disabled form 元素,参考[MDN](https://developer.mozill
 | manual | 手动控制模式,设置为 true 后,mouseenter 和 mouseleave 事件将不会生效 | Boolean | — | false |
 | popper-class | 为 Tooltip 的 popper 添加类名 | String | — | — |
 | enterable | 鼠标是否可进入到 tooltip 中 | Boolean | — | true |
+| hide-after | Tooltip 出现后自动隐藏延时,单位毫秒,为 0 则不会自动隐藏 | number | — | 0 |

+ 16 - 2
packages/autocomplete/src/autocomplete.vue

@@ -74,7 +74,11 @@
       },
       customItem: String,
       icon: String,
-      onIconClick: Function
+      onIconClick: Function,
+      selectWhenUnmatched: {
+        type: Boolean,
+        default: false
+      }
     },
     data() {
       return {
@@ -142,6 +146,12 @@
         if (this.suggestionVisible && this.highlightedIndex >= 0 && this.highlightedIndex < this.suggestions.length) {
           e.preventDefault();
           this.select(this.suggestions[this.highlightedIndex]);
+        } else if (this.selectWhenUnmatched) {
+          this.$emit('select', {value: this.value});
+          this.$nextTick(_ => {
+            this.suggestions = [];
+            this.highlightedIndex = -1;
+          });
         }
       },
       select(item) {
@@ -149,11 +159,15 @@
         this.$emit('select', item);
         this.$nextTick(_ => {
           this.suggestions = [];
+          this.highlightedIndex = -1;
         });
       },
       highlight(index) {
         if (!this.suggestionVisible || this.loading) { return; }
-        if (index < 0) index = 0;
+        if (index < 0) {
+          this.highlightedIndex = -1;
+          return;
+        }
         if (index >= this.suggestions.length) {
           index = this.suggestions.length - 1;
         }

+ 1 - 1
packages/date-picker/src/basic/month-table.vue

@@ -67,7 +67,7 @@
         var year = this.date.getFullYear();
         var date = new Date(0);
         date.setFullYear(year);
-        date.setMonth(month);
+        date.setMonth(month, 1);
         date.setHours(0);
         var nextMonth = new Date(date);
         nextMonth.setMonth(month + 1);

+ 1 - 3
packages/date-picker/src/basic/year-table.vue

@@ -63,9 +63,7 @@
       getCellStyle(year) {
         const style = {};
 
-        var date = new Date(0);
-        date.setFullYear(year);
-        date.setHours(0);
+        var date = new Date(year, 0, 1, 0);
         var nextYear = new Date(date);
         nextYear.setFullYear(year + 1);
 

+ 10 - 1
packages/date-picker/src/panel/date-range.vue

@@ -156,6 +156,14 @@
   import DateTable from '../basic/date-table';
   import ElInput from 'element-ui/packages/input';
 
+  const calcDefaultValue = defaultValue => {
+    if (Array.isArray(defaultValue)) {
+      return new Date(defaultValue[0]);
+    } else {
+      return new Date(defaultValue);
+    }
+  };
+
   export default {
     mixins: [Locale],
 
@@ -232,7 +240,7 @@
         popperClass: '',
         minPickerWidth: 0,
         maxPickerWidth: 0,
-        date: new Date(),
+        date: this.$options.defaultValue ? calcDefaultValue(this.$options.defaultValue) : new Date(),
         minDate: '',
         maxDate: '',
         rangeState: {
@@ -309,6 +317,7 @@
       handleClear() {
         this.minDate = null;
         this.maxDate = null;
+        this.date = this.$options.defaultValue ? calcDefaultValue(this.$options.defaultValue) : new Date();
         this.handleConfirm(false);
       },
 

+ 1 - 1
packages/table/src/filter-panel.vue

@@ -19,7 +19,7 @@
     <div class="el-table-filter" v-else v-show="showPopper">
       <ul class="el-table-filter__list">
         <li class="el-table-filter__list-item"
-            :class="{ 'is-active': !filterValue }"
+            :class="{ 'is-active': filterValue === undefined || filterValue === null }"
             @click="handleSelect(null)">{{ t('el.table.clearFilter') }}</li>
         <li class="el-table-filter__list-item"
             v-for="filter in filters"

+ 3 - 2
packages/tooltip/src/main.js

@@ -88,16 +88,17 @@ export default {
     if (!this.$slots.default || !this.$slots.default.length) return this.$slots.default;
 
     const vnode = getFirstComponentChild(this.$slots.default);
-    if (!vnode || this.handlerAdded) return vnode;
+    if (!vnode) return vnode;
     const data = vnode.data = vnode.data || {};
     const on = vnode.data.on = vnode.data.on || {};
     const nativeOn = vnode.data.nativeOn = vnode.data.nativeOn || {};
 
+    data.staticClass = this.concatClass(data.staticClass, 'el-tooltip');
+    if (this.handlerAdded) return vnode;
     on.mouseenter = this.addEventHandle(on.mouseenter, () => { this.setExpectedState(true); this.handleShowPopper(); });
     on.mouseleave = this.addEventHandle(on.mouseleave, () => { this.setExpectedState(false); this.debounceClose(); });
     nativeOn.mouseenter = this.addEventHandle(nativeOn.mouseenter, () => { this.setExpectedState(true); this.handleShowPopper(); });
     nativeOn.mouseleave = this.addEventHandle(nativeOn.mouseleave, () => { this.setExpectedState(false); this.debounceClose(); });
-    data.staticClass = this.concatClass(data.staticClass, 'el-tooltip');
 
     return vnode;
   },

+ 1 - 1
packages/upload/src/ajax.js

@@ -48,7 +48,7 @@ export default function upload(option) {
   const formData = new FormData();
 
   if (option.data) {
-    Object.keys(option.data).map(key => {
+    Object.keys(option.data).forEach(key => {
       formData.append(key, option.data[key]);
     });
   }

+ 9 - 9
packages/upload/src/index.vue

@@ -139,13 +139,13 @@ export default {
       this.onChange(file, this.uploadFiles);
     },
     handleProgress(ev, rawFile) {
-      var file = this.getFile(rawFile);
+      const file = this.getFile(rawFile);
       this.onProgress(ev, file, this.uploadFiles);
       file.status = 'uploading';
       file.percentage = ev.percent || 0;
     },
     handleSuccess(res, rawFile) {
-      var file = this.getFile(rawFile);
+      const file = this.getFile(rawFile);
 
       if (file) {
         file.status = 'success';
@@ -156,8 +156,8 @@ export default {
       }
     },
     handleError(err, rawFile) {
-      var file = this.getFile(rawFile);
-      var fileList = this.uploadFiles;
+      const file = this.getFile(rawFile);
+      const fileList = this.uploadFiles;
 
       file.status = 'fail';
 
@@ -171,13 +171,13 @@ export default {
         file = this.getFile(raw);
       }
       this.abort(file);
-      var fileList = this.uploadFiles;
+      let fileList = this.uploadFiles;
       fileList.splice(fileList.indexOf(file), 1);
       this.onRemove(file, fileList);
     },
     getFile(rawFile) {
-      var fileList = this.uploadFiles;
-      var target;
+      let fileList = this.uploadFiles;
+      let target;
       fileList.every(item => {
         target = rawFile.uid === item.uid ? item : null;
         return !target;
@@ -209,7 +209,7 @@ export default {
   },
 
   render(h) {
-    var uploadList;
+    let uploadList;
 
     if (this.showFileList) {
       uploadList = (
@@ -223,7 +223,7 @@ export default {
       );
     }
 
-    var uploadData = {
+    const uploadData = {
       props: {
         type: this.type,
         drag: this.drag,

+ 2 - 2
packages/upload/src/upload.vue

@@ -90,12 +90,12 @@ export default {
             this.post(rawFile);
           }
         }, () => {
-          this.onRemove(rawFile, true);
+          this.onRemove(null, rawFile);
         });
       } else if (before !== false) {
         this.post(rawFile);
       } else {
-        this.onRemove(rawFile, true);
+        this.onRemove(null, rawFile);
       }
     },
     abort(file) {

+ 4 - 4
src/locale/lang/he.js

@@ -95,10 +95,10 @@ export default {
     transfer: {
       noMatch: 'אין נתונים מתאימים',
       noData: 'ללא נתונים',
-      titles: ['רשימה 1', 'רשימה 2'], // to be translated
-      filterPlaceholder: 'הקלד', // to be translated
-      noCheckedFormat: 'פריטים {total}', // to be translated
-      hasCheckedFormat: ' אישור {checked}/{total}' // to be translated
+      titles: ['רשימה 1', 'רשימה 2'],
+      filterPlaceholder: 'הקלד',
+      noCheckedFormat: 'פריטים {total}',
+      hasCheckedFormat: ' אישור {checked}/{total}'
     }
   }
 };

+ 7 - 19
test/unit/specs/date-picker.spec.js

@@ -358,23 +358,11 @@ describe('DatePicker', () => {
   });
 
   it('default value', done => {
-    const toDateStr = date => {
-      let d = new Date(date);
-      return `${d.getFullYear()}-${d.getMonth()}-${d.getDate()}`;
-    };
-    let today = new Date();
-    let nextMonth = new Date(today);
-    nextMonth.setDate(1);
-    if (nextMonth.getMonth() === 12) {
-      nextMonth.setFullYear(today.getFullYear + 1);
-      nextMonth.setMonth(1);
-    } else {
-      nextMonth.setMonth(today.getMonth() + 1);
-    }
-    let nextMonthStr = toDateStr(nextMonth);
+    let defaultValue = '2000-01-01';
+    let expectValue = new Date(2000, 0, 1);
 
     vm = createVue({
-      template: `<el-date-picker v-model="value" ref="compo" default-value="${nextMonthStr}" />`,
+      template: `<el-date-picker v-model="value" ref="compo" default-value="${defaultValue}" />`,
       data() {
         return {
           value: ''
@@ -389,10 +377,10 @@ describe('DatePicker', () => {
       const $el = vm.$refs.compo.picker.$el;
       $el.querySelector('td.current').click();
       setTimeout(_ => {
-        expect(vm.value).to.equal(nextMonthStr);
-      });
-      done();
-    });
+        expect(+vm.value).to.equal(+expectValue);
+        done();
+      }, 10);
+    }, 10);
   });
 
   describe('keydown', () => {