UNPKG

choerodon-ui

Version:

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

56 lines (48 loc) 2.38 kB
import React, { useCallback, useContext } from 'react'; import { observer } from 'mobx-react-lite'; import { action } from 'mobx'; import { $l } from '../locale-context'; import TableContext from './TableContext'; import Tooltip from '../tooltip'; import Button from '../button/Button'; import { FuncType } from '../button/enum'; var SelectionTips = function SelectionTips() { var _useContext = useContext(TableContext), prefixCls = _useContext.prefixCls, dataSet = _useContext.dataSet, tableStore = _useContext.tableStore, showSelectionCachedButton = _useContext.showSelectionCachedButton, onShowCachedSelectionChange = _useContext.onShowCachedSelectionChange; var showCachedSelection = tableStore.showCachedSelection; var handleSwitch = useCallback(action(function () { var newShowCachedSelection = !showCachedSelection; tableStore.showCachedSelection = newShowCachedSelection; if (onShowCachedSelectionChange) { onShowCachedSelectionChange(newShowCachedSelection); } }), [showCachedSelection, onShowCachedSelectionChange]); var getTitle = function getTitle() { if (!dataSet.cacheModifiedKeys) { return $l('Table', showCachedSelection ? 'hide_cached_seletion' : 'show_cached_seletion'); } return $l('Table', showCachedSelection ? 'hide_cached_modified' : 'show_cached_modified'); }; var cachedButton = showSelectionCachedButton && (dataSet.cacheSelectionKeys || dataSet.cacheModifiedKeys) && dataSet.cachedRecords.length > 0 ? /*#__PURE__*/React.createElement(Tooltip, { title: getTitle }, /*#__PURE__*/React.createElement(Button, { className: "".concat(prefixCls, "-switch"), funcType: FuncType.flat, icon: showCachedSelection ? 'visibility_off' : 'visibility', onClick: handleSwitch })) : null; return tableStore.showSelectionTips ? /*#__PURE__*/React.createElement("div", { className: "".concat(prefixCls, "-selection-tips") }, /*#__PURE__*/React.createElement("span", null, $l('Table', 'selection_tips', { count: /*#__PURE__*/React.createElement("b", { key: "count" }, dataSet.isAllPageSelection ? dataSet.totalCount - dataSet.unSelected.length : dataSet.selected.length) })), cachedButton) : cachedButton; }; SelectionTips.displayName = 'SelectionTips'; export default observer(SelectionTips); //# sourceMappingURL=SelectionTips.js.map