UNPKG

tdesign-mobile-vue

Version:
40 lines (36 loc) 1.26 kB
/** * tdesign v1.7.0 * (c) 2024 TDesign Group * @license MIT */ import { computed } from 'vue'; import intersection from 'lodash/intersection'; var setCheckAllStatus = function setCheckAllStatus(optionList, innerValue, checkedSet) { var isArray = Array.isArray; var intersectionLen = computed(function () { var _optionList$value; var values = (_optionList$value = optionList.value) === null || _optionList$value === void 0 ? void 0 : _optionList$value.map(function (item) { return item.value; }); if (isArray(innerValue.value)) { return intersection(innerValue.value, values).length; } return 0; }); var isAllChecked = computed(function () { if (checkedSet.value.size !== optionList.value.length - 1) { return false; } return intersectionLen.value === optionList.value.length - 1; }); var indeterminate = computed(function () { return !isAllChecked.value && intersectionLen.value < optionList.value.length && intersectionLen.value > 0; }); return computed(function () { if (isAllChecked.value) return "checked"; if (indeterminate.value) return "indeterminate"; return "uncheck"; }); }; export { setCheckAllStatus }; //# sourceMappingURL=setCheckAllStatus.js.map