UNPKG

@fe6/water-pro

Version:

An enterprise-class UI design language and Vue-based implementation

54 lines (46 loc) 1.81 kB
import { createVNode as _createVNode } from "vue"; function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); } import { __rest } from "tslib"; import { computed, defineComponent } from 'vue'; import Checkbox from '../checkbox'; import Radio from '../radio'; import { SelectionBoxProps } from './interface'; import BaseMixin from '../_util/BaseMixin'; import { getOptionProps } from '../_util/props-util'; export default defineComponent({ name: 'SelectionBox', mixins: [BaseMixin], inheritAttrs: false, props: SelectionBoxProps, setup: function setup(props) { return { checked: computed(function () { var store = props.store, defaultSelection = props.defaultSelection, rowIndex = props.rowIndex; var checked = false; if (store.selectionDirty) { checked = store.selectedRowKeys.includes(rowIndex); } else { checked = store.selectedRowKeys.includes(rowIndex) || defaultSelection.includes(rowIndex); } return checked; }) }; }, render: function render() { var _a = _extends(_extends({}, getOptionProps(this)), this.$attrs), type = _a.type, rowIndex = _a.rowIndex, rest = __rest(_a, ["type", "rowIndex"]); var checked = this.checked; var checkboxProps = _extends({ checked: checked }, rest); if (type === 'radio') { checkboxProps.value = rowIndex; return _createVNode(Radio, checkboxProps, null); } return _createVNode(Checkbox, checkboxProps, null); } });