Merge pull request #15 from iview/2.0

更新到最新版本
This commit is contained in:
yangdan8 2018-11-12 00:03:41 -06:00 committed by GitHub
commit 47ecd33930
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
19 changed files with 351 additions and 231 deletions

396
dist/iview.js vendored

File diff suppressed because one or more lines are too long

2
dist/iview.js.map vendored

File diff suppressed because one or more lines are too long

4
dist/iview.min.js vendored

File diff suppressed because one or more lines are too long

BIN
dist/iview.min.js.gz vendored

Binary file not shown.

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -58,7 +58,7 @@ export declare interface Tabs extends Vue {
}; };
} }
export declare interface TabsPane extends Vue { export declare interface TabPane extends Vue {
/** /**
* value * value
*/ */

View file

@ -1,6 +1,6 @@
{ {
"name": "iview", "name": "iview",
"version": "3.1.4", "version": "3.1.5",
"title": "iView", "title": "iView",
"description": "A high quality UI components Library with Vue.js", "description": "A high quality UI components Library with Vue.js",
"homepage": "http://www.iviewui.com", "homepage": "http://www.iviewui.com",

View file

@ -151,6 +151,7 @@
this.$emit('on-search', query); this.$emit('on-search', query);
}, },
handleChange (val) { handleChange (val) {
if (val === undefined || val === null) return;
this.currentValue = val; this.currentValue = val;
this.$refs.input.blur(); this.$refs.input.blur();
this.$emit('on-select', val); this.$emit('on-select', val);

View file

@ -1,27 +1,9 @@
<template> <template>
<a <component :is="tagName" :class="classes" :disabled="disabled" @click="handleClickLink" v-bind="tagProps">
v-if="to"
:class="classes"
:disabled="disabled"
:href="linkUrl"
:target="target"
@click.exact="handleClickLink($event, false)"
@click.ctrl="handleClickLink($event, true)"
@click.meta="handleClickLink($event, true)">
<Icon class="ivu-load-loop" type="ios-loading" v-if="loading"></Icon> <Icon class="ivu-load-loop" type="ios-loading" v-if="loading"></Icon>
<Icon :type="icon" :custom="customIcon" v-if="(icon || customIcon) && !loading"></Icon> <Icon :type="icon" :custom="customIcon" v-if="(icon || customIcon) && !loading"></Icon>
<span v-if="showSlot" ref="slot"><slot></slot></span> <span v-if="showSlot" ref="slot"><slot></slot></span>
</a> </component>
<button
v-else
:type="htmlType"
:class="classes"
:disabled="disabled"
@click="handleClickLink">
<Icon class="ivu-load-loop" type="ios-loading" v-if="loading"></Icon>
<Icon :type="icon" :custom="customIcon" v-if="(icon || customIcon) && !loading"></Icon>
<span v-if="showSlot" ref="slot"><slot></slot></span>
</button>
</template> </template>
<script> <script>
import Icon from '../icon'; import Icon from '../icon';
@ -98,14 +80,34 @@
[`${prefixCls}-ghost`]: this.ghost [`${prefixCls}-ghost`]: this.ghost
} }
]; ];
},
// Point out if it should render as <a> tag
isHrefPattern() {
const {to} = this;
return !!to;
},
tagName() {
const {isHrefPattern} = this;
return isHrefPattern ? 'a' : 'button';
},
tagProps() {
const {isHrefPattern} = this;
if(isHrefPattern) {
const {linkUrl,target}=this;
return {href: linkUrl, target};
} else {
const {htmlType} = this;
return {type: htmlType};
}
} }
}, },
methods: { methods: {
// Ctrl or CMD and click, open in new window when use `to` // Ctrl or CMD and click, open in new window when use `to`
handleClickLink (event, new_window = false) { handleClickLink (event) {
this.$emit('click', event); this.$emit('click', event);
const openInNewWindow = event.ctrlKey || event.metaKey;
this.handleCheckClick(event, new_window); this.handleCheckClick(event, openInNewWindow);
} }
}, },
mounted () { mounted () {

View file

@ -753,7 +753,14 @@
}, },
visible(state){ visible(state){
this.$emit('on-open-change', state); this.$emit('on-open-change', state);
},
slotOptions(options, old){
// dropdown
// dropdown
if (options && old && options.length !== old.length) {
this.broadcast('Drop', 'on-update-popper');
} }
},
} }
}; };
</script> </script>

