zent
Version:
一套前端设计语言和基于React的实现
20 lines (19 loc) • 1.36 kB
JavaScript
import { __assign } from "tslib";
import { jsx as _jsx } from "react/jsx-runtime";
import { useCallback } from 'react';
import Checkbox from '../../checkbox';
var AllCheckBox = function (_a) {
var classNamePrefix = _a.classNamePrefix, isAllChecked = _a.isAllChecked, handleCheckBoxChange = _a.handleCheckBoxChange, compontentDisabled = _a.compontentDisabled, i18n = _a.i18n, selectedKeysLength = _a.selectedKeysLength, listDataLength = _a.listDataLength, title = _a.title;
var getTitle = useCallback(function (_a) {
var item = _a.item, items = _a.items;
var totalText = listDataLength + " " + (listDataLength > 1 ? items : item);
if (selectedKeysLength > 0) {
return title
? title + "\uFF08" + selectedKeysLength + "/" + totalText + "\uFF09"
: selectedKeysLength + "/" + totalText;
}
return title ? title + "\uFF08" + totalText + "\uFF09" : totalText;
}, [title, listDataLength, selectedKeysLength]);
return (_jsx("div", __assign({ className: classNamePrefix + "__allCheckbox", "data-zv": '10.0.17' }, { children: _jsx(Checkbox, __assign({ checked: isAllChecked, indeterminate: selectedKeysLength && !isAllChecked, onChange: handleCheckBoxChange, disabled: compontentDisabled }, { children: getTitle(i18n) }), void 0) }), void 0));
};
export default AllCheckBox;