"use strict"; var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); exports.__esModule = true; exports.CheckboxMixin = void 0; var _icon = _interopRequireDefault(require("../icon")); var _findParent = require("./find-parent"); /** * Common part of Checkbox & Radio */ var CheckboxMixin = function CheckboxMixin(parent, bem) { return { mixins: [_findParent.FindParentMixin], props: { name: null, value: null, disabled: Boolean, checkedColor: String, labelPosition: String, labelDisabled: Boolean, shape: { type: String, "default": 'round' } }, created: function created() { this.findParent(parent); }, computed: { isDisabled: function isDisabled() { return this.parent && this.parent.disabled || this.disabled; }, iconStyle: function iconStyle() { var checkedColor = this.checkedColor; if (checkedColor && this.checked && !this.isDisabled) { return { borderColor: checkedColor, backgroundColor: checkedColor }; } } }, render: function render(h) { var _this = this; var slots = this.slots, checked = this.checked; var CheckIcon = slots('icon', { checked: checked }) || h(_icon["default"], { "attrs": { "name": "success" }, "style": this.iconStyle }); var Label = slots() && h("span", { "class": bem('label', [this.labelPosition, { disabled: this.isDisabled }]), "on": { "click": this.onClickLabel } }, [slots()]); return h("div", { "class": bem(), "on": { "click": function click(event) { _this.$emit('click', event); } } }, [h("div", { "class": bem('icon', [this.shape, { disabled: this.isDisabled, checked: checked }]), "on": { "click": this.onClickIcon } }, [CheckIcon]), Label]); } }; }; exports.CheckboxMixin = CheckboxMixin;