@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,252 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Org transfer selector
|
|
3
|
-
*/
|
|
4
|
-
import { useImperativeHandle, useState } from 'react';
|
|
5
|
-
import { useReactive, useDebounce, useInfiniteScroll, useMemoizedFn } from 'ahooks';
|
|
6
|
-
import { Button, Typography, Box, Autocomplete, TextField, CircularProgress } from '@mui/material';
|
|
7
|
-
import { AxiosError } from 'axios';
|
|
8
|
-
import { getBlockletSDK } from '@blocklet/js-sdk';
|
|
9
|
-
|
|
10
|
-
import Toast from '../Toast';
|
|
11
|
-
import Dialog from '../Dialog';
|
|
12
|
-
import { Org, OrgTransferSelectorProps } from './type';
|
|
13
|
-
import { OrgQueryType } from '../Util/client';
|
|
14
|
-
import { formatAxiosError } from '../Util';
|
|
15
|
-
import { translate } from '../Locale/util';
|
|
16
|
-
import translations from './locales';
|
|
17
|
-
|
|
18
|
-
const PAGE_SIZE = 20;
|
|
19
|
-
|
|
20
|
-
export default function OrgTransferSelector({
|
|
21
|
-
ref,
|
|
22
|
-
org,
|
|
23
|
-
onSuccess,
|
|
24
|
-
resourceId,
|
|
25
|
-
locale = 'en',
|
|
26
|
-
dialogProps,
|
|
27
|
-
}: OrgTransferSelectorProps) {
|
|
28
|
-
const t = useMemoizedFn((key, data = {}) => {
|
|
29
|
-
return translate(translations, key, locale, 'en', data);
|
|
30
|
-
});
|
|
31
|
-
const client = getBlockletSDK();
|
|
32
|
-
const [searchText, setSearchText] = useState('');
|
|
33
|
-
|
|
34
|
-
const state = useReactive<{
|
|
35
|
-
open: boolean;
|
|
36
|
-
selectedOrg: Org | null;
|
|
37
|
-
}>({
|
|
38
|
-
open: false,
|
|
39
|
-
selectedOrg: null,
|
|
40
|
-
});
|
|
41
|
-
|
|
42
|
-
const debouncedSearchText = useDebounce(searchText, { wait: 500 });
|
|
43
|
-
|
|
44
|
-
const { data, loadMore, loadingMore, loading, reload } = useInfiniteScroll(
|
|
45
|
-
async (d) => {
|
|
46
|
-
// 只有对话框打开时才发起请求
|
|
47
|
-
if (!state.open) return { list: [], total: 0 };
|
|
48
|
-
|
|
49
|
-
const page = d ? Math.ceil(d.list.length / PAGE_SIZE) + 1 : 1;
|
|
50
|
-
const params = { page, pageSize: PAGE_SIZE, search: debouncedSearchText, type: OrgQueryType.OWNED };
|
|
51
|
-
const response = await client.user.getOrgs(params);
|
|
52
|
-
|
|
53
|
-
const { orgs: resultOrgs = [], paging } = response || {};
|
|
54
|
-
return { list: resultOrgs, total: paging?.total || 0 };
|
|
55
|
-
},
|
|
56
|
-
{
|
|
57
|
-
reloadDeps: [debouncedSearchText],
|
|
58
|
-
isNoMore: (d) => {
|
|
59
|
-
if (!d?.list.length) return true;
|
|
60
|
-
return d.list.length >= d?.total;
|
|
61
|
-
},
|
|
62
|
-
onError: (error) => {
|
|
63
|
-
// eslint-disable-next-line no-console
|
|
64
|
-
console.error('Get orgs failed', error);
|
|
65
|
-
},
|
|
66
|
-
manual: true, // 手动触发,在对话框打开时再加载
|
|
67
|
-
}
|
|
68
|
-
);
|
|
69
|
-
|
|
70
|
-
const handleClose = useMemoizedFn(() => {
|
|
71
|
-
state.open = false;
|
|
72
|
-
state.selectedOrg = null;
|
|
73
|
-
setSearchText(''); // 关闭时重置搜索
|
|
74
|
-
});
|
|
75
|
-
|
|
76
|
-
const handleConfirm = useMemoizedFn(async () => {
|
|
77
|
-
try {
|
|
78
|
-
if (!resourceId) {
|
|
79
|
-
throw new Error(t('resourceIdRequired'));
|
|
80
|
-
}
|
|
81
|
-
if (!state.selectedOrg) {
|
|
82
|
-
throw new Error(t('placeholder'));
|
|
83
|
-
}
|
|
84
|
-
if (state.selectedOrg.id === org.id) {
|
|
85
|
-
throw new Error(t('organizationSameAsCurrent'));
|
|
86
|
-
}
|
|
87
|
-
await client.user.migrateResourceToOrg({ form: org.id, to: state.selectedOrg.id, resourceId });
|
|
88
|
-
handleClose();
|
|
89
|
-
onSuccess?.(state.selectedOrg);
|
|
90
|
-
Toast.success(t('tranferSuccess'));
|
|
91
|
-
} catch (error) {
|
|
92
|
-
console.error('Resource transfer failed', error);
|
|
93
|
-
Toast.error(formatAxiosError(error as AxiosError));
|
|
94
|
-
}
|
|
95
|
-
});
|
|
96
|
-
|
|
97
|
-
useImperativeHandle(ref, () => ({
|
|
98
|
-
open: (options = {}) => {
|
|
99
|
-
Object.assign(state, { open: true, selectedOrg: null }, options);
|
|
100
|
-
// 对话框打开时重新加载数据
|
|
101
|
-
setTimeout(() => {
|
|
102
|
-
if (state.open) {
|
|
103
|
-
reload();
|
|
104
|
-
}
|
|
105
|
-
}, 0);
|
|
106
|
-
},
|
|
107
|
-
close: handleClose,
|
|
108
|
-
}));
|
|
109
|
-
|
|
110
|
-
const organizations = data?.list || [];
|
|
111
|
-
// const hasMore = data ? data.list.length < data.total : false;
|
|
112
|
-
|
|
113
|
-
const { placeholder = '', ...rest } = dialogProps || {};
|
|
114
|
-
return (
|
|
115
|
-
<Dialog
|
|
116
|
-
title={t('transferOrg')}
|
|
117
|
-
fullWidth
|
|
118
|
-
maxWidth="sm"
|
|
119
|
-
open={state.open}
|
|
120
|
-
onClose={handleClose}
|
|
121
|
-
actions={
|
|
122
|
-
<>
|
|
123
|
-
<Button onClick={handleClose} color="secondary" variant="outlined">
|
|
124
|
-
{t('cancel')}
|
|
125
|
-
</Button>
|
|
126
|
-
<Button onClick={handleConfirm} color="primary" variant="contained" disabled={!state.selectedOrg}>
|
|
127
|
-
{t('confirm')}
|
|
128
|
-
</Button>
|
|
129
|
-
</>
|
|
130
|
-
}
|
|
131
|
-
{...(rest || {})}>
|
|
132
|
-
<Box>
|
|
133
|
-
<Typography variant="body2" color="text.secondary" sx={{ mb: 2 }}>
|
|
134
|
-
{placeholder || t('placeholder')}
|
|
135
|
-
</Typography>
|
|
136
|
-
|
|
137
|
-
<Autocomplete
|
|
138
|
-
options={organizations}
|
|
139
|
-
getOptionLabel={(option) => option?.name || ''}
|
|
140
|
-
isOptionEqualToValue={(option, value) => option?.id === value?.id}
|
|
141
|
-
value={state.selectedOrg}
|
|
142
|
-
onChange={(_, newValue) => {
|
|
143
|
-
// 如果点击的是加载项,触发加载更多
|
|
144
|
-
if (newValue?.isLoadingItem && !loadingMore) {
|
|
145
|
-
loadMore();
|
|
146
|
-
return;
|
|
147
|
-
}
|
|
148
|
-
// 忽略加载项的选择
|
|
149
|
-
if (newValue?.isLoadingItem) {
|
|
150
|
-
return;
|
|
151
|
-
}
|
|
152
|
-
state.selectedOrg = newValue;
|
|
153
|
-
// 选择选项后清空搜索文本
|
|
154
|
-
if (newValue) {
|
|
155
|
-
setSearchText('');
|
|
156
|
-
}
|
|
157
|
-
}}
|
|
158
|
-
inputValue={state.selectedOrg ? state.selectedOrg.name : searchText}
|
|
159
|
-
onInputChange={(_, newInputValue, reason) => {
|
|
160
|
-
// 只有用户键盘输入时才更新搜索文本
|
|
161
|
-
if (reason === 'input') {
|
|
162
|
-
// 用户开始输入时,清除当前选中的组织,进入搜索模式
|
|
163
|
-
if (state.selectedOrg) {
|
|
164
|
-
state.selectedOrg = null;
|
|
165
|
-
}
|
|
166
|
-
setSearchText(newInputValue);
|
|
167
|
-
}
|
|
168
|
-
}}
|
|
169
|
-
loading={loading}
|
|
170
|
-
loadingText={t('loading')}
|
|
171
|
-
noOptionsText={loading ? t('loading') : t('noResults')}
|
|
172
|
-
renderInput={(params) => (
|
|
173
|
-
<TextField
|
|
174
|
-
{...params}
|
|
175
|
-
variant="outlined"
|
|
176
|
-
fullWidth
|
|
177
|
-
InputProps={{
|
|
178
|
-
...params.InputProps,
|
|
179
|
-
endAdornment: (
|
|
180
|
-
<>
|
|
181
|
-
{loading && <CircularProgress color="inherit" size={20} />}
|
|
182
|
-
{params.InputProps.endAdornment}
|
|
183
|
-
</>
|
|
184
|
-
),
|
|
185
|
-
}}
|
|
186
|
-
/>
|
|
187
|
-
)}
|
|
188
|
-
renderOption={(props, option) => {
|
|
189
|
-
// 特殊处理加载项
|
|
190
|
-
if (option.isLoadingItem) {
|
|
191
|
-
return (
|
|
192
|
-
<Box component="li" {...props} key={option.id}>
|
|
193
|
-
<Box
|
|
194
|
-
sx={{
|
|
195
|
-
display: 'flex',
|
|
196
|
-
alignItems: 'center',
|
|
197
|
-
justifyContent: 'center',
|
|
198
|
-
flex: 1,
|
|
199
|
-
py: 1,
|
|
200
|
-
color: 'primary.main',
|
|
201
|
-
cursor: 'pointer',
|
|
202
|
-
}}>
|
|
203
|
-
{loadingMore && <CircularProgress size={16} sx={{ mr: 1 }} />}
|
|
204
|
-
<Typography variant="body2" sx={{ fontStyle: loadingMore ? 'italic' : 'normal' }}>
|
|
205
|
-
{option.name}
|
|
206
|
-
</Typography>
|
|
207
|
-
</Box>
|
|
208
|
-
</Box>
|
|
209
|
-
);
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
// 正常组织项的渲染
|
|
213
|
-
return (
|
|
214
|
-
<Box component="li" {...props} key={option.id}>
|
|
215
|
-
<Box sx={{ display: 'flex', flexDirection: 'column', flex: 1, minWidth: 0 }}>
|
|
216
|
-
<Typography
|
|
217
|
-
variant="body1"
|
|
218
|
-
sx={{
|
|
219
|
-
overflow: 'hidden',
|
|
220
|
-
textOverflow: 'ellipsis',
|
|
221
|
-
whiteSpace: 'nowrap',
|
|
222
|
-
}}>
|
|
223
|
-
{option.name}
|
|
224
|
-
</Typography>
|
|
225
|
-
{option.description && (
|
|
226
|
-
<Typography
|
|
227
|
-
variant="body2"
|
|
228
|
-
color="text.secondary"
|
|
229
|
-
sx={{
|
|
230
|
-
display: '-webkit-box',
|
|
231
|
-
WebkitLineClamp: 3,
|
|
232
|
-
WebkitBoxOrient: 'vertical',
|
|
233
|
-
overflow: 'hidden',
|
|
234
|
-
textOverflow: 'ellipsis',
|
|
235
|
-
}}>
|
|
236
|
-
{option.description}
|
|
237
|
-
</Typography>
|
|
238
|
-
)}
|
|
239
|
-
</Box>
|
|
240
|
-
</Box>
|
|
241
|
-
);
|
|
242
|
-
}}
|
|
243
|
-
sx={{
|
|
244
|
-
'& .MuiAutocomplete-listbox': {
|
|
245
|
-
maxHeight: 200,
|
|
246
|
-
},
|
|
247
|
-
}}
|
|
248
|
-
/>
|
|
249
|
-
</Box>
|
|
250
|
-
</Dialog>
|
|
251
|
-
);
|
|
252
|
-
}
|
package/src/OrgTransfer/type.ts
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import type { ComponentProps } from 'react';
|
|
2
|
-
import { ButtonProps } from '@mui/material';
|
|
3
|
-
import Dialog from '../Dialog';
|
|
4
|
-
|
|
5
|
-
export type Org = {
|
|
6
|
-
id: string;
|
|
7
|
-
name: string;
|
|
8
|
-
description?: string;
|
|
9
|
-
ownerDid: string;
|
|
10
|
-
metadata?: Record<string, any>;
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
type DialogProps = ComponentProps<typeof Dialog> & {
|
|
14
|
-
placeholder?: string; // 搜索框的 placeholder
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
export type OrgTransferSelectorProps = Omit<OrgTransferProps, 'children' | 'buttonProps' | 'buttonText'> & {
|
|
18
|
-
ref: React.RefObject<unknown | null>;
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
export interface OrgTransferProps {
|
|
22
|
-
resourceId: string;
|
|
23
|
-
onSuccess?: (org: Org) => void;
|
|
24
|
-
org?: Org; // 当前所在的 Org
|
|
25
|
-
children?: React.ReactNode;
|
|
26
|
-
buttonProps?: ButtonProps;
|
|
27
|
-
buttonText?: string;
|
|
28
|
-
dialogProps?: DialogProps;
|
|
29
|
-
locale?: string;
|
|
30
|
-
[key: string]: any;
|
|
31
|
-
}
|
|
@@ -1,316 +0,0 @@
|
|
|
1
|
-
/* eslint-disable jsx-a11y/no-noninteractive-tabindex */
|
|
2
|
-
import { Children, cloneElement, useCallback, useEffect, useRef, useState } from 'react';
|
|
3
|
-
import isEqual from 'lodash/isEqual';
|
|
4
|
-
import isNil from 'lodash/isNil';
|
|
5
|
-
import isNull from 'lodash/isNull';
|
|
6
|
-
|
|
7
|
-
import usePrevious from './usePrevValue';
|
|
8
|
-
import { withDeprecated } from '../Util/deprecate';
|
|
9
|
-
|
|
10
|
-
const Events = {
|
|
11
|
-
TOUCHMOVE: 'touchmove',
|
|
12
|
-
KEYDOWN: 'keydown',
|
|
13
|
-
} as const;
|
|
14
|
-
|
|
15
|
-
const DEFAULT_ANIMATION_TIMER = 500;
|
|
16
|
-
const DEFAULT_ANIMATION = 'ease-in-out';
|
|
17
|
-
const DEFAULT_CONTAINER_HEIGHT = '100vh';
|
|
18
|
-
const DEFAULT_CONTAINER_WIDTH = '100vw';
|
|
19
|
-
const DEFAULT_COMPONENT_INDEX = 0;
|
|
20
|
-
const DEFAULT_COMPONENTS_TO_RENDER_LENGTH = 0;
|
|
21
|
-
|
|
22
|
-
const ANIMATION_TIMER_BUFFER = 100;
|
|
23
|
-
const KEY_UP = 38;
|
|
24
|
-
const KEY_DOWN = 40;
|
|
25
|
-
const DISABLED_CLASS_NAME = 'rps-scroll--disabled';
|
|
26
|
-
|
|
27
|
-
let previousTouchMove: number | null = null;
|
|
28
|
-
let isScrolling = false;
|
|
29
|
-
let isMounted = false;
|
|
30
|
-
let isBodyScrollEnabled = true;
|
|
31
|
-
let isTransitionAfterComponentsToRenderChanged = false;
|
|
32
|
-
const containers: boolean[] = [];
|
|
33
|
-
|
|
34
|
-
export interface PageScrollerProps {
|
|
35
|
-
animationTimer?: number;
|
|
36
|
-
blockScrollDown?: false | true;
|
|
37
|
-
blockScrollUp?: false | true;
|
|
38
|
-
children?: React.ReactElement<any> | React.ReactElement<any>[];
|
|
39
|
-
height?: number | string;
|
|
40
|
-
width?: number | string;
|
|
41
|
-
customPageNumber?: number;
|
|
42
|
-
onScrollUnavailable?: () => void;
|
|
43
|
-
onChange?: (index: number) => void;
|
|
44
|
-
renderAllPagesOnFirstRender?: false | true;
|
|
45
|
-
transitionTimingFunction?: string;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
function PageScroller({
|
|
49
|
-
animationTimer = DEFAULT_ANIMATION_TIMER,
|
|
50
|
-
blockScrollDown = false,
|
|
51
|
-
blockScrollUp = false,
|
|
52
|
-
children: _children = undefined,
|
|
53
|
-
height = DEFAULT_CONTAINER_HEIGHT,
|
|
54
|
-
width = DEFAULT_CONTAINER_WIDTH,
|
|
55
|
-
customPageNumber = undefined,
|
|
56
|
-
onScrollUnavailable = undefined,
|
|
57
|
-
onChange = undefined,
|
|
58
|
-
renderAllPagesOnFirstRender = false,
|
|
59
|
-
transitionTimingFunction = DEFAULT_ANIMATION,
|
|
60
|
-
}: PageScrollerProps) {
|
|
61
|
-
const [componentIndex, setComponentIndex] = useState(DEFAULT_COMPONENT_INDEX);
|
|
62
|
-
const [componentsToRenderLength, setComponentsToRenderLength] = useState(DEFAULT_COMPONENTS_TO_RENDER_LENGTH);
|
|
63
|
-
const prevComponentIndex = usePrevious(componentIndex);
|
|
64
|
-
const pageContainer = useRef<HTMLDivElement>(null);
|
|
65
|
-
const children = Children.toArray(_children) as React.ReactElement<any>[];
|
|
66
|
-
|
|
67
|
-
const addNextComponent = useCallback(
|
|
68
|
-
(componentsToRenderOnMountLength?: number) => {
|
|
69
|
-
let tempComponentsToRenderLength = 0;
|
|
70
|
-
|
|
71
|
-
if (!isNil(componentsToRenderOnMountLength)) {
|
|
72
|
-
tempComponentsToRenderLength = componentsToRenderOnMountLength;
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
tempComponentsToRenderLength = Math.max(tempComponentsToRenderLength, componentsToRenderLength);
|
|
76
|
-
|
|
77
|
-
if (tempComponentsToRenderLength <= componentIndex + 1) {
|
|
78
|
-
if (!isNil(children[componentIndex + 1])) {
|
|
79
|
-
tempComponentsToRenderLength++;
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
setComponentsToRenderLength(tempComponentsToRenderLength);
|
|
84
|
-
},
|
|
85
|
-
[children, componentIndex, componentsToRenderLength]
|
|
86
|
-
);
|
|
87
|
-
|
|
88
|
-
const checkRenderOnMount = useCallback(() => {
|
|
89
|
-
if (renderAllPagesOnFirstRender) {
|
|
90
|
-
setComponentsToRenderLength(Children.count(children));
|
|
91
|
-
} else if (!isNil(children[DEFAULT_COMPONENT_INDEX + 1])) {
|
|
92
|
-
addNextComponent(DEFAULT_COMPONENTS_TO_RENDER_LENGTH + 1);
|
|
93
|
-
}
|
|
94
|
-
}, [addNextComponent, children, renderAllPagesOnFirstRender]);
|
|
95
|
-
|
|
96
|
-
const disableScroll = useCallback(() => {
|
|
97
|
-
if (isBodyScrollEnabled) {
|
|
98
|
-
isBodyScrollEnabled = false;
|
|
99
|
-
window.scrollTo({
|
|
100
|
-
left: 0,
|
|
101
|
-
top: 0,
|
|
102
|
-
behavior: 'smooth',
|
|
103
|
-
});
|
|
104
|
-
document.body.classList.add(DISABLED_CLASS_NAME);
|
|
105
|
-
document.documentElement.classList.add(DISABLED_CLASS_NAME);
|
|
106
|
-
}
|
|
107
|
-
}, []);
|
|
108
|
-
|
|
109
|
-
const enableDocumentScroll = useCallback(() => {
|
|
110
|
-
if (!isBodyScrollEnabled) {
|
|
111
|
-
isBodyScrollEnabled = true;
|
|
112
|
-
document.body.classList.remove(DISABLED_CLASS_NAME);
|
|
113
|
-
document.documentElement.classList.remove(DISABLED_CLASS_NAME);
|
|
114
|
-
}
|
|
115
|
-
}, []);
|
|
116
|
-
|
|
117
|
-
const setRenderComponents = useCallback(() => {
|
|
118
|
-
const newComponentsToRender = [];
|
|
119
|
-
|
|
120
|
-
let i = 0;
|
|
121
|
-
|
|
122
|
-
while (i < componentsToRenderLength && !isNil(children[i])) {
|
|
123
|
-
containers[i] = true;
|
|
124
|
-
newComponentsToRender.push(
|
|
125
|
-
<div key={i} style={{ height: '100%', width: '100%' }}>
|
|
126
|
-
{cloneElement(children[i], { ...children[i].props })}
|
|
127
|
-
</div>
|
|
128
|
-
);
|
|
129
|
-
i++;
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
return newComponentsToRender;
|
|
133
|
-
}, [children, componentsToRenderLength]);
|
|
134
|
-
|
|
135
|
-
const scrollWindowDown = useCallback(() => {
|
|
136
|
-
if (!isScrolling && !blockScrollDown) {
|
|
137
|
-
if (!isNil(containers[componentIndex + 1])) {
|
|
138
|
-
disableScroll();
|
|
139
|
-
isScrolling = true;
|
|
140
|
-
pageContainer.current!.style.transform = `translate3d(0, ${(componentIndex + 1) * -100}%, 0)`; // prettier-ignore
|
|
141
|
-
|
|
142
|
-
setTimeout(() => {
|
|
143
|
-
if (isMounted) {
|
|
144
|
-
setComponentIndex((prevState) => prevState + 1);
|
|
145
|
-
}
|
|
146
|
-
}, animationTimer + ANIMATION_TIMER_BUFFER);
|
|
147
|
-
} else {
|
|
148
|
-
enableDocumentScroll();
|
|
149
|
-
if (onScrollUnavailable) {
|
|
150
|
-
onScrollUnavailable();
|
|
151
|
-
}
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
|
-
}, [animationTimer, blockScrollDown, componentIndex, disableScroll, enableDocumentScroll, onScrollUnavailable]);
|
|
155
|
-
|
|
156
|
-
const scrollWindowUp = useCallback(() => {
|
|
157
|
-
if (!isScrolling && !blockScrollUp) {
|
|
158
|
-
if (!isNil(containers[componentIndex - 1])) {
|
|
159
|
-
disableScroll();
|
|
160
|
-
isScrolling = true;
|
|
161
|
-
pageContainer.current!.style.transform = `translate3d(0, ${(componentIndex - 1) * -100}%, 0)`; // prettier-ignore
|
|
162
|
-
|
|
163
|
-
setTimeout(() => {
|
|
164
|
-
if (isMounted) {
|
|
165
|
-
setComponentIndex((prevState) => prevState - 1);
|
|
166
|
-
}
|
|
167
|
-
}, animationTimer + ANIMATION_TIMER_BUFFER);
|
|
168
|
-
} else {
|
|
169
|
-
enableDocumentScroll();
|
|
170
|
-
if (onScrollUnavailable) {
|
|
171
|
-
onScrollUnavailable();
|
|
172
|
-
}
|
|
173
|
-
}
|
|
174
|
-
}
|
|
175
|
-
}, [animationTimer, blockScrollUp, componentIndex, disableScroll, enableDocumentScroll, onScrollUnavailable]);
|
|
176
|
-
|
|
177
|
-
const touchMove = useCallback(
|
|
178
|
-
(event: TouchEvent) => {
|
|
179
|
-
if (!isNull(previousTouchMove)) {
|
|
180
|
-
if (event.touches[0].clientY > previousTouchMove) {
|
|
181
|
-
scrollWindowUp();
|
|
182
|
-
} else {
|
|
183
|
-
scrollWindowDown();
|
|
184
|
-
}
|
|
185
|
-
} else {
|
|
186
|
-
previousTouchMove = event.touches[0].clientY;
|
|
187
|
-
}
|
|
188
|
-
},
|
|
189
|
-
[scrollWindowDown, scrollWindowUp]
|
|
190
|
-
);
|
|
191
|
-
|
|
192
|
-
const wheelScroll = useCallback(
|
|
193
|
-
(event: React.WheelEvent<HTMLDivElement>) => {
|
|
194
|
-
if (event.deltaY < 0) {
|
|
195
|
-
scrollWindowUp();
|
|
196
|
-
} else {
|
|
197
|
-
scrollWindowDown();
|
|
198
|
-
}
|
|
199
|
-
},
|
|
200
|
-
[scrollWindowDown, scrollWindowUp]
|
|
201
|
-
);
|
|
202
|
-
|
|
203
|
-
const keyPress = useCallback(
|
|
204
|
-
(event: KeyboardEvent) => {
|
|
205
|
-
if (isEqual(event.keyCode, KEY_UP)) {
|
|
206
|
-
scrollWindowUp();
|
|
207
|
-
}
|
|
208
|
-
if (isEqual(event.keyCode, KEY_DOWN)) {
|
|
209
|
-
scrollWindowDown();
|
|
210
|
-
}
|
|
211
|
-
},
|
|
212
|
-
[scrollWindowDown, scrollWindowUp]
|
|
213
|
-
);
|
|
214
|
-
|
|
215
|
-
useEffect(() => {
|
|
216
|
-
pageContainer.current?.addEventListener(Events.TOUCHMOVE, touchMove);
|
|
217
|
-
pageContainer.current?.addEventListener(Events.KEYDOWN, keyPress);
|
|
218
|
-
return () => {
|
|
219
|
-
if (pageContainer.current?.removeEventListener) {
|
|
220
|
-
pageContainer.current.removeEventListener(Events.TOUCHMOVE, touchMove);
|
|
221
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
222
|
-
pageContainer.current.removeEventListener(Events.KEYDOWN, keyPress);
|
|
223
|
-
}
|
|
224
|
-
};
|
|
225
|
-
}, [touchMove, keyPress]);
|
|
226
|
-
|
|
227
|
-
useEffect(() => {
|
|
228
|
-
isMounted = true;
|
|
229
|
-
|
|
230
|
-
checkRenderOnMount();
|
|
231
|
-
return () => {
|
|
232
|
-
isMounted = false;
|
|
233
|
-
};
|
|
234
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
235
|
-
}, []);
|
|
236
|
-
|
|
237
|
-
useEffect(() => {
|
|
238
|
-
isScrolling = false;
|
|
239
|
-
previousTouchMove = null;
|
|
240
|
-
if (prevComponentIndex !== undefined && componentIndex > prevComponentIndex) {
|
|
241
|
-
addNextComponent();
|
|
242
|
-
}
|
|
243
|
-
}, [addNextComponent, componentIndex, prevComponentIndex]);
|
|
244
|
-
|
|
245
|
-
useEffect(() => {
|
|
246
|
-
if (onChange) {
|
|
247
|
-
onChange(componentIndex);
|
|
248
|
-
}
|
|
249
|
-
}, [onChange, componentIndex]);
|
|
250
|
-
|
|
251
|
-
useEffect(() => {
|
|
252
|
-
if (!isNil(customPageNumber) && !isEqual(customPageNumber, componentIndex)) {
|
|
253
|
-
let newComponentsToRenderLength = componentsToRenderLength;
|
|
254
|
-
|
|
255
|
-
if (!isEqual(componentIndex, customPageNumber)) {
|
|
256
|
-
if (!isNil(containers[customPageNumber]) && !isScrolling) {
|
|
257
|
-
isScrolling = true;
|
|
258
|
-
pageContainer.current!.style.transform = `translate3d(0, ${customPageNumber * -100}%, 0)`;
|
|
259
|
-
|
|
260
|
-
if (isNil(containers[customPageNumber]) && !isNil(children[customPageNumber])) {
|
|
261
|
-
newComponentsToRenderLength++;
|
|
262
|
-
}
|
|
263
|
-
|
|
264
|
-
setTimeout(() => {
|
|
265
|
-
setComponentIndex(customPageNumber);
|
|
266
|
-
setComponentsToRenderLength(newComponentsToRenderLength);
|
|
267
|
-
}, animationTimer + ANIMATION_TIMER_BUFFER);
|
|
268
|
-
} else if (!isScrolling && !isNil(children[customPageNumber])) {
|
|
269
|
-
for (let i = componentsToRenderLength; i <= customPageNumber; i++) {
|
|
270
|
-
newComponentsToRenderLength++;
|
|
271
|
-
}
|
|
272
|
-
|
|
273
|
-
if (!isNil(children[customPageNumber])) {
|
|
274
|
-
newComponentsToRenderLength++;
|
|
275
|
-
}
|
|
276
|
-
|
|
277
|
-
isScrolling = true;
|
|
278
|
-
isTransitionAfterComponentsToRenderChanged = true;
|
|
279
|
-
setComponentsToRenderLength(newComponentsToRenderLength);
|
|
280
|
-
}
|
|
281
|
-
}
|
|
282
|
-
}
|
|
283
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
284
|
-
}, [customPageNumber]);
|
|
285
|
-
|
|
286
|
-
useEffect(() => {
|
|
287
|
-
if (isTransitionAfterComponentsToRenderChanged) {
|
|
288
|
-
isTransitionAfterComponentsToRenderChanged = false;
|
|
289
|
-
|
|
290
|
-
pageContainer.current!.style.transform = `translate3d(0, ${customPageNumber! * -100}%, 0)`;
|
|
291
|
-
|
|
292
|
-
setTimeout(() => {
|
|
293
|
-
setComponentIndex(customPageNumber!);
|
|
294
|
-
}, animationTimer + ANIMATION_TIMER_BUFFER);
|
|
295
|
-
}
|
|
296
|
-
}, [animationTimer, componentsToRenderLength, customPageNumber]);
|
|
297
|
-
|
|
298
|
-
return (
|
|
299
|
-
<div style={{ height, width, overflow: 'hidden' }}>
|
|
300
|
-
<div
|
|
301
|
-
ref={pageContainer}
|
|
302
|
-
onWheel={wheelScroll}
|
|
303
|
-
style={{
|
|
304
|
-
height: '100%',
|
|
305
|
-
width: '100%',
|
|
306
|
-
transition: `transform ${animationTimer}ms ${transitionTimingFunction}`,
|
|
307
|
-
outline: 'none',
|
|
308
|
-
}}
|
|
309
|
-
tabIndex={0}>
|
|
310
|
-
{setRenderComponents()}
|
|
311
|
-
</div>
|
|
312
|
-
</div>
|
|
313
|
-
);
|
|
314
|
-
}
|
|
315
|
-
|
|
316
|
-
export default withDeprecated(PageScroller, { name: 'PageScroller' });
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
/* eslint-disable jsx-a11y/control-has-associated-label */
|
|
2
|
-
import { useState } from 'react';
|
|
3
|
-
|
|
4
|
-
import Button from '../../Button';
|
|
5
|
-
import PageScroller from '..';
|
|
6
|
-
|
|
7
|
-
import FirstComponent from './FirstComponent';
|
|
8
|
-
import SecondComponent from './SecondComponent';
|
|
9
|
-
import ThirdComponent from './ThirdComponent';
|
|
10
|
-
import FourthComponent from './FourthComponent';
|
|
11
|
-
import FifthComponent from './FifthComponent';
|
|
12
|
-
|
|
13
|
-
import './index.css';
|
|
14
|
-
|
|
15
|
-
export default function FullPage() {
|
|
16
|
-
const [current, setCurrent] = useState(0);
|
|
17
|
-
|
|
18
|
-
const pageNumbers = [];
|
|
19
|
-
for (let i = 0; i < 5; i++) {
|
|
20
|
-
pageNumbers.push(
|
|
21
|
-
<Button
|
|
22
|
-
key={i}
|
|
23
|
-
variant={i === current ? 'contained' : 'outlined'}
|
|
24
|
-
size="small"
|
|
25
|
-
onClick={() => setCurrent(i)}
|
|
26
|
-
color={i === current ? 'primary' : 'secondary'}>
|
|
27
|
-
{i + 1}
|
|
28
|
-
</Button>
|
|
29
|
-
);
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
const progress = (current / (5 - 1)) * 100;
|
|
33
|
-
|
|
34
|
-
return (
|
|
35
|
-
<div className="demo-page-full">
|
|
36
|
-
<PageScroller onChange={(i) => setCurrent(i)} customPageNumber={current}>
|
|
37
|
-
<FirstComponent />
|
|
38
|
-
<SecondComponent />
|
|
39
|
-
<ThirdComponent />
|
|
40
|
-
<FourthComponent />
|
|
41
|
-
<FifthComponent />
|
|
42
|
-
</PageScroller>
|
|
43
|
-
<div
|
|
44
|
-
className="progress"
|
|
45
|
-
role="progressbar"
|
|
46
|
-
aria-valuemin="0"
|
|
47
|
-
aria-valuemax="100"
|
|
48
|
-
aria-valuenow={progress}
|
|
49
|
-
aria-valuetext={`Page Scroller Progress: ${progress}`}
|
|
50
|
-
style={{ width: `${progress}%` }}
|
|
51
|
-
/>
|
|
52
|
-
<div className="pagination-additional-class">{pageNumbers}</div>
|
|
53
|
-
</div>
|
|
54
|
-
);
|
|
55
|
-
}
|