UNPKG

choerodon-ui

Version:

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

36 lines (34 loc) 1.59 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 = observer(function () { var _useContext = useContext(TableContext), tableStore = _useContext.tableStore; var prefixCls = tableStore.prefixCls, dataSet = tableStore.dataSet, showCachedSelection = tableStore.showCachedSelection; var handleSwitch = useCallback(action(function () { tableStore.showCachedSelection = !showCachedSelection; }), [showCachedSelection]); var cachedButton = dataSet.cacheSelectionKeys && dataSet.cachedSelected.length > 0 ? React.createElement(Tooltip, { title: $l('Table', showCachedSelection ? 'hide_cached_seletion' : 'show_cached_seletion') }, React.createElement(Button, { className: "".concat(prefixCls, "-switch"), funcType: FuncType.flat, icon: showCachedSelection ? 'visibility_off' : 'visibility', onClick: handleSwitch })) : null; return tableStore.showSelectionTips ? React.createElement("div", { className: "".concat(prefixCls, "-selection-tips") }, React.createElement("span", null, $l('Table', 'selection_tips', { count: React.createElement("b", null, dataSet.selected.length) })), cachedButton) : cachedButton; }); SelectionTips.displayName = 'SelectionTips'; export default SelectionTips; //# sourceMappingURL=SelectionTips.js.map