Merge remote-tracking branch 'upstream/2.0' into popper

This commit is contained in:
huanghong 2018-04-10 12:42:32 +08:00
commit 586bf3fc1b
16 changed files with 191 additions and 100 deletions

View file

@ -115,7 +115,8 @@ If you want to contribute or have questions or bugs to report:
|---|---|---|---|---|---|
|[Aresn](https://github.com/icarusion) | ![](https://avatars3.githubusercontent.com/u/5370542?v=3&s=60) |[jingsam](https://github.com/jingsam) | ![](https://avatars3.githubusercontent.com/u/1522494?v=3&s=60) | [rijn](https://github.com/rijn) | ![](https://avatars2.githubusercontent.com/u/6976367?v=3&s=60) |
|[lcx960324](https://github.com/lcx960324) | ![](https://avatars3.githubusercontent.com/u/9768245?v=3&s=60) |[GITleonine1989](https://github.com/GITleonine1989) | ![](https://avatars1.githubusercontent.com/u/7582490?v=3&s=60) |[huixisheng](https://github.com/huixisheng) | ![](https://avatars1.githubusercontent.com/u/1518967?v=3&s=60) |
|[Sergio Crisostomo](https://github.com/SergioCrisostomo) | ![](https://avatars3.githubusercontent.com/u/5614559?v=3&s=60) | [lison16](https://github.com/lison16) | ![](https://avatars3.githubusercontent.com/u/20942571?v=3&s=60) | [Xotic750](https://github.com/Xotic750) | ![](https://avatars3.githubusercontent.com/u/216041?v=3&s=60)
|[Sergio Crisostomo](https://github.com/SergioCrisostomo) | ![](https://avatars3.githubusercontent.com/u/5614559?v=3&s=60) | [lison16](https://github.com/lison16) | ![](https://avatars3.githubusercontent.com/u/20942571?v=3&s=60) | [Xotic750](https://github.com/Xotic750) | ![](https://avatars3.githubusercontent.com/u/216041?v=3&s=60) |
[huanghong1125](https://github.com/huanghong1125) | ![](https://avatars3.githubusercontent.com/u/12794817?v=3&s=60) |
## Links

View file

@ -1,46 +1,69 @@
<template>
<Menu active-name="1-2" :open-names="['1']" theme="dark">
<Submenu name="1">
<template slot="title">
<Icon type="ios-analytics"></Icon>
Navigation One
</template>
<MenuGroup title="Item 1">
<MenuItem name="1-1">Option 1</MenuItem>
<MenuItem name="1-2">Option 2</MenuItem>
</MenuGroup>
<MenuGroup title="Item 2">
<MenuItem name="1-3">Option 3</MenuItem>
<MenuItem name="1-4">Option 4</MenuItem>
</MenuGroup>
</Submenu>
<Submenu name="2">
<template slot="title">
<Icon type="ios-filing"></Icon>
Navigation Two
</template>
<MenuItem name="2-1">Option 5</MenuItem>
<MenuItem name="2-2">Option 6</MenuItem>
<Submenu name="3">
<template slot="title">Submenu</template>
<MenuItem name="3-1">Option 7</MenuItem>
<MenuItem name="3-2">Option 8</MenuItem>
<div>
<Menu ref="menu" active-name="1-2" :open-names="openNames" theme="dark" accordion @on-open-change="handleOpenChange">
<Submenu name="1">
<template slot="title">
<Icon type="ios-analytics"></Icon>
Navigation One
</template>
<MenuGroup title="Item 1">
<MenuItem name="1-1">Option 1</MenuItem>
<MenuItem name="1-2">Option 2</MenuItem>
</MenuGroup>
<MenuGroup title="Item 2">
<MenuItem name="1-3">Option 3</MenuItem>
<MenuItem name="1-4">Option 4</MenuItem>
</MenuGroup>
</Submenu>
</Submenu>
<Submenu name="4">
<template slot="title">
<Icon type="ios-gear"></Icon>
Navigation Three
</template>
<MenuItem name="4-1">Option 9</MenuItem>
<MenuItem name="4-2">Option 10</MenuItem>
<MenuItem name="4-3">Option 11</MenuItem>
<MenuItem name="4-4">Option 12</MenuItem>
</Submenu>
</Menu>
<Submenu name="2">
<template slot="title">
<Icon type="ios-filing"></Icon>
Navigation Two
</template>
<MenuItem name="2-1">Option 5</MenuItem>
<MenuItem name="2-2">Option 6</MenuItem>
<Submenu name="3">
<template slot="title">Submenu</template>
<MenuItem name="3-1">Option 7</MenuItem>
<MenuItem name="3-2">Option 8</MenuItem>
</Submenu>
<Submenu name="4">
<template slot="title">Submenu</template>
<MenuItem name="4-1">Option 7</MenuItem>
<MenuItem name="4-2">Option 8</MenuItem>
</Submenu>
</Submenu>
<Submenu name="5">
<template slot="title">
<Icon type="ios-gear"></Icon>
Navigation Three
</template>
<MenuItem name="5-1">Option 9</MenuItem>
<MenuItem name="5-2">Option 10</MenuItem>
<MenuItem name="5-3">Option 11</MenuItem>
<MenuItem name="5-4">Option 12</MenuItem>
</Submenu>
</Menu>
<Button @click="setOpenNames">修改展开数组</Button>
</div>
</template>
<script>
export default {
data () {
return {
openNames: ['1']
};
},
methods: {
handleOpenChange (name) {
console.log(name)
},
setOpenNames () {
this.openNames = ['2', '3'];
this.$nextTick(() => {
this.$refs.menu.updateOpened();
})
}
}
}
</script>

View file

@ -1,21 +1,28 @@
<template>
<div style="margin: 200px;">
<Poptip title="提示标题" transfer>
<div slot="content" style="padding: 50px">
<Button>click me</Button>
</div>
<Button>click 激活</Button>
</Poptip>
<div style="margin: 200px">
<Tabs value="name1">
<TabPane label="标签一" name="name1">
<div style="overflow: auto;width: 200px;height:300px">
<Poptip title="提示标题" content="标签一的内容" placement="right" transfer :options="options">
<Button id="aaa">右边</Button>
</Poptip>
</div>
</TabPane>
<TabPane label="标签二" name="name2">标签二的内容</TabPane>
</Tabs>
</div>
</template>
<script>
export default {
methods: {
ok () {
this.$Message.info('点击了确定');
},
cancel () {
this.$Message.info('点击了取消');
data () {
return {
options: {
modifiers: {
preventOverflow: {
boundariesElement: 'body',
}
}
}
}
}
}

View file

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

View file

@ -1,6 +1,11 @@
<template>
<div :class="classes">
<div :class="headClasses" v-if="showHead"><slot name="title"></slot></div>
<div :class="headClasses" v-if="showHead"><slot name="title">
<p v-if="title">
<Icon v-if="icon" :type="icon"></Icon>
{{title}}
</p>
</slot></div>
<div :class="extraClasses" v-if="showExtra"><slot name="extra"></slot></div>
<div :class="bodyClasses" :style="bodyStyles"><slot></slot></div>
</div>
@ -8,10 +13,11 @@
<script>
const prefixCls = 'ivu-card';
const defaultPadding = 16;
import Icon from '../icon/icon.vue';
export default {
name: 'Card',
components: { Icon },
props: {
bordered: {
type: Boolean,
@ -28,6 +34,12 @@
padding: {
type: Number,
default: defaultPadding
},
title: {
type: String,
},
icon: {
type: String,
}
},
data () {
@ -67,7 +79,7 @@
}
},
mounted () {
this.showHead = this.$slots.title !== undefined;
this.showHead = this.title || this.$slots.title !== undefined;
this.showExtra = this.$slots.extra !== undefined;
}
};

View file

@ -3,7 +3,7 @@
</template>
<script>
const prefixCls = 'ivu-dropdown-item';
import { findComponentUpward } from '../../utils/assist';
export default {
name: 'DropdownItem',
props: {
@ -37,7 +37,7 @@
},
methods: {
handleClick () {
const $parent = this.$parent.$parent.$parent;
const $parent = findComponentUpward(this, 'Dropdown');
const hasChildren = this.$parent && this.$parent.$options.name === 'Dropdown';
if (this.disabled) {

View file

@ -92,6 +92,7 @@
this.validateState = val;
}
},
inject: ['form'],
computed: {
classes () {
return [
@ -103,13 +104,13 @@
}
];
},
form() {
let parent = this.$parent;
while (parent.$options.name !== 'iForm') {
parent = parent.$parent;
}
return parent;
},
// form() {
// let parent = this.$parent;
// while (parent.$options.name !== 'iForm') {
// parent = parent.$parent;
// }
// return parent;
// },
fieldValue: {
cache: false,
get() {

View file

@ -40,6 +40,9 @@
default: 'off'
}
},
provide() {
return { form : this };
},
data () {
return {
fields: []

View file

@ -2,7 +2,7 @@
<div :class="wrapClasses">
<template v-if="type !== 'textarea'">
<div :class="[prefixCls + '-group-prepend']" v-if="prepend" v-show="slotReady"><slot name="prepend"></slot></div>
<i class="ivu-icon" :class="['ivu-icon-ios-close', prefixCls + '-icon', prefixCls + '-icon-clear' , prefixCls + '-icon-normal']" v-if="clearable" @click="handleClear"></i>
<i class="ivu-icon" :class="['ivu-icon-ios-close', prefixCls + '-icon', prefixCls + '-icon-clear' , prefixCls + '-icon-normal']" v-if="clearable && currentValue" @click="handleClear"></i>
<i class="ivu-icon" :class="['ivu-icon-' + icon, prefixCls + '-icon', prefixCls + '-icon-normal']" v-else-if="icon" @click="handleIconClick"></i>
<transition name="fade">
<i class="ivu-icon ivu-icon-load-c ivu-load-loop" :class="[prefixCls + '-icon', prefixCls + '-icon-validate']" v-if="!icon"></i>

View file

@ -43,7 +43,8 @@
},
data () {
return {
currentActiveName: this.activeName
currentActiveName: this.activeName,
openedNames: []
};
},
computed: {
@ -76,36 +77,40 @@
this.broadcast('MenuItem', 'on-update-active-name', this.currentActiveName);
},
updateOpenKeys (name) {
const index = this.openNames.indexOf(name);
if (index > -1) {
this.openNames.splice(index, 1);
let names = [...this.openedNames];
const index = names.indexOf(name);
if (index >= 0) {
names.splice(index, 1);
} else {
this.openNames.push(name);
if (this.accordion) {
let currentSubmenu = {};
let currentSubmenu = null;
findComponentsDownward(this, 'Submenu').forEach(item => {
if (item.name === name) currentSubmenu = item;
});
findBrothersComponents(currentSubmenu, 'Submenu').forEach(item => {
let index = this.openNames.indexOf(item.name);
this.openNames.splice(index, index >= 0 ? 1 : 0);
let i = names.indexOf(item.name);
if (i >= 0) names.splice(i, 1);
});
this.openNames.push(name);
names.push(name);
}
}
this.openedNames = names;
this.$emit('on-open-change', this.openedNames);
},
updateOpened () {
const items = findComponentsDownward(this, 'Submenu');
if (items.length) {
items.forEach(item => {
if (this.openNames.indexOf(item.name) > -1) item.opened = true;
if (this.openedNames.indexOf(item.name) > -1) item.opened = true;
else item.opened = false;
});
}
}
},
mounted () {
this.updateActiveName();
this.openedNames = [...this.openNames];
this.updateOpened();
this.$on('on-menu-item-select', (name) => {
this.currentActiveName = name;
@ -113,8 +118,8 @@
});
},
watch: {
openNames () {
this.$emit('on-open-change', this.openNames);
openNames (names) {
this.openedNames = names;
},
activeName (val) {
this.currentActiveName = val;

View file

@ -21,7 +21,8 @@
data () {
return {
popper: null,
width: ''
width: '',
popperStatus: false
};
},
computed: {
@ -37,6 +38,7 @@
if (this.popper) {
this.$nextTick(() => {
this.popper.update();
this.popperStatus = true;
});
} else {
this.$nextTick(() => {
@ -65,10 +67,11 @@
destroy () {
if (this.popper) {
setTimeout(() => {
if (this.popper) {
if (this.popper && !this.popperStatus) {
this.popper.destroy();
this.popper = null;
}
this.popperStatus = false;
}, 300);
}
},

View file

@ -3,6 +3,7 @@
<Input-number
v-if="!range && showInput"
:min="min"
:size="inputSize"
:max="max"
:step="step"
:value="exportValue[0]"
@ -120,6 +121,13 @@
type: Boolean,
default: false
},
inputSize: {
type: String,
default: 'default',
validator (value) {
return oneOf(value, ['small', 'large', 'default']);
}
},
showStops: {
type: Boolean,
default: false
@ -151,7 +159,7 @@
startX: 0,
currentX: 0,
startPos: 0,
oldValue: val,
oldValue: [...val],
valueIndex: {
min: 0,
max: 1,
@ -327,7 +335,7 @@
if (type === 'min') newPos = this.checkLimits([newPos, this.maxPosition])[0];
else newPos = this.checkLimits([this.minPosition, newPos])[1];
const modulus = newPos % this.step;
const modulus = this.handleDecimal(newPos,this.step);
const value = this.currentValue;
value[index] = newPos - modulus;
this.currentValue = [...value];
@ -339,7 +347,20 @@
}
}
},
handleDecimal(pos,step){
if(step<1){
let sl = step.toString(),
multiple = 1,
m;
try {
m = sl.split('.')[1].length;
} catch (e){
m = 0;
}
multiple = Math.pow(10,m);
return (pos * multiple) % (step * multiple) / multiple;
}else return pos % step;
},
emitChange(){
const value = this.range ? this.exportValue : this.exportValue[0];
this.$emit('on-change', value);

View file

@ -17,11 +17,12 @@
<span v-else :class="titleClasses" @click="handleSelect">{{ data.title }}</span>
<Tree-node
v-if="data.expand"
v-for="(item, i) in data.children"
v-for="(item, i) in children"
:key="i"
:data="item"
:multiple="multiple"
:show-checkbox="showCheckbox">
:show-checkbox="showCheckbox"
:children-key="childrenKey">
</Tree-node>
</li>
</ul>
@ -52,6 +53,10 @@
type: Boolean,
default: false
},
childrenKey: {
type: String,
default: 'children'
},
showCheckbox: {
type: Boolean,
default: false
@ -93,7 +98,7 @@
];
},
showArrow () {
return (this.data.children && this.data.children.length) || ('loading' in this.data && !this.data.loading);
return (this.data[this.childrenKey] && this.data[this.childrenKey].length) || ('loading' in this.data && !this.data.loading);
},
showLoading () {
return 'loading' in this.data && this.data.loading;
@ -118,6 +123,9 @@
} else {
return [];
}
},
children () {
return this.data[this.childrenKey];
}
},
methods: {
@ -126,14 +134,14 @@
if (item.disabled) return;
// async loading
if (item.children.length === 0) {
if (item[this.childrenKey].length === 0) {
const tree = findComponentUpward(this, 'Tree');
if (tree && tree.loadData) {
this.$set(this.data, 'loading', true);
tree.loadData(item, children => {
this.$set(this.data, 'loading', false);
if (children.length) {
this.$set(this.data, 'children', children);
this.$set(this.data, this.childrenKey, children);
this.$nextTick(() => this.handleExpand());
}
});
@ -141,7 +149,7 @@
}
}
if (item.children && item.children.length) {
if (item[this.childrenKey] && item[this.childrenKey].length) {
this.$set(this.data, 'expand', !this.data.expand);
this.dispatch('Tree', 'toggle-expand', this.data);
}

View file

@ -6,7 +6,8 @@
:data="item"
visible
:multiple="multiple"
:show-checkbox="showCheckbox">
:show-checkbox="showCheckbox"
:children-key="childrenKey">
</Tree-node>
<div :class="[prefixCls + '-empty']" v-if="!stateTree.length">{{ localeEmptyText }}</div>
</div>
@ -40,6 +41,10 @@
emptyText: {
type: String
},
childrenKey: {
type: String,
default: 'children'
},
loadData: {
type: Function
},
@ -76,18 +81,19 @@
methods: {
compileFlatState () { // so we have always a relation parent/children of each node
let keyCounter = 0;
let childrenKey = this.childrenKey;
const flatTree = [];
function flattenChildren(node, parent) {
node.nodeKey = keyCounter++;
flatTree[node.nodeKey] = { node: node, nodeKey: node.nodeKey };
if (typeof parent != 'undefined') {
flatTree[node.nodeKey].parent = parent.nodeKey;
flatTree[parent.nodeKey].children.push(node.nodeKey);
flatTree[parent.nodeKey][childrenKey].push(node.nodeKey);
}
if (node.children) {
flatTree[node.nodeKey].children = [];
node.children.forEach(child => flattenChildren(child, node));
if (node[childrenKey]) {
flatTree[node.nodeKey][childrenKey] = [];
node[childrenKey].forEach(child => flattenChildren(child, node));
}
}
this.stateTree.forEach(rootNode => {
@ -104,11 +110,11 @@
if (node.checked == parent.checked && node.indeterminate == parent.indeterminate) return; // no need to update upwards
if (node.checked == true) {
this.$set(parent, 'checked', parent.children.every(node => node.checked));
this.$set(parent, 'checked', parent[this.childrenKey].every(node => node.checked));
this.$set(parent, 'indeterminate', !parent.checked);
} else {
this.$set(parent, 'checked', false);
this.$set(parent, 'indeterminate', parent.children.some(node => node.checked || node.indeterminate));
this.$set(parent, 'indeterminate', parent[this.childrenKey].some(node => node.checked || node.indeterminate));
}
this.updateTreeUp(parentKey);
},
@ -139,8 +145,8 @@
for (let key in changes) {
this.$set(node, key, changes[key]);
}
if (node.children) {
node.children.forEach(child => {
if (node[this.childrenKey]) {
node[this.childrenKey].forEach(child => {
this.updateTreeDown(child, changes);
});
}

View file

@ -236,6 +236,8 @@
}
&-dropdown-list {
display: inline-block;
min-width: 100%;
list-style: none;
}
}

View file

@ -354,7 +354,6 @@
}
label {
display: block;
margin-bottom: 4px;
& > span{
margin-right: 4px;