@arcblock/ux 3.4.15 → 3.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/package.json.js +1 -1
- package/package.json +10 -7
- package/src/ActionButton/ActionButton.stories.jsx +0 -61
- package/src/ActionButton/index.jsx +0 -106
- package/src/ActivityIndicator/ActivityIndicator.stories.jsx +0 -9
- package/src/ActivityIndicator/index.jsx +0 -140
- package/src/Address/Address.stories.jsx +0 -38
- package/src/Address/compact-text.jsx +0 -76
- package/src/Address/did-address.tsx +0 -223
- package/src/Address/index.tsx +0 -21
- package/src/Address/responsive-did-address.tsx +0 -154
- package/src/Alert/Alert.stories.jsx +0 -100
- package/src/Alert/index.jsx +0 -130
- package/src/AnimationWaiter/AnimationWaiter.stories.jsx +0 -35
- package/src/AnimationWaiter/dark-animation.json +0 -1
- package/src/AnimationWaiter/default-animation.json +0 -1
- package/src/AnimationWaiter/index.jsx +0 -296
- package/src/Async/index.tsx +0 -44
- package/src/Avatar/Avatar.stories.jsx +0 -11
- package/src/Avatar/did-motif.jsx +0 -38
- package/src/Avatar/etherscan-blockies.js +0 -81
- package/src/Avatar/index.jsx +0 -195
- package/src/Badge/Badge.stories.jsx +0 -41
- package/src/Badge/index.jsx +0 -101
- package/src/Blocklet/Blocklet.stories.jsx +0 -21
- package/src/Blocklet/blocklet.jsx +0 -276
- package/src/Blocklet/index.js +0 -5
- package/src/Blocklet/utils.jsx +0 -58
- package/src/BlockletContext/index.tsx +0 -72
- package/src/BlockletNFT/BlockletNFT.stories.jsx +0 -21
- package/src/BlockletNFT/index.jsx +0 -378
- package/src/BlockletV2/Blocklet.stories.jsx +0 -34
- package/src/BlockletV2/blocklet.tsx +0 -247
- package/src/BlockletV2/components/icon-text.tsx +0 -47
- package/src/BlockletV2/components/tooltip-icon.tsx +0 -52
- package/src/BlockletV2/index.ts +0 -6
- package/src/BlockletV2/utils.js +0 -75
- package/src/Button/Button.stories.jsx +0 -24
- package/src/Button/index.js +0 -9
- package/src/Button/wrap.jsx +0 -126
- package/src/ButtonGroup/index.js +0 -16
- package/src/CardSelector/index.tsx +0 -136
- package/src/Center/Center.stories.jsx +0 -20
- package/src/Center/index.tsx +0 -33
- package/src/ClickToCopy/ClickToCopy.stories.jsx +0 -24
- package/src/ClickToCopy/copy-button.tsx +0 -43
- package/src/ClickToCopy/hook.ts +0 -42
- package/src/ClickToCopy/index.tsx +0 -96
- package/src/CloseButton/index.tsx +0 -37
- package/src/CodeBlock/CodeBlock.stories.jsx +0 -22
- package/src/CodeBlock/LightBox.tsx +0 -87
- package/src/CodeBlock/index.tsx +0 -217
- package/src/Colors/Colors.stories.jsx +0 -211
- package/src/Colors/index.ts +0 -4
- package/src/Colors/themes/default.ts +0 -8
- package/src/Colors/themes/did-connect.ts +0 -64
- package/src/Colors/themes/temp.ts +0 -52
- package/src/Config/Config.stories.jsx +0 -16
- package/src/Config/config-provider.tsx +0 -62
- package/src/Config/index.ts +0 -2
- package/src/Config/theme-mode-toggle.tsx +0 -38
- package/src/ContactForm/ContactForm.stories.jsx +0 -32
- package/src/ContactForm/index.tsx +0 -264
- package/src/CookieConsent/CookieConsent.stories.jsx +0 -33
- package/src/CookieConsent/index.tsx +0 -104
- package/src/CountDown/CountDown.stories.jsx +0 -15
- package/src/CountDown/index.tsx +0 -170
- package/src/DID/DID.stories.jsx +0 -37
- package/src/DID/index.tsx +0 -393
- package/src/DIDConnect/app-icon.tsx +0 -37
- package/src/DIDConnect/app-info-item.tsx +0 -93
- package/src/DIDConnect/auth-apps/auth-apps-info.tsx +0 -77
- package/src/DIDConnect/auth-apps/index.tsx +0 -278
- package/src/DIDConnect/auth-apps/switch-role.tsx +0 -47
- package/src/DIDConnect/did-connect-container.tsx +0 -326
- package/src/DIDConnect/did-connect-footer.tsx +0 -76
- package/src/DIDConnect/did-connect-logo.tsx +0 -8
- package/src/DIDConnect/icons/did-wallet-logo.tsx +0 -18
- package/src/DIDConnect/icons/github-logo.tsx +0 -17
- package/src/DIDConnect/index.ts +0 -11
- package/src/DIDConnect/landing-page.tsx +0 -218
- package/src/DIDConnect/powered-by.tsx +0 -48
- package/src/DIDConnect/provider-icon.tsx +0 -62
- package/src/DIDConnect/request-storage-access-api-dialog.tsx +0 -304
- package/src/DIDConnect/with-container.tsx +0 -323
- package/src/DIDConnect/with-ux-theme.tsx +0 -22
- package/src/DIDLogo/Logo.stories.jsx +0 -11
- package/src/DIDLogo/index.tsx +0 -168
- package/src/Datatable/CustomToolbar.jsx +0 -415
- package/src/Datatable/Datatable.stories.jsx +0 -92
- package/src/Datatable/DatatableContext.jsx +0 -35
- package/src/Datatable/TableSearch.jsx +0 -166
- package/src/Datatable/index.jsx +0 -652
- package/src/Datatable/utils.js +0 -161
- package/src/Dialog/Dialog.stories.jsx +0 -21
- package/src/Dialog/confirm.jsx +0 -143
- package/src/Dialog/dialog.jsx +0 -199
- package/src/Dialog/index.js +0 -4
- package/src/Dialog/types.d.ts +0 -20
- package/src/Dialog/use-confirm.jsx +0 -188
- package/src/DriftBot/index.tsx +0 -81
- package/src/Earth/Earth.stories.jsx +0 -39
- package/src/Earth/countries.json +0 -8057
- package/src/Earth/index.tsx +0 -515
- package/src/Earth/util.ts +0 -72
- package/src/Empty/Empty.stories.jsx +0 -23
- package/src/Empty/index.jsx +0 -48
- package/src/ErrorBoundary/ErrorBoundary.stories.jsx +0 -13
- package/src/ErrorBoundary/fallback.tsx +0 -85
- package/src/ErrorBoundary/index.ts +0 -1
- package/src/Footer/Footer.stories.jsx +0 -13
- package/src/Footer/index.tsx +0 -130
- package/src/Header/Header.stories.jsx +0 -30
- package/src/Header/addon-button.tsx +0 -41
- package/src/Header/auto-hidden.tsx +0 -31
- package/src/Header/header-addons.tsx +0 -37
- package/src/Header/header.tsx +0 -214
- package/src/Header/index.ts +0 -3
- package/src/Header/responsive-header.tsx +0 -145
- package/src/Icon/Icon.stories.jsx +0 -45
- package/src/Icon/image.tsx +0 -53
- package/src/Icon/index.tsx +0 -63
- package/src/Img/Img.stories.jsx +0 -17
- package/src/Img/index.jsx +0 -258
- package/src/InfoRow/InfoRow.stories.jsx +0 -14
- package/src/InfoRow/index.tsx +0 -91
- package/src/Layout/Layout.stories.jsx +0 -24
- package/src/Layout/dashboard/external-link.tsx +0 -59
- package/src/Layout/dashboard/full-page.tsx +0 -58
- package/src/Layout/dashboard/index.tsx +0 -260
- package/src/Layout/dashboard/sidebar.tsx +0 -198
- package/src/Layout/dashboard-legacy/header.tsx +0 -156
- package/src/Layout/dashboard-legacy/index.tsx +0 -127
- package/src/Layout/dashboard-legacy/sidebar.tsx +0 -129
- package/src/Layout/index.tsx +0 -310
- package/src/LoadingMask/index.tsx +0 -108
- package/src/Locale/LocaleSelector.stories.jsx +0 -44
- package/src/Locale/browser-lang.ts +0 -65
- package/src/Locale/context.tsx +0 -162
- package/src/Locale/languages.ts +0 -58
- package/src/Locale/selector.tsx +0 -174
- package/src/Locale/util.ts +0 -38
- package/src/Logo/Logo.stories.jsx +0 -23
- package/src/Logo/images/logo-dark-text.svg +0 -3
- package/src/Logo/images/logo-dark-top.svg +0 -6
- package/src/Logo/images/logo-light-text.svg +0 -3
- package/src/Logo/images/logo-light-top.svg +0 -6
- package/src/Logo/index.tsx +0 -58
- package/src/Metric/Metric.stories.jsx +0 -29
- package/src/Metric/index.tsx +0 -130
- package/src/MuiWrap/index.tsx +0 -10
- package/src/NFTDisplay/NFTBroken.svg +0 -34
- package/src/NFTDisplay/NFTDisplay.stories.jsx +0 -30
- package/src/NFTDisplay/README.md +0 -59
- package/src/NFTDisplay/aspect-ratio-container.tsx +0 -36
- package/src/NFTDisplay/broken.tsx +0 -51
- package/src/NFTDisplay/displayApi.ts +0 -43
- package/src/NFTDisplay/index.tsx +0 -393
- package/src/NFTDisplay/loading.tsx +0 -16
- package/src/NFTDisplay/preview.tsx +0 -84
- package/src/NFTDisplay/render-svg.tsx +0 -21
- package/src/NFTDisplay/svg-embedder/img.tsx +0 -27
- package/src/NFTDisplay/svg-embedder/inline-svg.tsx +0 -36
- package/src/NavMenu/NavMenu.stories.jsx +0 -17
- package/src/NavMenu/images/OCAP.svg +0 -1
- package/src/NavMenu/images/abt-network.svg +0 -1
- package/src/NavMenu/images/ai-kit.svg +0 -1
- package/src/NavMenu/images/aigne-image-smith.svg +0 -1
- package/src/NavMenu/images/aigne.svg +0 -1
- package/src/NavMenu/images/aistro.png +0 -0
- package/src/NavMenu/images/arcsphere.svg +0 -1
- package/src/NavMenu/images/blocklet-framework.svg +0 -1
- package/src/NavMenu/images/blocklet-launcher.svg +0 -1
- package/src/NavMenu/images/blocklet-server.svg +0 -1
- package/src/NavMenu/images/blocklet-store.svg +0 -1
- package/src/NavMenu/images/creator-studio.svg +0 -1
- package/src/NavMenu/images/did-wallet.svg +0 -1
- package/src/NavMenu/images/did.svg +0 -1
- package/src/NavMenu/images/nft-studio.svg +0 -1
- package/src/NavMenu/images/payment-kit.png +0 -0
- package/src/NavMenu/images/vc.svg +0 -1
- package/src/NavMenu/images/web3-kit.svg +0 -1
- package/src/NavMenu/index.ts +0 -3
- package/src/NavMenu/nav-menu-context.tsx +0 -30
- package/src/NavMenu/nav-menu.tsx +0 -441
- package/src/NavMenu/products.tsx +0 -830
- package/src/NavMenu/style.ts +0 -258
- package/src/NavMenu/sub-container.tsx +0 -125
- package/src/NavMenu/sub-item-group.tsx +0 -42
- package/src/OrgTransfer/index.tsx +0 -53
- package/src/OrgTransfer/locales.ts +0 -25
- package/src/OrgTransfer/selector.tsx +0 -252
- package/src/OrgTransfer/type.ts +0 -31
- package/src/PageScroller/index.tsx +0 -316
- package/src/PageScroller/story/FifthComponent.jsx +0 -7
- package/src/PageScroller/story/FirstComponent.jsx +0 -7
- package/src/PageScroller/story/FourthComponent.jsx +0 -7
- package/src/PageScroller/story/FullPage.jsx +0 -55
- package/src/PageScroller/story/PageContain.jsx +0 -59
- package/src/PageScroller/story/PageScroller.stories.jsx +0 -18
- package/src/PageScroller/story/SecondComponent.jsx +0 -7
- package/src/PageScroller/story/ThirdComponent.jsx +0 -7
- package/src/PageScroller/story/index.css +0 -115
- package/src/PageScroller/usePrevValue.ts +0 -11
- package/src/Passport/index.ts +0 -3
- package/src/Passport/passport.tsx +0 -118
- package/src/PhoneInput/PhoneInput.stories.jsx +0 -12
- package/src/PhoneInput/country-select.tsx +0 -148
- package/src/PhoneInput/index.tsx +0 -269
- package/src/PoweredByArcBlock/index.tsx +0 -27
- package/src/PricingTable/PricingPlan.tsx +0 -120
- package/src/PricingTable/PricingTable.stories.jsx +0 -38
- package/src/PricingTable/index.tsx +0 -59
- package/src/QRCode/QRCode.stories.jsx +0 -13
- package/src/QRCode/index.tsx +0 -66
- package/src/RelativeTime/RelativeTime.stories.jsx +0 -20
- package/src/RelativeTime/index.tsx +0 -334
- package/src/Result/Result.stories.jsx +0 -61
- package/src/Result/common.tsx +0 -119
- package/src/Result/index.tsx +0 -30
- package/src/Result/result.tsx +0 -65
- package/src/Result/translations.ts +0 -57
- package/src/Screenshot/BaseScreenshot/index.tsx +0 -73
- package/src/Screenshot/BaseScreenshot/shells/Macbook.tsx +0 -38
- package/src/Screenshot/BaseScreenshot/shells/Phone.tsx +0 -35
- package/src/Screenshot/Screenshot.stories.jsx +0 -44
- package/src/Screenshot/devices.css +0 -1366
- package/src/Screenshot/index.tsx +0 -300
- package/src/SessionBlocklet/index.tsx +0 -178
- package/src/SessionManager/SessionManager.stories.jsx +0 -9
- package/src/SessionManager/index.tsx +0 -3
- package/src/SessionPermission/index.tsx +0 -26
- package/src/SessionUser/components/did-space.tsx +0 -68
- package/src/SessionUser/components/logged-in.tsx +0 -338
- package/src/SessionUser/components/quick-login-item.tsx +0 -132
- package/src/SessionUser/components/session-user-item.tsx +0 -93
- package/src/SessionUser/components/session-user-switch.tsx +0 -240
- package/src/SessionUser/components/un-login.tsx +0 -257
- package/src/SessionUser/components/user-info.tsx +0 -201
- package/src/SessionUser/index.tsx +0 -68
- package/src/SessionUser/libs/translation.ts +0 -30
- package/src/SessionUser/libs/utils.ts +0 -39
- package/src/SharedBridge/index.tsx +0 -126
- package/src/SocialShare/index.tsx +0 -194
- package/src/Sparkline/Sparkline.stories.jsx +0 -13
- package/src/Sparkline/index.tsx +0 -231
- package/src/Spinner/Spinner.stories.jsx +0 -98
- package/src/Spinner/index.tsx +0 -20
- package/src/SplitButton/SplitButton.stories.jsx +0 -32
- package/src/SplitButton/index.tsx +0 -116
- package/src/SplitButton/useClickAway.tsx +0 -24
- package/src/Success/index.tsx +0 -175
- package/src/Switch/Switch.stories.jsx +0 -16
- package/src/Switch/index.jsx +0 -79
- package/src/Tabs/Tabs.stories.jsx +0 -18
- package/src/Tabs/index.tsx +0 -255
- package/src/Tag/Tag.stories.jsx +0 -15
- package/src/Tag/index.jsx +0 -106
- package/src/TextCollapse/TextCollapse.stories.jsx +0 -73
- package/src/TextCollapse/index.tsx +0 -85
- package/src/Theme/Theme.stories.jsx +0 -11
- package/src/Theme/index.ts +0 -21
- package/src/Theme/theme-provider.tsx +0 -374
- package/src/Theme/theme.ts +0 -229
- package/src/Toast/Toast.stories.jsx +0 -28
- package/src/Toast/index.tsx +0 -80
- package/src/Typography/index.tsx +0 -124
- package/src/UserCard/Cards/avatar-only.tsx +0 -27
- package/src/UserCard/Cards/basic-info.tsx +0 -43
- package/src/UserCard/Cards/index.tsx +0 -16
- package/src/UserCard/Cards/social-actions.tsx +0 -196
- package/src/UserCard/Container/card.tsx +0 -63
- package/src/UserCard/Container/dialog.tsx +0 -37
- package/src/UserCard/Content/basic.tsx +0 -330
- package/src/UserCard/Content/clock.tsx +0 -82
- package/src/UserCard/Content/minimal.tsx +0 -113
- package/src/UserCard/Content/shorten-label.tsx +0 -32
- package/src/UserCard/Content/tooltip-avatar.tsx +0 -80
- package/src/UserCard/UserCard.stories.jsx +0 -19
- package/src/UserCard/components.tsx +0 -81
- package/src/UserCard/index.tsx +0 -132
- package/src/UserCard/types.ts +0 -165
- package/src/UserCard/use-follow.tsx +0 -111
- package/src/UserCard/utils.ts +0 -155
- package/src/Util/WebWalletOpener.stories.jsx +0 -5
- package/src/Util/client.ts +0 -4
- package/src/Util/constant.ts +0 -70
- package/src/Util/deprecate.tsx +0 -29
- package/src/Util/federated.ts +0 -125
- package/src/Util/iframe.ts +0 -19
- package/src/Util/index.ts +0 -760
- package/src/Util/logger.ts +0 -44
- package/src/Util/passport.ts +0 -127
- package/src/Util/security.ts +0 -72
- package/src/Util/style.ts +0 -17
- package/src/Util/wallet.ts +0 -35
- package/src/VerificationCode/index.tsx +0 -83
- package/src/Video/Video.stories.jsx +0 -6
- package/src/Video/index.tsx +0 -70
- package/src/Wallet/Action.stories.jsx +0 -8
- package/src/Wallet/Action.tsx +0 -118
- package/src/Wallet/Download.stories.jsx +0 -9
- package/src/Wallet/Download.tsx +0 -157
- package/src/Wallet/Open.tsx +0 -47
- package/src/Wallet/OpenInWallet.stories.jsx +0 -5
- package/src/Wallet/images/abtwallet.png +0 -0
- package/src/Wallet/images/android_download.svg +0 -22
- package/src/Wallet/images/app-store.svg +0 -30
- package/src/Wallet/images/google-play.svg +0 -69
- package/src/WalletOSIcon/index.tsx +0 -47
- package/src/WebWalletSWKeeper/index.tsx +0 -117
- package/src/WechatPrompt/images/android.png +0 -0
- package/src/WechatPrompt/images/ios.png +0 -0
- package/src/WechatPrompt/index.tsx +0 -75
- package/src/global.d.ts +0 -28
- package/src/hooks/use-blocklet-logo.tsx +0 -32
- package/src/hooks/use-clock.tsx +0 -62
- package/src/hooks/use-location-state.tsx +0 -117
- package/src/hooks/use-mobile.tsx +0 -6
- package/src/index.ts +0 -79
- package/src/type.d.ts +0 -44
- package/src/withTheme/index.tsx +0 -72
- package/src/withTracker/README.md +0 -37
- package/src/withTracker/action/bind-wallet.tsx +0 -17
- package/src/withTracker/action/login.tsx +0 -18
- package/src/withTracker/action/pay.tsx +0 -14
- package/src/withTracker/action/switch-passport.tsx +0 -20
- package/src/withTracker/constant/index.tsx +0 -3
- package/src/withTracker/env.tsx +0 -1
- package/src/withTracker/error_boundary.jsx +0 -34
- package/src/withTracker/index.tsx +0 -50
- package/src/withTracker/libs/utm.ts +0 -46
- package/vite.config.mjs +0 -37
|
@@ -1,415 +0,0 @@
|
|
|
1
|
-
import { useState, useRef, isValidElement } from 'react';
|
|
2
|
-
import PropTypes from 'prop-types';
|
|
3
|
-
import { TableFilter, TableViewCol } from 'mui-datatables';
|
|
4
|
-
import ReactToPrint, { PrintContextConsumer } from 'react-to-print';
|
|
5
|
-
import {
|
|
6
|
-
CloudDownload as DownloadIcon,
|
|
7
|
-
Print as PrintIcon,
|
|
8
|
-
ViewColumn as ViewColumnIcon,
|
|
9
|
-
FilterList as FilterIcon,
|
|
10
|
-
MoreVert as MoreVertIcon,
|
|
11
|
-
} from '@mui/icons-material';
|
|
12
|
-
import {
|
|
13
|
-
ListItemText,
|
|
14
|
-
useMediaQuery,
|
|
15
|
-
LinearProgress,
|
|
16
|
-
ListItemIcon,
|
|
17
|
-
Popover,
|
|
18
|
-
Menu,
|
|
19
|
-
MenuItem,
|
|
20
|
-
Tooltip,
|
|
21
|
-
IconButton,
|
|
22
|
-
} from '@mui/material';
|
|
23
|
-
import { useDeepCompareEffect } from 'ahooks';
|
|
24
|
-
|
|
25
|
-
import { handleCSVDownload } from './utils';
|
|
26
|
-
import TableSearch from './TableSearch';
|
|
27
|
-
import { useDatatableContext } from './DatatableContext';
|
|
28
|
-
import { styled, useTheme } from '../Theme';
|
|
29
|
-
|
|
30
|
-
function useMobile() {
|
|
31
|
-
const theme = useTheme();
|
|
32
|
-
return useMediaQuery(theme.breakpoints.down('sm'));
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
export default function CustomToolbar({ ...props }) {
|
|
36
|
-
const [menuIconEl, setMenuIconEl] = useState(null);
|
|
37
|
-
const moreBtn = useRef(null);
|
|
38
|
-
const isMobile = useMobile();
|
|
39
|
-
const toolbarId = useRef(Math.random().toString(32).slice(2));
|
|
40
|
-
const [searchOpened, setSearchOpened] = useState(false);
|
|
41
|
-
const { customPreButtons, customButtons, loading, disabled } = useDatatableContext();
|
|
42
|
-
|
|
43
|
-
const {
|
|
44
|
-
data = [],
|
|
45
|
-
options,
|
|
46
|
-
components = {},
|
|
47
|
-
columns,
|
|
48
|
-
filterList = [],
|
|
49
|
-
filterData = [],
|
|
50
|
-
filterUpdate,
|
|
51
|
-
resetFilters,
|
|
52
|
-
updateFilterByType,
|
|
53
|
-
toggleViewColumn,
|
|
54
|
-
updateColumns,
|
|
55
|
-
title = '',
|
|
56
|
-
searchText = null,
|
|
57
|
-
searchTextUpdate,
|
|
58
|
-
searchClose,
|
|
59
|
-
} = props;
|
|
60
|
-
|
|
61
|
-
const [allPopsEl, setAllPopsEl] = useState({});
|
|
62
|
-
|
|
63
|
-
const customToolbarEle = options.customToolbar ? options.customToolbar(props) : '';
|
|
64
|
-
|
|
65
|
-
const { search, downloadCsv, print, viewColumns, filterTable } = options.textLabels.toolbar;
|
|
66
|
-
|
|
67
|
-
const hideSearch = options.search === false || options.search === 'false';
|
|
68
|
-
const hidePrint = options.print === false || options.print === 'false';
|
|
69
|
-
|
|
70
|
-
const TableFilterComponent = components.TableFilter || TableFilter;
|
|
71
|
-
const TableViewColComponent = components.TableViewCol || TableViewCol;
|
|
72
|
-
|
|
73
|
-
useDeepCompareEffect(() => {
|
|
74
|
-
if (loading || disabled) {
|
|
75
|
-
setAllPopsEl({});
|
|
76
|
-
}
|
|
77
|
-
}, [loading, disabled]);
|
|
78
|
-
|
|
79
|
-
const printArea = (func) => {
|
|
80
|
-
return (
|
|
81
|
-
<ReactToPrint content={() => props.tableRef()}>
|
|
82
|
-
<PrintContextConsumer>{func}</PrintContextConsumer>
|
|
83
|
-
</ReactToPrint>
|
|
84
|
-
);
|
|
85
|
-
};
|
|
86
|
-
|
|
87
|
-
const getPopId = (key) => `toolbar-pop-${toolbarId.current}-${key}`;
|
|
88
|
-
|
|
89
|
-
const defaultButtons = [];
|
|
90
|
-
|
|
91
|
-
// download/viewColumns/filter button behaviours, rendered using custom button logic
|
|
92
|
-
if (!(options.download === false || options.download === 'false')) {
|
|
93
|
-
defaultButtons.push({
|
|
94
|
-
icon: <DownloadIcon />,
|
|
95
|
-
title: downloadCsv,
|
|
96
|
-
onClick: () => {
|
|
97
|
-
handleCSVDownload(props);
|
|
98
|
-
},
|
|
99
|
-
});
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
if (!(options.viewColumns === false || options.viewColumns === 'false')) {
|
|
103
|
-
defaultButtons.push({
|
|
104
|
-
icon: <ViewColumnIcon />,
|
|
105
|
-
title: viewColumns,
|
|
106
|
-
// eslint-disable-next-line react/no-unstable-nested-components
|
|
107
|
-
popRender() {
|
|
108
|
-
return (
|
|
109
|
-
<TableViewColComponent
|
|
110
|
-
data={data}
|
|
111
|
-
columns={columns}
|
|
112
|
-
options={options}
|
|
113
|
-
onColumnUpdate={toggleViewColumn}
|
|
114
|
-
updateColumns={updateColumns}
|
|
115
|
-
components={components}
|
|
116
|
-
/>
|
|
117
|
-
);
|
|
118
|
-
},
|
|
119
|
-
});
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
if (!(options.filter === false || options.filter === 'false')) {
|
|
123
|
-
defaultButtons.push({
|
|
124
|
-
icon: <FilterIcon />,
|
|
125
|
-
title: filterTable,
|
|
126
|
-
// eslint-disable-next-line react/no-unstable-nested-components
|
|
127
|
-
popRender() {
|
|
128
|
-
return (
|
|
129
|
-
<TableFilterComponent
|
|
130
|
-
customFooter={options.customFilterDialogFooter}
|
|
131
|
-
columns={columns}
|
|
132
|
-
options={options}
|
|
133
|
-
filterList={filterList}
|
|
134
|
-
filterData={filterData}
|
|
135
|
-
onFilterUpdate={filterUpdate}
|
|
136
|
-
onFilterReset={resetFilters}
|
|
137
|
-
updateFilterByType={updateFilterByType}
|
|
138
|
-
components={components}
|
|
139
|
-
/>
|
|
140
|
-
);
|
|
141
|
-
},
|
|
142
|
-
});
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
const showMore =
|
|
146
|
-
[...customPreButtons, !hidePrint, ...defaultButtons, ...customButtons].filter((e) => !!e).length > 1 && isMobile;
|
|
147
|
-
|
|
148
|
-
const allPops = [];
|
|
149
|
-
|
|
150
|
-
// Large screens show the toolbar buttons directly, small screens show the drop-down menu style buttons
|
|
151
|
-
// The right-hand button of the form toolbar in desktop mode
|
|
152
|
-
const toolbarButtons = [...customPreButtons, ...defaultButtons, ...customButtons].map((e, index) => {
|
|
153
|
-
if (isValidElement(e)) {
|
|
154
|
-
return e;
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
const popId = getPopId(index);
|
|
158
|
-
|
|
159
|
-
if (e.icon) {
|
|
160
|
-
const { popRender, icon } = e;
|
|
161
|
-
// When popRender is present, clicking the button will bubble up the content returned by the popRender
|
|
162
|
-
if (popRender) {
|
|
163
|
-
allPops.push(
|
|
164
|
-
<Popover
|
|
165
|
-
open={!!allPopsEl[popId]}
|
|
166
|
-
anchorEl={() => allPopsEl[popId]}
|
|
167
|
-
onClose={() => {
|
|
168
|
-
setAllPopsEl({});
|
|
169
|
-
}}
|
|
170
|
-
key={popId}
|
|
171
|
-
anchorOrigin={{
|
|
172
|
-
vertical: 'bottom',
|
|
173
|
-
horizontal: 'right',
|
|
174
|
-
}}>
|
|
175
|
-
<div>{popRender()}</div>
|
|
176
|
-
</Popover>
|
|
177
|
-
);
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
return (
|
|
181
|
-
<Tooltip title={e.title} key={popId}>
|
|
182
|
-
<IconButton
|
|
183
|
-
data-testid={`${e.title}-iconButton`}
|
|
184
|
-
id={`btn-${popId}`}
|
|
185
|
-
aria-label={e.title}
|
|
186
|
-
onClick={() => {
|
|
187
|
-
if (e.onClick) {
|
|
188
|
-
e.onClick();
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
if (popRender) {
|
|
192
|
-
// On the large screen, the bubble is positioned at the corresponding button
|
|
193
|
-
setAllPopsEl({
|
|
194
|
-
[popId]: document.getElementById(`btn-${popId}`),
|
|
195
|
-
});
|
|
196
|
-
}
|
|
197
|
-
}}>
|
|
198
|
-
<div className="custom-toolbar-icon">{icon}</div>
|
|
199
|
-
</IconButton>
|
|
200
|
-
</Tooltip>
|
|
201
|
-
);
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
return e;
|
|
205
|
-
});
|
|
206
|
-
|
|
207
|
-
// The toolbar menu in the mobile to replace toolbarButtons
|
|
208
|
-
const menuItems = [...customPreButtons, ...defaultButtons, ...customButtons].map((e, index) => {
|
|
209
|
-
const popId = getPopId(index);
|
|
210
|
-
|
|
211
|
-
let content;
|
|
212
|
-
|
|
213
|
-
if (isValidElement(e)) {
|
|
214
|
-
content = e;
|
|
215
|
-
} else if (e.icon) {
|
|
216
|
-
const { icon } = e;
|
|
217
|
-
|
|
218
|
-
content = (
|
|
219
|
-
<>
|
|
220
|
-
<ListItemIcon>{icon}</ListItemIcon>
|
|
221
|
-
<ListItemText>{e.title}</ListItemText>
|
|
222
|
-
</>
|
|
223
|
-
);
|
|
224
|
-
}
|
|
225
|
-
|
|
226
|
-
return (
|
|
227
|
-
<MenuItem
|
|
228
|
-
key={popId}
|
|
229
|
-
onClick={() => {
|
|
230
|
-
setMenuIconEl(null);
|
|
231
|
-
if (e.onClick) {
|
|
232
|
-
e.onClick();
|
|
233
|
-
}
|
|
234
|
-
|
|
235
|
-
if (e.popRender) {
|
|
236
|
-
// On the small screen, the bubbles are positioned at the three dot buttons
|
|
237
|
-
setAllPopsEl({
|
|
238
|
-
[popId]: moreBtn.current,
|
|
239
|
-
});
|
|
240
|
-
}
|
|
241
|
-
}}>
|
|
242
|
-
{content}
|
|
243
|
-
</MenuItem>
|
|
244
|
-
);
|
|
245
|
-
});
|
|
246
|
-
|
|
247
|
-
return (
|
|
248
|
-
<div>
|
|
249
|
-
<Container>
|
|
250
|
-
<div
|
|
251
|
-
className={`custom-toobar-title ${
|
|
252
|
-
isMobile && searchOpened && isValidElement(title) ? 'toobar-title-hidden' : ''
|
|
253
|
-
}`}>
|
|
254
|
-
<div className="custom-toobar-title-inner">
|
|
255
|
-
<span>{title}</span>
|
|
256
|
-
</div>
|
|
257
|
-
</div>
|
|
258
|
-
<div className={`custom-toobar-btns ${loading || disabled ? 'toobar-btns-disabled' : ''}`}>
|
|
259
|
-
{!hideSearch && (
|
|
260
|
-
<TableSearch
|
|
261
|
-
search={search}
|
|
262
|
-
options={options}
|
|
263
|
-
searchText={searchText}
|
|
264
|
-
searchTextUpdate={searchTextUpdate}
|
|
265
|
-
searchClose={searchClose}
|
|
266
|
-
onSearchOpen={setSearchOpened}
|
|
267
|
-
/>
|
|
268
|
-
)}
|
|
269
|
-
{!showMore && (
|
|
270
|
-
<>
|
|
271
|
-
{!hidePrint &&
|
|
272
|
-
printArea(({ handlePrint }) => (
|
|
273
|
-
<span>
|
|
274
|
-
<Tooltip title={print}>
|
|
275
|
-
<IconButton
|
|
276
|
-
data-testid={`${print}-iconButton`}
|
|
277
|
-
aria-label={print}
|
|
278
|
-
disabled={options.print === 'disabled'}
|
|
279
|
-
onClick={handlePrint}>
|
|
280
|
-
<PrintIcon />
|
|
281
|
-
</IconButton>
|
|
282
|
-
</Tooltip>
|
|
283
|
-
</span>
|
|
284
|
-
))}
|
|
285
|
-
|
|
286
|
-
{toolbarButtons}
|
|
287
|
-
</>
|
|
288
|
-
)}
|
|
289
|
-
{showMore && (
|
|
290
|
-
<IconButton
|
|
291
|
-
ref={moreBtn}
|
|
292
|
-
aria-haspopup="true"
|
|
293
|
-
aria-expanded={menuIconEl ? 'true' : undefined}
|
|
294
|
-
onClick={(event) => setMenuIconEl(event.currentTarget)}
|
|
295
|
-
style={{ flexShrink: 0 }}>
|
|
296
|
-
<MoreVertIcon />
|
|
297
|
-
</IconButton>
|
|
298
|
-
)}
|
|
299
|
-
</div>
|
|
300
|
-
{customToolbarEle}
|
|
301
|
-
</Container>
|
|
302
|
-
<Menu
|
|
303
|
-
anchorEl={menuIconEl}
|
|
304
|
-
open={!!menuIconEl}
|
|
305
|
-
onClose={() => setMenuIconEl(null)}
|
|
306
|
-
slotProps={{
|
|
307
|
-
list: {
|
|
308
|
-
'aria-labelledby': 'more-button',
|
|
309
|
-
},
|
|
310
|
-
}}>
|
|
311
|
-
{!hidePrint &&
|
|
312
|
-
printArea(({ handlePrint }) => (
|
|
313
|
-
<MenuItem
|
|
314
|
-
onClick={() => {
|
|
315
|
-
setMenuIconEl(null);
|
|
316
|
-
handlePrint();
|
|
317
|
-
}}>
|
|
318
|
-
<ListItemIcon>
|
|
319
|
-
<PrintIcon fontSize="small" />
|
|
320
|
-
</ListItemIcon>
|
|
321
|
-
<ListItemText>{print}</ListItemText>
|
|
322
|
-
</MenuItem>
|
|
323
|
-
))}
|
|
324
|
-
{menuItems}
|
|
325
|
-
</Menu>
|
|
326
|
-
{allPops.map((e, index) => (
|
|
327
|
-
<div key={getPopId(index)}>{e}</div>
|
|
328
|
-
))}
|
|
329
|
-
<ProgressContainer>{loading && <LinearProgress className="toolbar-progress" />}</ProgressContainer>
|
|
330
|
-
</div>
|
|
331
|
-
);
|
|
332
|
-
}
|
|
333
|
-
|
|
334
|
-
CustomToolbar.propTypes = {
|
|
335
|
-
data: PropTypes.array,
|
|
336
|
-
options: PropTypes.object.isRequired,
|
|
337
|
-
components: PropTypes.object,
|
|
338
|
-
columns: PropTypes.array.isRequired,
|
|
339
|
-
filterList: PropTypes.array,
|
|
340
|
-
filterData: PropTypes.array,
|
|
341
|
-
filterUpdate: PropTypes.func.isRequired,
|
|
342
|
-
resetFilters: PropTypes.func.isRequired,
|
|
343
|
-
updateFilterByType: PropTypes.func.isRequired,
|
|
344
|
-
toggleViewColumn: PropTypes.func.isRequired,
|
|
345
|
-
updateColumns: PropTypes.func.isRequired,
|
|
346
|
-
title: PropTypes.any,
|
|
347
|
-
searchText: PropTypes.any,
|
|
348
|
-
searchTextUpdate: PropTypes.func.isRequired,
|
|
349
|
-
searchClose: PropTypes.func.isRequired,
|
|
350
|
-
tableRef: PropTypes.func.isRequired,
|
|
351
|
-
};
|
|
352
|
-
|
|
353
|
-
const Container = styled('div')`
|
|
354
|
-
display: flex;
|
|
355
|
-
align-items: center;
|
|
356
|
-
flex-wrap: wrap;
|
|
357
|
-
min-height: 56px;
|
|
358
|
-
.custom-toobar-title {
|
|
359
|
-
flex: 1 1 auto;
|
|
360
|
-
font-size: 18px;
|
|
361
|
-
font-weight: 800;
|
|
362
|
-
transition: all ease 0.3s;
|
|
363
|
-
&-inner {
|
|
364
|
-
width: 100%;
|
|
365
|
-
span {
|
|
366
|
-
display: inline-block;
|
|
367
|
-
max-width: 100%;
|
|
368
|
-
white-space: nowrap;
|
|
369
|
-
text-overflow: ellipsis;
|
|
370
|
-
overflow: hidden;
|
|
371
|
-
}
|
|
372
|
-
}
|
|
373
|
-
}
|
|
374
|
-
.custom-toobar-btns {
|
|
375
|
-
display: flex;
|
|
376
|
-
justify-content: center;
|
|
377
|
-
align-items: center;
|
|
378
|
-
&.toobar-btns-disabled {
|
|
379
|
-
position: relative;
|
|
380
|
-
opacity: 0.5;
|
|
381
|
-
&:after {
|
|
382
|
-
position: absolute;
|
|
383
|
-
display: block;
|
|
384
|
-
z-index: 2;
|
|
385
|
-
width: 100%;
|
|
386
|
-
height: 100%;
|
|
387
|
-
left: 0;
|
|
388
|
-
top: 0;
|
|
389
|
-
content: '';
|
|
390
|
-
cursor: not-allowed;
|
|
391
|
-
}
|
|
392
|
-
}
|
|
393
|
-
.custom-toolbar-icon {
|
|
394
|
-
display: flex;
|
|
395
|
-
justify-content: center;
|
|
396
|
-
align-items: center;
|
|
397
|
-
width: 24px;
|
|
398
|
-
height: 24px;
|
|
399
|
-
font-size: 20px;
|
|
400
|
-
overflow: hidden;
|
|
401
|
-
}
|
|
402
|
-
}
|
|
403
|
-
.toobar-title-hidden {
|
|
404
|
-
opacity: 0;
|
|
405
|
-
cursor: none;
|
|
406
|
-
}
|
|
407
|
-
`;
|
|
408
|
-
|
|
409
|
-
const ProgressContainer = styled('div')`
|
|
410
|
-
width: 100%;
|
|
411
|
-
height: 2px;
|
|
412
|
-
.toolbar-progress {
|
|
413
|
-
height: 2px;
|
|
414
|
-
}
|
|
415
|
-
`;
|
|
@@ -1,92 +0,0 @@
|
|
|
1
|
-
import { Box, IconButton } from '@mui/material';
|
|
2
|
-
import {
|
|
3
|
-
LightModeOutlined as LightModeOutlinedIcon,
|
|
4
|
-
Brightness2Outlined as Brightness2OutlinedIcon,
|
|
5
|
-
} from '@mui/icons-material';
|
|
6
|
-
|
|
7
|
-
import Basic from './demo/basic';
|
|
8
|
-
import Durable from './demo/durable';
|
|
9
|
-
import Stripped from './demo/stripped';
|
|
10
|
-
import LocaleZh from './demo/locale-zh';
|
|
11
|
-
import ElementTitle from './demo/element-title';
|
|
12
|
-
import CustomButtons from './demo/custom-buttons';
|
|
13
|
-
import ColumnWidth from './demo/column-width';
|
|
14
|
-
import SelectItem from './demo/select-item';
|
|
15
|
-
import SetTableBodyHeight from './demo/set-table-body-height';
|
|
16
|
-
import HideTableHeader from './demo/hide-table-header';
|
|
17
|
-
import ParentContainerHasHeight from './demo/parent-container-has-height';
|
|
18
|
-
import InFlexHeight from './demo/in-flex-height';
|
|
19
|
-
import EmptyTable from './demo/empty-table';
|
|
20
|
-
import VerticalKeyWidth from './demo/vertical-key-width';
|
|
21
|
-
import CustomCellRender from './demo/custom-cell-render';
|
|
22
|
-
import SearchOpenAndPlaceholder from './demo/search-open-and-placeholder';
|
|
23
|
-
import DynamicData from './demo/dynamic-data';
|
|
24
|
-
import LotsOfData from './demo/lots-of-data';
|
|
25
|
-
import JumpToPage from './demo/jump-to-page';
|
|
26
|
-
import { ThemeProvider, useColorScheme } from '../Theme';
|
|
27
|
-
|
|
28
|
-
export default {
|
|
29
|
-
title: 'Data Display/Datatable',
|
|
30
|
-
|
|
31
|
-
parameters: {
|
|
32
|
-
docs: {
|
|
33
|
-
description: {
|
|
34
|
-
component: 'Enhanced Datatable component, based on mui-datatables',
|
|
35
|
-
},
|
|
36
|
-
},
|
|
37
|
-
},
|
|
38
|
-
decorators: [
|
|
39
|
-
(StoryFn) => (
|
|
40
|
-
<ThemeProvider prefer="system">
|
|
41
|
-
<Container>
|
|
42
|
-
<StoryFn />
|
|
43
|
-
</Container>
|
|
44
|
-
</ThemeProvider>
|
|
45
|
-
),
|
|
46
|
-
],
|
|
47
|
-
};
|
|
48
|
-
|
|
49
|
-
export {
|
|
50
|
-
Basic,
|
|
51
|
-
Durable,
|
|
52
|
-
Stripped,
|
|
53
|
-
LocaleZh,
|
|
54
|
-
ElementTitle,
|
|
55
|
-
CustomButtons,
|
|
56
|
-
ColumnWidth,
|
|
57
|
-
SelectItem,
|
|
58
|
-
SetTableBodyHeight,
|
|
59
|
-
HideTableHeader,
|
|
60
|
-
ParentContainerHasHeight,
|
|
61
|
-
InFlexHeight,
|
|
62
|
-
EmptyTable,
|
|
63
|
-
VerticalKeyWidth,
|
|
64
|
-
CustomCellRender,
|
|
65
|
-
SearchOpenAndPlaceholder,
|
|
66
|
-
DynamicData,
|
|
67
|
-
LotsOfData,
|
|
68
|
-
JumpToPage,
|
|
69
|
-
};
|
|
70
|
-
|
|
71
|
-
VerticalKeyWidth.parameters = {
|
|
72
|
-
viewport: {
|
|
73
|
-
defaultViewport: 'tablet',
|
|
74
|
-
},
|
|
75
|
-
};
|
|
76
|
-
|
|
77
|
-
// eslint-disable-next-line react/prop-types
|
|
78
|
-
function Container({ children }) {
|
|
79
|
-
const { mode, toggleMode } = useColorScheme();
|
|
80
|
-
|
|
81
|
-
return (
|
|
82
|
-
<Box sx={{ p: 4, backgroundColor: 'background.default', color: 'text.primary' }}>
|
|
83
|
-
<Box sx={{ display: 'flex', alignItems: 'center', justifyContent: 'flex-end' }}>
|
|
84
|
-
{/* 切换浅色/深色模式 */}
|
|
85
|
-
<IconButton onClick={toggleMode} color="inherit" sx={{ border: 1, borderColor: 'divider' }}>
|
|
86
|
-
{mode === 'light' ? <Brightness2OutlinedIcon /> : <LightModeOutlinedIcon />}
|
|
87
|
-
</IconButton>
|
|
88
|
-
</Box>
|
|
89
|
-
{children}
|
|
90
|
-
</Box>
|
|
91
|
-
);
|
|
92
|
-
}
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import { createContext, use, useState } from 'react';
|
|
2
|
-
|
|
3
|
-
const DatatableContext = createContext({});
|
|
4
|
-
|
|
5
|
-
const { Provider } = DatatableContext;
|
|
6
|
-
|
|
7
|
-
// eslint-disable-next-line react/prop-types
|
|
8
|
-
function DatatableProvider({ children }) {
|
|
9
|
-
const [customButtons, setCustomButtons] = useState([]);
|
|
10
|
-
const [customPreButtons, setCustomPreButtons] = useState([]);
|
|
11
|
-
const [loading, setLoading] = useState(false);
|
|
12
|
-
const [disabled, setDisabled] = useState(false);
|
|
13
|
-
const [filterLabel, setFilterLabel] = useState('Filter');
|
|
14
|
-
|
|
15
|
-
const value = {
|
|
16
|
-
customButtons,
|
|
17
|
-
setCustomButtons,
|
|
18
|
-
customPreButtons,
|
|
19
|
-
setCustomPreButtons,
|
|
20
|
-
filterLabel,
|
|
21
|
-
setFilterLabel,
|
|
22
|
-
loading,
|
|
23
|
-
setLoading,
|
|
24
|
-
disabled,
|
|
25
|
-
setDisabled,
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
return <Provider value={value}>{children}</Provider>;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
function useDatatableContext() {
|
|
32
|
-
return use(DatatableContext);
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
export { DatatableProvider, useDatatableContext };
|
|
@@ -1,166 +0,0 @@
|
|
|
1
|
-
import { useState, useRef } from 'react';
|
|
2
|
-
import PropTypes from 'prop-types';
|
|
3
|
-
import { IconButton, Tooltip, TextField } from '@mui/material';
|
|
4
|
-
import { Search as SearchIcon, Clear as ClearIcon } from '@mui/icons-material';
|
|
5
|
-
import clsx from 'clsx';
|
|
6
|
-
import noop from 'lodash/noop';
|
|
7
|
-
|
|
8
|
-
import { useDatatableContext } from './DatatableContext';
|
|
9
|
-
import { styled } from '../Theme';
|
|
10
|
-
|
|
11
|
-
export default function TableSearch({
|
|
12
|
-
search = '',
|
|
13
|
-
options,
|
|
14
|
-
searchText = '',
|
|
15
|
-
searchTextUpdate,
|
|
16
|
-
searchClose,
|
|
17
|
-
onSearchOpen = noop,
|
|
18
|
-
}) {
|
|
19
|
-
const { searchOpen, searchPlaceholder, searchAlwaysOpen } = options;
|
|
20
|
-
const [inputExpand, setInputExpand] = useState(!!searchText || searchOpen || false);
|
|
21
|
-
const [innerSearchText, setInnerSearchText] = useState(searchText);
|
|
22
|
-
const inputTimer = useRef(null);
|
|
23
|
-
const { loading } = useDatatableContext();
|
|
24
|
-
|
|
25
|
-
const { searchDebounceTime } = options;
|
|
26
|
-
|
|
27
|
-
const searchExpand = searchAlwaysOpen || inputExpand;
|
|
28
|
-
|
|
29
|
-
const clickSearchIcon = () => {
|
|
30
|
-
setInputExpand(true);
|
|
31
|
-
onSearchOpen(true);
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
const onChange = (event) => {
|
|
35
|
-
const { value } = event.currentTarget;
|
|
36
|
-
if (searchDebounceTime) {
|
|
37
|
-
clearTimeout(inputTimer.current);
|
|
38
|
-
setInnerSearchText(value);
|
|
39
|
-
inputTimer.current = setTimeout(() => {
|
|
40
|
-
searchTextUpdate(value);
|
|
41
|
-
}, searchDebounceTime);
|
|
42
|
-
} else {
|
|
43
|
-
searchTextUpdate(value);
|
|
44
|
-
}
|
|
45
|
-
};
|
|
46
|
-
|
|
47
|
-
const clickClose = () => {
|
|
48
|
-
setInputExpand(false);
|
|
49
|
-
searchClose();
|
|
50
|
-
setInnerSearchText('');
|
|
51
|
-
onSearchOpen(false);
|
|
52
|
-
};
|
|
53
|
-
|
|
54
|
-
return (
|
|
55
|
-
<Container
|
|
56
|
-
className={clsx({
|
|
57
|
-
'search-always-open': searchAlwaysOpen,
|
|
58
|
-
})}>
|
|
59
|
-
{searchExpand ? (
|
|
60
|
-
<div className="toolbar-search-icon-placeholder">
|
|
61
|
-
<SearchIcon />
|
|
62
|
-
</div>
|
|
63
|
-
) : (
|
|
64
|
-
<Tooltip title={search} disableFocusListener>
|
|
65
|
-
<IconButton
|
|
66
|
-
aria-label={search}
|
|
67
|
-
data-testid={`${search}-iconButton`}
|
|
68
|
-
disabled={options.search === 'disabled'}
|
|
69
|
-
onClick={clickSearchIcon}>
|
|
70
|
-
<SearchIcon />
|
|
71
|
-
</IconButton>
|
|
72
|
-
</Tooltip>
|
|
73
|
-
)}
|
|
74
|
-
|
|
75
|
-
<div className={`toolbar-search-area ${searchExpand ? 'toolbar-btn-show' : ''}`}>
|
|
76
|
-
{searchExpand && !loading && (
|
|
77
|
-
<TextField
|
|
78
|
-
variant="standard"
|
|
79
|
-
spacing={2}
|
|
80
|
-
onChange={onChange}
|
|
81
|
-
value={searchDebounceTime ? innerSearchText : searchText}
|
|
82
|
-
placeholder={searchPlaceholder || ''}
|
|
83
|
-
autoFocus={!searchAlwaysOpen}
|
|
84
|
-
/>
|
|
85
|
-
)}
|
|
86
|
-
{/* loading完成后没办法使用focus方法,所以改用两个 TextField */}
|
|
87
|
-
{loading && (
|
|
88
|
-
<TextField
|
|
89
|
-
disabled
|
|
90
|
-
variant="standard"
|
|
91
|
-
spacing={2}
|
|
92
|
-
value={searchDebounceTime ? innerSearchText : searchText}
|
|
93
|
-
/>
|
|
94
|
-
)}
|
|
95
|
-
</div>
|
|
96
|
-
{!searchAlwaysOpen && (
|
|
97
|
-
<div className={`toolbar-search-close ${searchExpand ? 'toolbar-btn-show' : ''}`}>
|
|
98
|
-
<IconButton onClick={clickClose} aria-label="click to close the search box">
|
|
99
|
-
<ClearIcon />
|
|
100
|
-
</IconButton>
|
|
101
|
-
</div>
|
|
102
|
-
)}
|
|
103
|
-
</Container>
|
|
104
|
-
);
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
TableSearch.propTypes = {
|
|
108
|
-
search: PropTypes.string,
|
|
109
|
-
searchText: PropTypes.string,
|
|
110
|
-
onSearchOpen: PropTypes.func,
|
|
111
|
-
options: PropTypes.object.isRequired,
|
|
112
|
-
searchTextUpdate: PropTypes.func.isRequired,
|
|
113
|
-
searchClose: PropTypes.func.isRequired,
|
|
114
|
-
};
|
|
115
|
-
|
|
116
|
-
const Container = styled('div')`
|
|
117
|
-
display: flex;
|
|
118
|
-
align-items: center;
|
|
119
|
-
.toolbar-search-area {
|
|
120
|
-
width: 0;
|
|
121
|
-
transition: all ease 0.3s;
|
|
122
|
-
overflow: hidden;
|
|
123
|
-
.MuiFormControl-root {
|
|
124
|
-
width: inherit;
|
|
125
|
-
margin: 0 12px;
|
|
126
|
-
}
|
|
127
|
-
&.toolbar-btn-show {
|
|
128
|
-
width: 260px;
|
|
129
|
-
padding-left: 8px;
|
|
130
|
-
|
|
131
|
-
${(props) => props.theme.breakpoints.down('md')} {
|
|
132
|
-
width: 200px;
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
${(props) => props.theme.breakpoints.down('sm')} {
|
|
136
|
-
width: 180px;
|
|
137
|
-
}
|
|
138
|
-
&.small-textfield {
|
|
139
|
-
width: 200px;
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
.toolbar-search-close {
|
|
144
|
-
width: 0;
|
|
145
|
-
transition: all ease 0.3s;
|
|
146
|
-
overflow: hidden;
|
|
147
|
-
&.toolbar-btn-show {
|
|
148
|
-
width: 40px;
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
.toolbar-search-icon-placeholder {
|
|
152
|
-
display: flex;
|
|
153
|
-
justify-content: center;
|
|
154
|
-
align-items: center;
|
|
155
|
-
width: 40px;
|
|
156
|
-
height: 40px;
|
|
157
|
-
}
|
|
158
|
-
&.search-always-open {
|
|
159
|
-
.MuiFormControl-root {
|
|
160
|
-
margin: 0 12px 0 0;
|
|
161
|
-
}
|
|
162
|
-
.toolbar-btn-show {
|
|
163
|
-
padding-left: 0;
|
|
164
|
-
}
|
|
165
|
-
}
|
|
166
|
-
`;
|