fix: checkbox
parent
cdefb49580
commit
3d6bffb067
|
@ -1 +1 @@
|
||||||
Subproject commit bf1777054fbe55a0d3bbdd037573e3a235137fbb
|
Subproject commit be126edd50d4d5ac1c7a05eceb8d57d3c1169889
|
|
@ -51,3 +51,11 @@ v-model -> v-model:visible
|
||||||
## Steps
|
## Steps
|
||||||
|
|
||||||
v-model -> v-model:current
|
v-model -> v-model:current
|
||||||
|
|
||||||
|
## checkbox
|
||||||
|
|
||||||
|
v-model -> v-model:checked
|
||||||
|
|
||||||
|
checkboxGroup
|
||||||
|
|
||||||
|
v-model -> v-model:value
|
||||||
|
|
|
@ -2,9 +2,10 @@ import { inject } from 'vue';
|
||||||
import PropTypes from '../_util/vue-types';
|
import PropTypes from '../_util/vue-types';
|
||||||
import classNames from 'classnames';
|
import classNames from 'classnames';
|
||||||
import VcCheckbox from '../vc-checkbox';
|
import VcCheckbox from '../vc-checkbox';
|
||||||
import hasProp, { getOptionProps } from '../_util/props-util';
|
import hasProp, { getOptionProps, getSlot } from '../_util/props-util';
|
||||||
import { ConfigConsumerProps } from '../config-provider';
|
import { ConfigConsumerProps } from '../config-provider';
|
||||||
import warning from '../_util/warning';
|
import warning from '../_util/warning';
|
||||||
|
function noop() {}
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'ACheckbox',
|
name: 'ACheckbox',
|
||||||
|
@ -64,7 +65,8 @@ export default {
|
||||||
methods: {
|
methods: {
|
||||||
handleChange(event) {
|
handleChange(event) {
|
||||||
const targetChecked = event.target.checked;
|
const targetChecked = event.target.checked;
|
||||||
this.$emit('input', targetChecked);
|
this.$emit('update:checked', targetChecked);
|
||||||
|
// this.$emit('input', targetChecked);
|
||||||
this.$emit('change', event);
|
this.$emit('change', event);
|
||||||
},
|
},
|
||||||
focus() {
|
focus() {
|
||||||
|
@ -77,12 +79,19 @@ export default {
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const props = getOptionProps(this);
|
const props = getOptionProps(this);
|
||||||
const { checkboxGroupContext: checkboxGroup, $slots, $attrs } = this;
|
const { checkboxGroupContext: checkboxGroup, $attrs } = this;
|
||||||
const children = $slots.default && $slots.default();
|
const children = getSlot(this);
|
||||||
const { indeterminate, prefixCls: customizePrefixCls, ...restProps } = props;
|
const { indeterminate, prefixCls: customizePrefixCls, ...restProps } = props;
|
||||||
const getPrefixCls = this.configProvider.getPrefixCls;
|
const getPrefixCls = this.configProvider.getPrefixCls;
|
||||||
const prefixCls = getPrefixCls('checkbox', customizePrefixCls);
|
const prefixCls = getPrefixCls('checkbox', customizePrefixCls);
|
||||||
const { onMouseenter, onMouseleave, onInput, class: className, style, ...restAttrs } = $attrs;
|
const {
|
||||||
|
onMouseenter = noop,
|
||||||
|
onMouseleave = noop,
|
||||||
|
onInput,
|
||||||
|
class: className,
|
||||||
|
style,
|
||||||
|
...restAttrs
|
||||||
|
} = $attrs;
|
||||||
const checkboxProps = {
|
const checkboxProps = {
|
||||||
...restProps,
|
...restProps,
|
||||||
prefixCls,
|
prefixCls,
|
||||||
|
|
|
@ -1,15 +1,12 @@
|
||||||
import { inject, provide } from 'vue';
|
import { inject, provide } from 'vue';
|
||||||
import PropTypes from '../_util/vue-types';
|
import PropTypes from '../_util/vue-types';
|
||||||
import Checkbox from './Checkbox';
|
import Checkbox from './Checkbox';
|
||||||
import hasProp from '../_util/props-util';
|
import hasProp, { getSlot } from '../_util/props-util';
|
||||||
import { ConfigConsumerProps } from '../config-provider';
|
import { ConfigConsumerProps } from '../config-provider';
|
||||||
|
|
||||||
function noop() {}
|
function noop() {}
|
||||||
export default {
|
export default {
|
||||||
name: 'ACheckboxGroup',
|
name: 'ACheckboxGroup',
|
||||||
model: {
|
|
||||||
prop: 'value',
|
|
||||||
},
|
|
||||||
props: {
|
props: {
|
||||||
name: PropTypes.string,
|
name: PropTypes.string,
|
||||||
prefixCls: PropTypes.string,
|
prefixCls: PropTypes.string,
|
||||||
|
@ -17,6 +14,7 @@ export default {
|
||||||
value: PropTypes.array,
|
value: PropTypes.array,
|
||||||
options: PropTypes.array.def([]),
|
options: PropTypes.array.def([]),
|
||||||
disabled: PropTypes.bool,
|
disabled: PropTypes.bool,
|
||||||
|
onChange: PropTypes.func,
|
||||||
},
|
},
|
||||||
|
|
||||||
data() {
|
data() {
|
||||||
|
@ -31,8 +29,12 @@ export default {
|
||||||
this.sValue = val || [];
|
this.sValue = val || [];
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
setup() {
|
||||||
|
return {
|
||||||
|
configProvider: inject('configProvider', ConfigConsumerProps),
|
||||||
|
};
|
||||||
|
},
|
||||||
created() {
|
created() {
|
||||||
(this.configProvider = inject('configProvider', ConfigConsumerProps)),
|
|
||||||
provide('checkboxGroupContext', this);
|
provide('checkboxGroupContext', this);
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
@ -79,16 +81,17 @@ export default {
|
||||||
const indexB = options.findIndex(opt => opt.value === b);
|
const indexB = options.findIndex(opt => opt.value === b);
|
||||||
return indexA - indexB;
|
return indexA - indexB;
|
||||||
});
|
});
|
||||||
this.$emit('input', val);
|
// this.$emit('input', val);
|
||||||
|
this.$emit('update:value', val);
|
||||||
this.$emit('change', val);
|
this.$emit('change', val);
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
render() {
|
render() {
|
||||||
const { $props: props, $data: state, $slots } = this;
|
const { $props: props, $data: state } = this;
|
||||||
const { prefixCls: customizePrefixCls, options } = props;
|
const { prefixCls: customizePrefixCls, options } = props;
|
||||||
const getPrefixCls = this.configProvider.getPrefixCls;
|
const getPrefixCls = this.configProvider.getPrefixCls;
|
||||||
const prefixCls = getPrefixCls('checkbox', customizePrefixCls);
|
const prefixCls = getPrefixCls('checkbox', customizePrefixCls);
|
||||||
let children = $slots.default;
|
let children = getSlot(this);
|
||||||
const groupPrefixCls = `${prefixCls}-group`;
|
const groupPrefixCls = `${prefixCls}-group`;
|
||||||
if (options && options.length > 0) {
|
if (options && options.length > 0) {
|
||||||
children = this.getOptions().map(option => (
|
children = this.getOptions().map(option => (
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
import { inject } from 'vue';
|
import { inject } from 'vue';
|
||||||
import PropTypes from '../_util/vue-types';
|
import PropTypes from '../_util/vue-types';
|
||||||
import { ConfigConsumerProps } from '../config-provider';
|
import { ConfigConsumerProps } from '../config-provider';
|
||||||
|
import { getSlot } from '../_util/props-util';
|
||||||
|
|
||||||
const stringOrNumber = PropTypes.oneOfType([PropTypes.string, PropTypes.number]);
|
const stringOrNumber = PropTypes.oneOfType([PropTypes.string, PropTypes.number]);
|
||||||
|
|
||||||
|
@ -39,16 +40,7 @@ export default {
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
render() {
|
render() {
|
||||||
const {
|
const { span, order, offset, push, pull, prefixCls: customizePrefixCls, rowContext } = this;
|
||||||
span,
|
|
||||||
order,
|
|
||||||
offset,
|
|
||||||
push,
|
|
||||||
pull,
|
|
||||||
prefixCls: customizePrefixCls,
|
|
||||||
$slots,
|
|
||||||
rowContext,
|
|
||||||
} = this;
|
|
||||||
const getPrefixCls = this.configProvider.getPrefixCls;
|
const getPrefixCls = this.configProvider.getPrefixCls;
|
||||||
const prefixCls = getPrefixCls('col', customizePrefixCls);
|
const prefixCls = getPrefixCls('col', customizePrefixCls);
|
||||||
|
|
||||||
|
@ -104,6 +96,6 @@ export default {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return <div {...divProps}>{$slots.default && $slots.default()}</div>;
|
return <div {...divProps}>{getSlot(this)}</div>;
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
|
@ -3,6 +3,7 @@ import PropTypes from '../_util/vue-types';
|
||||||
import BaseMixin from '../_util/BaseMixin';
|
import BaseMixin from '../_util/BaseMixin';
|
||||||
import { ConfigConsumerProps } from '../config-provider';
|
import { ConfigConsumerProps } from '../config-provider';
|
||||||
import ResponsiveObserve from '../_util/responsiveObserve';
|
import ResponsiveObserve from '../_util/responsiveObserve';
|
||||||
|
import { getSlot } from '../_util/props-util';
|
||||||
|
|
||||||
const RowProps = {
|
const RowProps = {
|
||||||
gutter: PropTypes.oneOfType([PropTypes.object, PropTypes.number, PropTypes.array]),
|
gutter: PropTypes.oneOfType([PropTypes.object, PropTypes.number, PropTypes.array]),
|
||||||
|
@ -79,7 +80,7 @@ export default {
|
||||||
},
|
},
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const { type, justify, align, prefixCls: customizePrefixCls, $slots } = this;
|
const { type, justify, align, prefixCls: customizePrefixCls } = this;
|
||||||
const getPrefixCls = this.configProvider.getPrefixCls;
|
const getPrefixCls = this.configProvider.getPrefixCls;
|
||||||
const prefixCls = getPrefixCls('row', customizePrefixCls);
|
const prefixCls = getPrefixCls('row', customizePrefixCls);
|
||||||
|
|
||||||
|
@ -106,7 +107,7 @@ export default {
|
||||||
};
|
};
|
||||||
return (
|
return (
|
||||||
<div class={classes} style={rowStyle}>
|
<div class={classes} style={rowStyle}>
|
||||||
{$slots.default && $slots.default()}
|
{getSlot(this)}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
|
|
@ -45,6 +45,4 @@ const Number = (_, { attrs }) => {
|
||||||
|
|
||||||
return <span class={`${prefixCls}-content-value`}>{valueNode}</span>;
|
return <span class={`${prefixCls}-content-value`}>{valueNode}</span>;
|
||||||
};
|
};
|
||||||
|
|
||||||
Number.name = 'AStatisticNumber';
|
|
||||||
export default Number;
|
export default Number;
|
||||||
|
|
Loading…
Reference in New Issue