View file

@ -379,7 +379,7 @@
}, },
handleInputChange (val) { handleInputChange (val) {
this.currentValue = [val, this.currentValue[1]]; this.currentValue = [val || this.min, this.currentValue[1]];
this.emitChange(); this.emitChange();
}, },

View file

@ -18,23 +18,23 @@
<Icon type="ios-arrow-forward"></Icon> <Icon type="ios-arrow-forward"></Icon>
</div> </div>
</template> </template>
<Cell <table-expand
v-if="renderType === 'render'" v-if="renderType === 'render'"
:row="row" :row="row"
:column="column" :column="column"
:index="index" :index="index"
:render="column.render"></Cell> :render="column.render"></table-expand>
</div> </div>
</template> </template>
<script> <script>
import Cell from './expand'; import TableExpand from './expand';
import Icon from '../icon/icon.vue'; import Icon from '../icon/icon.vue';
import Checkbox from '../checkbox/checkbox.vue'; import Checkbox from '../checkbox/checkbox.vue';
import Tooltip from '../tooltip/tooltip.vue'; import Tooltip from '../tooltip/tooltip.vue';
export default { export default {
name: 'TableCell', name: 'TableCell',
components: { Icon, Checkbox, Cell, Tooltip }, components: { Icon, Checkbox, TableExpand, Tooltip },
props: { props: {
prefixCls: String, prefixCls: String,
row: Object, row: Object,

View file

@ -14,7 +14,7 @@
@click.native="clickCurrentRow(row._index)" @click.native="clickCurrentRow(row._index)"
@dblclick.native.stop="dblclickCurrentRow(row._index)"> @dblclick.native.stop="dblclickCurrentRow(row._index)">
<td v-for="column in columns" :class="alignCls(column, row)"> <td v-for="column in columns" :class="alignCls(column, row)">
<Cell <table-cell
:fixed="fixed" :fixed="fixed"
:prefix-cls="prefixCls" :prefix-cls="prefixCls"
:row="row" :row="row"
@ -25,7 +25,7 @@
:checked="rowChecked(row._index)" :checked="rowChecked(row._index)"
:disabled="rowDisabled(row._index)" :disabled="rowDisabled(row._index)"
:expanded="rowExpanded(row._index)" :expanded="rowExpanded(row._index)"
></Cell> ></table-cell>
</td> </td>
</table-tr> </table-tr>
<tr v-if="rowExpanded(row._index)" :class="{[prefixCls + '-expanded-hidden']: fixed}"> <tr v-if="rowExpanded(row._index)" :class="{[prefixCls + '-expanded-hidden']: fixed}">
@ -40,14 +40,14 @@
<script> <script>
// todo :key="row" // todo :key="row"
import TableTr from './table-tr.vue'; import TableTr from './table-tr.vue';
import Cell from './cell.vue'; import TableCell from './cell.vue';
import Expand from './expand.js'; import Expand from './expand.js';
import Mixin from './mixin'; import Mixin from './mixin';
export default { export default {
name: 'TableBody', name: 'TableBody',
mixins: [ Mixin ], mixins: [ Mixin ],
components: { Cell, Expand, TableTr }, components: { TableCell, Expand, TableTr },
props: { props: {
prefixCls: String, prefixCls: String,
styleObject: Object, styleObject: Object,

View file

@ -153,16 +153,29 @@
&-disabled { &-disabled {
cursor: @cursor-disabled; cursor: @cursor-disabled;
background: #f3f3f3; opacity: .4;
border-color: #f3f3f3;
&:after { &:after {
background: #ccc; background: #fff;
cursor: not-allowed; cursor: not-allowed;
} }
.@{switch-prefix-cls}-inner { .@{switch-prefix-cls}-inner {
color: #ccc; color: #fff;
}
}
&-disabled&-checked{
border-color: @primary-color;
background-color: @primary-color;
opacity: .4;
&:after {
background: #fff;
}
.@{switch-prefix-cls}-inner {
color: #fff;
} }
} }

View file

@ -2,6 +2,7 @@ export default {
'de-DE': 'Oktober 2030', 'de-DE': 'Oktober 2030',
'en-US': 'October 2030', 'en-US': 'October 2030',
'es-ES': 'octubre 2030', 'es-ES': 'octubre 2030',
'fi-FI': 'lokakuu 2030',
'fr-FR': 'octobre 2030', 'fr-FR': 'octobre 2030',
'id-ID': 'Oktober 2030', 'id-ID': 'Oktober 2030',
'ja-JP': '2030年 10月', 'ja-JP': '2030年 10月',

View file

@ -0,0 +1,66 @@
import { createVue, destroyVM } from '../util';
describe('Button.vue', () => {
let vm;
afterEach(() => {
destroyVM(vm);
});
it('should render as <a>', done => {
vm = createVue(`
<Button to="http://www.thinkinfe.tech/">Think in FE</Button>
`);
expect(vm.$el.tagName).to.equal('A');
done();
});
it('should render as <button>', done => {
vm = createVue(`
<Button>Think in FE</Button>
`);
expect(vm.$el.tagName).to.equal('BUTTON');
done();
});
it('handle with `type` attribute', done => {
// should render with `type` attribute
// if it is a <button>
vm = createVue(`
<Button htmlType="reset">Think in FE</Button>
`);
expect(vm.$el.getAttribute('type')).to.equal('reset');
// should't render with `type` attribute
// if it is a <button>
vm = createVue(`
<Button to="http://www.thinkinfe.tech/" htmlType="reset">Think in FE</Button>
`);
expect(vm.$el.getAttribute('type')).to.equal(null);
done();
});
it('should change loading state', done => {
vm = createVue({
template: `
<Button :loading="loading" @click="fetch">Think in FE</Button>
`,
data() {
return {loading: false};
},
methods: {
fetch() {
this.loading = true;
}
}
});
vm.$el.click();
vm.$nextTick(() => {
expect(vm.$el.classList.contains('ivu-btn-loading')).to.equal(true);
const $icons = vm.$el.querySelectorAll('.ivu-icon');
expect($icons.length).to.equal(1);
expect($icons[0].classList.contains('ivu-load-loop')).to.equal(true);
expect($icons[0].classList.contains('ivu-icon-ios-loading')).to.equal(true);
done();
});
});
});

View file

@ -371,7 +371,7 @@ describe('DatePicker.vue', () => {
const formater = require('../../../src/components/date-picker/util').formatDateLabels; const formater = require('../../../src/components/date-picker/util').formatDateLabels;
const expectedResults = require('./assets/locale-expects.js').default; const expectedResults = require('./assets/locale-expects.js').default;
const locales = [ const locales = [
'de-DE', 'en-US', 'es-ES', 'fr-FR', 'id-ID', 'ja-JP', 'ko-KR', 'pt-BR', 'de-DE', 'en-US', 'es-ES', 'fi-FI', 'fr-FR', 'id-ID', 'ja-JP', 'ko-KR', 'pt-BR',
'pt-PT', 'ru-RU', 'sv-SE', 'tr-TR', 'vi-VN', 'zh-CN', 'zh-TW' 'pt-PT', 'ru-RU', 'sv-SE', 'tr-TR', 'vi-VN', 'zh-CN', 'zh-TW'
].reduce((obj, locale) => { ].reduce((obj, locale) => {
obj[locale] = require('../../../src/locale/lang/' + locale).default; obj[locale] = require('../../../src/locale/lang/' + locale).default;

2
types/tabs.d.ts vendored
View file

@ -58,7 +58,7 @@ export declare interface Tabs extends Vue {
}; };
} }
export declare interface TabsPane extends Vue { export declare interface TabPane extends Vue {
/** /**
* value * value
*/ */