diff --git a/components/checkbox/Checkbox.vue b/components/checkbox/Checkbox.vue index d98fa3da1..826666e5a 100644 --- a/components/checkbox/Checkbox.vue +++ b/components/checkbox/Checkbox.vue @@ -27,15 +27,23 @@ export default { value: [String, Number, Boolean], name: String, indeterminate: Boolean, - onGroupChange: Function, }, model: { prop: 'checked', }, + inject: { + context: { default: undefined }, + }, data () { - const { checked, defaultChecked } = this + const { context, checked, defaultChecked, value } = this + let stateChecked + if (context && context.checkedStatus) { + stateChecked = context.checkedStatus.has(value) + } return { - stateChecked: checked === undefined ? defaultChecked : checked, + stateChecked: stateChecked === undefined + ? checked === undefined ? defaultChecked : checked + : stateChecked, } }, computed: { @@ -64,26 +72,27 @@ export default { handleChange (event) { const targetChecked = event.target.checked this.$emit('input', targetChecked) - const { name, value, checked } = this - if (checked === undefined) { + const { name, value, checked, context, stateChecked } = this + if ((checked === undefined && !context) || (context && context.value === undefined)) { this.stateChecked = targetChecked } const target = { name, value, - checked: targetChecked, + checked: !stateChecked, } - this.$emit('change', { - target, - stopPropagation () { - event.stopPropagation() - }, - preventDefault () { - event.preventDefault() - }, - }) - if (this.isGroup) { - this.onGroupChange({ target }) + if (this.context) { + this.context.handleChange({ target }) + } else { + this.$emit('change', { + target, + stopPropagation () { + event.stopPropagation() + }, + preventDefault () { + event.preventDefault() + }, + }) } }, }, @@ -91,6 +100,9 @@ export default { checked (val) { this.stateChecked = val }, + 'context.checkedStatus': function (checkedStatus) { + this.stateChecked = checkedStatus.has(this.value) + }, }, } diff --git a/components/checkbox/Group.vue b/components/checkbox/Group.vue index ef2518833..1668f846a 100644 --- a/components/checkbox/Group.vue +++ b/components/checkbox/Group.vue @@ -31,6 +31,11 @@ export default { model: { prop: 'value', }, + provide () { + return { + context: this, + } + }, data () { const { value, defaultValue } = this return { @@ -50,9 +55,6 @@ export default { }) }, }, - created () { - this.setChildCheckbox(this.$slots.default) - }, methods: { handleChange (event) { const target = event.target @@ -73,31 +75,12 @@ export default { this.$emit('input', newVal) this.$emit('change', newVal) }, - setChildCheckbox (children = []) { - const { options, $slots, checkedStatus } = this - if (options.length === 0 && $slots.default) { - children.forEach(({ componentOptions = {}, children: newChildren }) => { - const { Ctor, propsData } = componentOptions - if (Ctor && Ctor.options.name === 'Checkbox') { - propsData.isGroup = true - propsData.onGroupChange = this.handleChange - propsData.checked = checkedStatus.has(propsData.value) - } else { - this.setChildCheckbox(newChildren) - } - }, this) - } - }, }, mounted () { }, - beforeUpdate () { - this.setChildCheckbox(this.$slots.default) - }, watch: { value (val) { this.stateValue = val - this.setChildCheckbox(this.$slots.default) }, }, components: { diff --git a/components/checkbox/demo/controller.vue b/components/checkbox/demo/controller.vue index 825ff1fd4..d1e1efe14 100644 --- a/components/checkbox/demo/controller.vue +++ b/components/checkbox/demo/controller.vue @@ -1,18 +1,62 @@ diff --git a/components/checkbox/demo/group.vue b/components/checkbox/demo/group.vue index f037068aa..7a944effa 100644 --- a/components/checkbox/demo/group.vue +++ b/components/checkbox/demo/group.vue @@ -4,7 +4,7 @@

- +
diff --git a/components/checkbox/demo/index.vue b/components/checkbox/demo/index.vue new file mode 100644 index 000000000..eea51bd1d --- /dev/null +++ b/components/checkbox/demo/index.vue @@ -0,0 +1,35 @@ + + diff --git a/components/checkbox/demo/layout.vue b/components/checkbox/demo/layout.vue index 825ff1fd4..c4e4708d0 100644 --- a/components/checkbox/demo/layout.vue +++ b/components/checkbox/demo/layout.vue @@ -1,18 +1,27 @@ diff --git a/components/index.js b/components/index.js index 73405f7e1..cf558bf16 100644 --- a/components/index.js +++ b/components/index.js @@ -13,3 +13,7 @@ export { default as Rate } from './rate' export { default as ToolTip } from './tooltip' export { default as Pagination } from './pagination' + +export { default as Row } from './grid/row' + +export { default as Col } from './grid/col' diff --git a/components/style.js b/components/style.js index fd37c82f3..12fa2a160 100644 --- a/components/style.js +++ b/components/style.js @@ -2,3 +2,4 @@ import './button/style' import './icon/style' import './radio/style' import './checkbox/style' +import './grid/style' diff --git a/components/tooltip/demo/index.vue b/components/tooltip/demo/index.vue index a1e0451d3..178db3bff 100644 --- a/components/tooltip/demo/index.vue +++ b/components/tooltip/demo/index.vue @@ -2,19 +2,37 @@
-

This is just a test, put your cursor here

+ :title="showText" + :autoAdjustOverflow="autoAdjustOverflow" + > +

撞到边缘翻转位置 & 点击更新

- {{showText}} + {{autoAdjustOverflow ? '启用' : '关闭'}}自动调整中
+

切换arrowPointAtCenter模式

+ {{arrowPointAtCenter}}
- {{td}} + + {{td}} +
+
+

+ + arrowPointAtCenter arrowPointAtCenter arrowPointAtCenter + +

+
@@ -33,7 +51,9 @@ ['left', '', '', '', 'right'], ['leftBottom', '', '', '', 'rightBottom'], ['', 'bottomLeft', 'bottom', 'bottomRight', ''], - ] + ], + arrowPointAtCenter: false, + autoAdjustOverflow: true, } }, methods: { @@ -43,6 +63,12 @@ } else { this.showText += ' ' } + }, + change() { + this.arrowPointAtCenter = !this.arrowPointAtCenter + }, + reverse() { + this.autoAdjustOverflow = !this.autoAdjustOverflow } }, components: { @@ -52,6 +78,10 @@ }