You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
80 lines
2.4 KiB
80 lines
2.4 KiB
"use strict";
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
var relation_1 = require("../common/relation");
|
|
var component_1 = require("../common/component");
|
|
function emit(target, value) {
|
|
target.$emit('input', value);
|
|
target.$emit('change', value);
|
|
}
|
|
(0, component_1.VantComponent)({
|
|
field: true,
|
|
relation: (0, relation_1.useParent)('checkbox-group'),
|
|
classes: ['icon-class', 'label-class'],
|
|
props: {
|
|
value: Boolean,
|
|
disabled: Boolean,
|
|
useIconSlot: Boolean,
|
|
checkedColor: String,
|
|
labelPosition: {
|
|
type: String,
|
|
value: 'right',
|
|
},
|
|
labelDisabled: Boolean,
|
|
shape: {
|
|
type: String,
|
|
value: 'round',
|
|
},
|
|
iconSize: {
|
|
type: null,
|
|
value: 20,
|
|
},
|
|
},
|
|
data: {
|
|
parentDisabled: false,
|
|
direction: 'vertical',
|
|
},
|
|
methods: {
|
|
emitChange: function (value) {
|
|
if (this.parent) {
|
|
this.setParentValue(this.parent, value);
|
|
}
|
|
else {
|
|
emit(this, value);
|
|
}
|
|
},
|
|
toggle: function () {
|
|
var _a = this.data, parentDisabled = _a.parentDisabled, disabled = _a.disabled, value = _a.value;
|
|
if (!disabled && !parentDisabled) {
|
|
this.emitChange(!value);
|
|
}
|
|
},
|
|
onClickLabel: function () {
|
|
var _a = this.data, labelDisabled = _a.labelDisabled, parentDisabled = _a.parentDisabled, disabled = _a.disabled, value = _a.value;
|
|
if (!disabled && !labelDisabled && !parentDisabled) {
|
|
this.emitChange(!value);
|
|
}
|
|
},
|
|
setParentValue: function (parent, value) {
|
|
var parentValue = parent.data.value.slice();
|
|
var name = this.data.name;
|
|
var max = parent.data.max;
|
|
if (value) {
|
|
if (max && parentValue.length >= max) {
|
|
return;
|
|
}
|
|
if (parentValue.indexOf(name) === -1) {
|
|
parentValue.push(name);
|
|
emit(parent, parentValue);
|
|
}
|
|
}
|
|
else {
|
|
var index = parentValue.indexOf(name);
|
|
if (index !== -1) {
|
|
parentValue.splice(index, 1);
|
|
emit(parent, parentValue);
|
|
}
|
|
}
|
|
},
|
|
},
|
|
});
|