tdesign-mobile-vue
Version:
tdesign-mobile-vue
45 lines (41 loc) • 1.52 kB
JavaScript
/**
* tdesign v1.15.0
* (c) 2026 TDesign Group
* @license MIT
*/
import { computed } from 'vue';
import { intersection } from 'lodash-es';
var setCheckAllStatus = function setCheckAllStatus(optionList, innerValue, checkedSet) {
var isArray = Array.isArray;
var validValues = computed(function () {
var _optionList$value$fil, _optionList$value;
return (_optionList$value$fil = (_optionList$value = optionList.value) === null || _optionList$value === void 0 ? void 0 : _optionList$value.filter(function (item) {
return !item.checkAll && item.value !== void 0;
}).map(function (item) {
return item.value;
})) !== null && _optionList$value$fil !== void 0 ? _optionList$value$fil : [];
});
var intersectionLen = computed(function () {
if (isArray(innerValue.value)) {
return intersection(innerValue.value, validValues.value).length;
}
return 0;
});
var isAllChecked = computed(function () {
var validLen = validValues.value.length;
if (validLen === 0) return false;
return intersectionLen.value === validLen;
});
var indeterminate = computed(function () {
var validLen = validValues.value.length;
if (validLen === 0) return false;
return !isAllChecked.value && intersectionLen.value > 0;
});
return computed(function () {
if (isAllChecked.value) return "checked";
if (indeterminate.value) return "indeterminate";
return "uncheck";
});
};
export { setCheckAllStatus };
//# sourceMappingURL=setCheckAllStatus.js.map