UNPKG

tdesign-mobile-vue

Version:
48 lines (40 loc) 1.58 kB
/** * tdesign v1.7.0 * (c) 2024 TDesign Group * @license MIT */ 'use strict'; Object.defineProperty(exports, '__esModule', { value: true }); var vue = require('vue'); var intersection = require('lodash/intersection'); function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; } var intersection__default = /*#__PURE__*/_interopDefaultLegacy(intersection); var setCheckAllStatus = function setCheckAllStatus(optionList, innerValue, checkedSet) { var isArray = Array.isArray; var intersectionLen = vue.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__default["default"](innerValue.value, values).length; } return 0; }); var isAllChecked = vue.computed(function () { if (checkedSet.value.size !== optionList.value.length - 1) { return false; } return intersectionLen.value === optionList.value.length - 1; }); var indeterminate = vue.computed(function () { return !isAllChecked.value && intersectionLen.value < optionList.value.length && intersectionLen.value > 0; }); return vue.computed(function () { if (isAllChecked.value) return "checked"; if (indeterminate.value) return "indeterminate"; return "uncheck"; }); }; exports.setCheckAllStatus = setCheckAllStatus; //# sourceMappingURL=setCheckAllStatus.js.map