UNPKG

choerodon-ui

Version:

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

43 lines (40 loc) 1.98 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 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 cachedButton = showSelectionCachedButton && 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