@daimo/pay 1.6.1 → 1.6.3
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/README.md +4 -4
- package/build/index.d.ts +251 -249
- package/build/index.js +12039 -0
- package/build/index.js.map +1 -0
- package/package.json +6 -5
- package/build/package.json.js +0 -101
- package/build/package.json.js.map +0 -1
- package/build/src/assets/ScanIconWithLogos.js +0 -34
- package/build/src/assets/ScanIconWithLogos.js.map +0 -1
- package/build/src/assets/browsers.js +0 -13
- package/build/src/assets/browsers.js.map +0 -1
- package/build/src/assets/chains.js +0 -70
- package/build/src/assets/chains.js.map +0 -1
- package/build/src/assets/coins.js +0 -6
- package/build/src/assets/coins.js.map +0 -1
- package/build/src/assets/crepe.js +0 -8
- package/build/src/assets/crepe.js.map +0 -1
- package/build/src/assets/icons.js +0 -29
- package/build/src/assets/icons.js.map +0 -1
- package/build/src/assets/logos.js +0 -153
- package/build/src/assets/logos.js.map +0 -1
- package/build/src/assets/wallet.js +0 -8
- package/build/src/assets/wallet.js.map +0 -1
- package/build/src/assets/wave.js +0 -6
- package/build/src/assets/wave.js.map +0 -1
- package/build/src/components/Common/Alert/index.js +0 -10
- package/build/src/components/Common/Alert/index.js.map +0 -1
- package/build/src/components/Common/Alert/styles.js +0 -55
- package/build/src/components/Common/Alert/styles.js.map +0 -1
- package/build/src/components/Common/AmountInput/AmountInputField.js +0 -59
- package/build/src/components/Common/AmountInput/AmountInputField.js.map +0 -1
- package/build/src/components/Common/AmountInput/index.js +0 -147
- package/build/src/components/Common/AmountInput/index.js.map +0 -1
- package/build/src/components/Common/Avatar/index.js +0 -66
- package/build/src/components/Common/Avatar/index.js.map +0 -1
- package/build/src/components/Common/Avatar/styles.js +0 -59
- package/build/src/components/Common/Avatar/styles.js.map +0 -1
- package/build/src/components/Common/BrowserIcon/index.js +0 -28
- package/build/src/components/Common/BrowserIcon/index.js.map +0 -1
- package/build/src/components/Common/BrowserIcon/styles.js +0 -20
- package/build/src/components/Common/BrowserIcon/styles.js.map +0 -1
- package/build/src/components/Common/Button/index.js +0 -38
- package/build/src/components/Common/Button/index.js.map +0 -1
- package/build/src/components/Common/Button/styles.js +0 -291
- package/build/src/components/Common/Button/styles.js.map +0 -1
- package/build/src/components/Common/Chain/index.js +0 -25
- package/build/src/components/Common/Chain/index.js.map +0 -1
- package/build/src/components/Common/Chain/styles.js +0 -94
- package/build/src/components/Common/Chain/styles.js.map +0 -1
- package/build/src/components/Common/ChainSelectList/index.js +0 -107
- package/build/src/components/Common/ChainSelectList/index.js.map +0 -1
- package/build/src/components/Common/ChainSelectList/styles.js +0 -228
- package/build/src/components/Common/ChainSelectList/styles.js.map +0 -1
- package/build/src/components/Common/ConnectorList/index.js +0 -71
- package/build/src/components/Common/ConnectorList/index.js.map +0 -1
- package/build/src/components/Common/ConnectorList/styles.js +0 -314
- package/build/src/components/Common/ConnectorList/styles.js.map +0 -1
- package/build/src/components/Common/CopyToClipboard/CopyToClipboardIcon.js +0 -71
- package/build/src/components/Common/CopyToClipboard/CopyToClipboardIcon.js.map +0 -1
- package/build/src/components/Common/CopyToClipboard/index.js +0 -51
- package/build/src/components/Common/CopyToClipboard/index.js.map +0 -1
- package/build/src/components/Common/CustomQRCode/QRCode.js +0 -69
- package/build/src/components/Common/CustomQRCode/QRCode.js.map +0 -1
- package/build/src/components/Common/CustomQRCode/index.js +0 -22
- package/build/src/components/Common/CustomQRCode/index.js.map +0 -1
- package/build/src/components/Common/CustomQRCode/styles.js +0 -155
- package/build/src/components/Common/CustomQRCode/styles.js.map +0 -1
- package/build/src/components/Common/FitText/index.js +0 -27
- package/build/src/components/Common/FitText/index.js.map +0 -1
- package/build/src/components/Common/Modal/index.js +0 -301
- package/build/src/components/Common/Modal/index.js.map +0 -1
- package/build/src/components/Common/Modal/styles.js +0 -661
- package/build/src/components/Common/Modal/styles.js.map +0 -1
- package/build/src/components/Common/OptionsList/index.js +0 -106
- package/build/src/components/Common/OptionsList/index.js.map +0 -1
- package/build/src/components/Common/OptionsList/styles.js +0 -165
- package/build/src/components/Common/OptionsList/styles.js.map +0 -1
- package/build/src/components/Common/OrderHeader/index.js +0 -128
- package/build/src/components/Common/OrderHeader/index.js.map +0 -1
- package/build/src/components/Common/PaymentBreakdown/index.js +0 -48
- package/build/src/components/Common/PaymentBreakdown/index.js.map +0 -1
- package/build/src/components/Common/Portal/index.js +0 -31
- package/build/src/components/Common/Portal/index.js.map +0 -1
- package/build/src/components/Common/PoweredByFooter/index.js +0 -79
- package/build/src/components/Common/PoweredByFooter/index.js.map +0 -1
- package/build/src/components/Common/ScrollArea/index.js +0 -62
- package/build/src/components/Common/ScrollArea/index.js.map +0 -1
- package/build/src/components/Common/ScrollArea/styles.js +0 -168
- package/build/src/components/Common/ScrollArea/styles.js.map +0 -1
- package/build/src/components/Common/Spinner/index.js +0 -24
- package/build/src/components/Common/Spinner/index.js.map +0 -1
- package/build/src/components/Common/Spinner/styles.js +0 -22
- package/build/src/components/Common/Spinner/styles.js.map +0 -1
- package/build/src/components/Common/SwitchButton/index.js +0 -39
- package/build/src/components/Common/SwitchButton/index.js.map +0 -1
- package/build/src/components/Common/ThemedButton/index.js +0 -25
- package/build/src/components/Common/ThemedButton/index.js.map +0 -1
- package/build/src/components/Common/ThemedButton/styles.js +0 -152
- package/build/src/components/Common/ThemedButton/styles.js.map +0 -1
- package/build/src/components/Common/TokenChainLogo/index.js +0 -24
- package/build/src/components/Common/TokenChainLogo/index.js.map +0 -1
- package/build/src/components/Common/Tooltip/index.js +0 -97
- package/build/src/components/Common/Tooltip/index.js.map +0 -1
- package/build/src/components/Common/Tooltip/styles.js +0 -81
- package/build/src/components/Common/Tooltip/styles.js.map +0 -1
- package/build/src/components/Common/WalletChainLogo/index.js +0 -24
- package/build/src/components/Common/WalletChainLogo/index.js.map +0 -1
- package/build/src/components/DaimoPay.js +0 -280
- package/build/src/components/DaimoPay.js.map +0 -1
- package/build/src/components/DaimoPayButton/index.js +0 -158
- package/build/src/components/DaimoPayButton/index.js.map +0 -1
- package/build/src/components/DaimoPayButton/styles.js +0 -50
- package/build/src/components/DaimoPayButton/styles.js.map +0 -1
- package/build/src/components/DaimoPayModal/ConnectUsing.js +0 -45
- package/build/src/components/DaimoPayModal/ConnectUsing.js.map +0 -1
- package/build/src/components/DaimoPayModal/ConnectWithInjector/index.js +0 -202
- package/build/src/components/DaimoPayModal/ConnectWithInjector/index.js.map +0 -1
- package/build/src/components/DaimoPayModal/ConnectWithInjector/styles.js +0 -133
- package/build/src/components/DaimoPayModal/ConnectWithInjector/styles.js.map +0 -1
- package/build/src/components/DaimoPayModal/ConnectWithQRCode.js +0 -75
- package/build/src/components/DaimoPayModal/ConnectWithQRCode.js.map +0 -1
- package/build/src/components/DaimoPayModal/index.js +0 -206
- package/build/src/components/DaimoPayModal/index.js.map +0 -1
- package/build/src/components/DaimoPayThemeProvider/DaimoPayThemeProvider.js +0 -21
- package/build/src/components/DaimoPayThemeProvider/DaimoPayThemeProvider.js.map +0 -1
- package/build/src/components/Pages/About/graphics.js +0 -187
- package/build/src/components/Pages/About/graphics.js.map +0 -1
- package/build/src/components/Pages/About/index.js +0 -131
- package/build/src/components/Pages/About/index.js.map +0 -1
- package/build/src/components/Pages/About/styles.js +0 -144
- package/build/src/components/Pages/About/styles.js.map +0 -1
- package/build/src/components/Pages/Confirmation/index.js +0 -105
- package/build/src/components/Pages/Confirmation/index.js.map +0 -1
- package/build/src/components/Pages/Connectors/index.js +0 -20
- package/build/src/components/Pages/Connectors/index.js.map +0 -1
- package/build/src/components/Pages/Connectors/styles.js +0 -267
- package/build/src/components/Pages/Connectors/styles.js.map +0 -1
- package/build/src/components/Pages/DownloadApp/index.js +0 -30
- package/build/src/components/Pages/DownloadApp/index.js.map +0 -1
- package/build/src/components/Pages/MobileConnectors/index.js +0 -78
- package/build/src/components/Pages/MobileConnectors/index.js.map +0 -1
- package/build/src/components/Pages/MobileConnectors/styles.js +0 -65
- package/build/src/components/Pages/MobileConnectors/styles.js.map +0 -1
- package/build/src/components/Pages/Onboarding/index.js +0 -18
- package/build/src/components/Pages/Onboarding/index.js.map +0 -1
- package/build/src/components/Pages/Onboarding/styles.js +0 -229
- package/build/src/components/Pages/Onboarding/styles.js.map +0 -1
- package/build/src/components/Pages/PayWithToken/index.js +0 -111
- package/build/src/components/Pages/PayWithToken/index.js.map +0 -1
- package/build/src/components/Pages/SelectAmount/index.js +0 -16
- package/build/src/components/Pages/SelectAmount/index.js.map +0 -1
- package/build/src/components/Pages/SelectDepositAddressAmount/index.js +0 -61
- package/build/src/components/Pages/SelectDepositAddressAmount/index.js.map +0 -1
- package/build/src/components/Pages/SelectDepositAddressChain/index.js +0 -38
- package/build/src/components/Pages/SelectDepositAddressChain/index.js.map +0 -1
- package/build/src/components/Pages/SelectExternalAmount/index.js +0 -63
- package/build/src/components/Pages/SelectExternalAmount/index.js.map +0 -1
- package/build/src/components/Pages/SelectMethod/index.js +0 -205
- package/build/src/components/Pages/SelectMethod/index.js.map +0 -1
- package/build/src/components/Pages/SelectToken/index.js +0 -61
- package/build/src/components/Pages/SelectToken/index.js.map +0 -1
- package/build/src/components/Pages/Solana/ConnectSolana/index.js +0 -80
- package/build/src/components/Pages/Solana/ConnectSolana/index.js.map +0 -1
- package/build/src/components/Pages/Solana/ConnectorSolana/index.js +0 -55
- package/build/src/components/Pages/Solana/ConnectorSolana/index.js.map +0 -1
- package/build/src/components/Pages/Solana/PayWithSolanaToken/index.js +0 -62
- package/build/src/components/Pages/Solana/PayWithSolanaToken/index.js.map +0 -1
- package/build/src/components/Pages/Solana/SelectSolanaAmount/index.js +0 -16
- package/build/src/components/Pages/Solana/SelectSolanaAmount/index.js.map +0 -1
- package/build/src/components/Pages/Solana/SelectSolanaToken/index.js +0 -59
- package/build/src/components/Pages/Solana/SelectSolanaToken/index.js.map +0 -1
- package/build/src/components/Pages/SwitchNetworks/index.js +0 -26
- package/build/src/components/Pages/SwitchNetworks/index.js.map +0 -1
- package/build/src/components/Pages/WaitingDepositAddress/index.js +0 -51
- package/build/src/components/Pages/WaitingDepositAddress/index.js.map +0 -1
- package/build/src/components/Pages/WaitingExternal/index.js +0 -53
- package/build/src/components/Pages/WaitingExternal/index.js.map +0 -1
- package/build/src/components/Spinners/CircleSpinner/index.js +0 -15
- package/build/src/components/Spinners/CircleSpinner/index.js.map +0 -1
- package/build/src/components/Spinners/CircleSpinner/styles.js +0 -118
- package/build/src/components/Spinners/CircleSpinner/styles.js.map +0 -1
- package/build/src/components/Spinners/ExternalPaymentSpinner/index.js +0 -20
- package/build/src/components/Spinners/ExternalPaymentSpinner/index.js.map +0 -1
- package/build/src/components/Spinners/SquircleSpinner/index.js +0 -15
- package/build/src/components/Spinners/SquircleSpinner/index.js.map +0 -1
- package/build/src/components/Spinners/SquircleSpinner/styles.js +0 -66
- package/build/src/components/Spinners/SquircleSpinner/styles.js.map +0 -1
- package/build/src/components/Spinners/TokenLogoSpinner/index.js +0 -13
- package/build/src/components/Spinners/TokenLogoSpinner/index.js.map +0 -1
- package/build/src/components/Spinners/TokenLogoSpinner/styles.js +0 -40
- package/build/src/components/Spinners/TokenLogoSpinner/styles.js.map +0 -1
- package/build/src/components/Spinners/styles.js +0 -33
- package/build/src/components/Spinners/styles.js.map +0 -1
- package/build/src/components/contexts/solana/index.js +0 -11
- package/build/src/components/contexts/solana/index.js.map +0 -1
- package/build/src/components/contexts/web3/index.js +0 -46
- package/build/src/components/contexts/web3/index.js.map +0 -1
- package/build/src/constants/defaultTheme.js +0 -6
- package/build/src/constants/defaultTheme.js.map +0 -1
- package/build/src/defaultConfig.js +0 -63
- package/build/src/defaultConfig.js.map +0 -1
- package/build/src/defaultConnectors.js +0 -43
- package/build/src/defaultConnectors.js.map +0 -1
- package/build/src/hooks/connectors/useWalletConnectUri.js +0 -93
- package/build/src/hooks/connectors/useWalletConnectUri.js.map +0 -1
- package/build/src/hooks/useChainIsSupported.js +0 -12
- package/build/src/hooks/useChainIsSupported.js.map +0 -1
- package/build/src/hooks/useChains.js +0 -11
- package/build/src/hooks/useChains.js.map +0 -1
- package/build/src/hooks/useConnect.js +0 -45
- package/build/src/hooks/useConnect.js.map +0 -1
- package/build/src/hooks/useConnectCallback.js +0 -18
- package/build/src/hooks/useConnectCallback.js.map +0 -1
- package/build/src/hooks/useConnectors.js +0 -29
- package/build/src/hooks/useConnectors.js.map +0 -1
- package/build/src/hooks/useDaimoPayStatus.js +0 -24
- package/build/src/hooks/useDaimoPayStatus.js.map +0 -1
- package/build/src/hooks/useDepositAddressOptions.js +0 -31
- package/build/src/hooks/useDepositAddressOptions.js.map +0 -1
- package/build/src/hooks/useEnsFallbackConfig.js +0 -16
- package/build/src/hooks/useEnsFallbackConfig.js.map +0 -1
- package/build/src/hooks/useExternalPaymentOptions.js +0 -49
- package/build/src/hooks/useExternalPaymentOptions.js.map +0 -1
- package/build/src/hooks/useFitText.js +0 -148
- package/build/src/hooks/useFitText.js.map +0 -1
- package/build/src/hooks/useFocusTrap.js +0 -60
- package/build/src/hooks/useFocusTrap.js.map +0 -1
- package/build/src/hooks/useGoogleFont.js +0 -45
- package/build/src/hooks/useGoogleFont.js.map +0 -1
- package/build/src/hooks/useIsMobile.js +0 -17
- package/build/src/hooks/useIsMobile.js.map +0 -1
- package/build/src/hooks/useIsMounted.js +0 -12
- package/build/src/hooks/useIsMounted.js.map +0 -1
- package/build/src/hooks/useLastConnector.js +0 -24
- package/build/src/hooks/useLastConnector.js.map +0 -1
- package/build/src/hooks/useLocales.js +0 -67
- package/build/src/hooks/useLocales.js.map +0 -1
- package/build/src/hooks/useLockBodyScroll.js +0 -53
- package/build/src/hooks/useLockBodyScroll.js.map +0 -1
- package/build/src/hooks/useOrderUsdLimits.js +0 -26
- package/build/src/hooks/useOrderUsdLimits.js.map +0 -1
- package/build/src/hooks/usePayWithSolanaToken.js +0 -50
- package/build/src/hooks/usePayWithSolanaToken.js.map +0 -1
- package/build/src/hooks/usePayWithToken.js +0 -58
- package/build/src/hooks/usePayWithToken.js.map +0 -1
- package/build/src/hooks/usePaymentState.js +0 -283
- package/build/src/hooks/usePaymentState.js.map +0 -1
- package/build/src/hooks/usePrevious.js +0 -14
- package/build/src/hooks/usePrevious.js.map +0 -1
- package/build/src/hooks/useSolanaPaymentOptions.js +0 -39
- package/build/src/hooks/useSolanaPaymentOptions.js.map +0 -1
- package/build/src/hooks/useWalletConnectModal.js +0 -52
- package/build/src/hooks/useWalletConnectModal.js.map +0 -1
- package/build/src/hooks/useWalletPaymentOptions.js +0 -50
- package/build/src/hooks/useWalletPaymentOptions.js.map +0 -1
- package/build/src/hooks/useWindowSize.js +0 -23
- package/build/src/hooks/useWindowSize.js.map +0 -1
- package/build/src/index.js +0 -10
- package/build/src/index.js.map +0 -1
- package/build/src/localizations/index.js +0 -57
- package/build/src/localizations/index.js.map +0 -1
- package/build/src/localizations/locales/ar-AE.js +0 -97
- package/build/src/localizations/locales/ar-AE.js.map +0 -1
- package/build/src/localizations/locales/ca-AD.js +0 -95
- package/build/src/localizations/locales/ca-AD.js.map +0 -1
- package/build/src/localizations/locales/ee-EE.js +0 -95
- package/build/src/localizations/locales/ee-EE.js.map +0 -1
- package/build/src/localizations/locales/en-US.js +0 -95
- package/build/src/localizations/locales/en-US.js.map +0 -1
- package/build/src/localizations/locales/es-ES.js +0 -95
- package/build/src/localizations/locales/es-ES.js.map +0 -1
- package/build/src/localizations/locales/fa-IR.js +0 -95
- package/build/src/localizations/locales/fa-IR.js.map +0 -1
- package/build/src/localizations/locales/fr-FR.js +0 -95
- package/build/src/localizations/locales/fr-FR.js.map +0 -1
- package/build/src/localizations/locales/ja-JP.js +0 -95
- package/build/src/localizations/locales/ja-JP.js.map +0 -1
- package/build/src/localizations/locales/pt-BR.js +0 -95
- package/build/src/localizations/locales/pt-BR.js.map +0 -1
- package/build/src/localizations/locales/ru-RU.js +0 -95
- package/build/src/localizations/locales/ru-RU.js.map +0 -1
- package/build/src/localizations/locales/tr-TR.js +0 -95
- package/build/src/localizations/locales/tr-TR.js.map +0 -1
- package/build/src/localizations/locales/vi-VN.js +0 -95
- package/build/src/localizations/locales/vi-VN.js.map +0 -1
- package/build/src/localizations/locales/zh-CN.js +0 -95
- package/build/src/localizations/locales/zh-CN.js.map +0 -1
- package/build/src/styles/defaultTheme.js +0 -89
- package/build/src/styles/defaultTheme.js.map +0 -1
- package/build/src/styles/index.js +0 -329
- package/build/src/styles/index.js.map +0 -1
- package/build/src/styles/styled/index.js +0 -16
- package/build/src/styles/styled/index.js.map +0 -1
- package/build/src/styles/themes/base.js +0 -141
- package/build/src/styles/themes/base.js.map +0 -1
- package/build/src/styles/themes/index.js +0 -13
- package/build/src/styles/themes/index.js.map +0 -1
- package/build/src/styles/themes/midnight.js +0 -76
- package/build/src/styles/themes/midnight.js.map +0 -1
- package/build/src/styles/themes/minimal.js +0 -96
- package/build/src/styles/themes/minimal.js.map +0 -1
- package/build/src/styles/themes/nouns.js +0 -81
- package/build/src/styles/themes/nouns.js.map +0 -1
- package/build/src/styles/themes/retro.js +0 -106
- package/build/src/styles/themes/retro.js.map +0 -1
- package/build/src/styles/themes/rounded.js +0 -106
- package/build/src/styles/themes/rounded.js.map +0 -1
- package/build/src/styles/themes/soft.js +0 -71
- package/build/src/styles/themes/soft.js.map +0 -1
- package/build/src/styles/themes/web95.js +0 -132
- package/build/src/styles/themes/web95.js.map +0 -1
- package/build/src/utils/exports.js +0 -7
- package/build/src/utils/exports.js.map +0 -1
- package/build/src/utils/format.js +0 -83
- package/build/src/utils/format.js.map +0 -1
- package/build/src/utils/index.js +0 -39
- package/build/src/utils/index.js.map +0 -1
- package/build/src/utils/p3.js +0 -16
- package/build/src/utils/p3.js.map +0 -1
- package/build/src/utils/platform.js +0 -13
- package/build/src/utils/platform.js.map +0 -1
- package/build/src/utils/supportUrl.js +0 -18
- package/build/src/utils/supportUrl.js.map +0 -1
- package/build/src/utils/trpc.js +0 -19
- package/build/src/utils/trpc.js.map +0 -1
- package/build/src/utils/validateInput.js +0 -36
- package/build/src/utils/validateInput.js.map +0 -1
- package/build/src/utils/wallets.js +0 -14
- package/build/src/utils/wallets.js.map +0 -1
- package/build/src/wallets/index.js +0 -32
- package/build/src/wallets/index.js.map +0 -1
- package/build/src/wallets/useWallets.js +0 -90
- package/build/src/wallets/useWallets.js.map +0 -1
- package/build/src/wallets/walletConfigs.js +0 -337
- package/build/src/wallets/walletConfigs.js.map +0 -1
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
import { useState, useEffect } from 'react';
|
|
2
|
-
import { useAccount } from 'wagmi';
|
|
3
|
-
import { usePayContext } from '../../components/DaimoPay.js';
|
|
4
|
-
import { useConnect } from '../useConnect.js';
|
|
5
|
-
import { useWalletConnectConnector } from '../useConnectors.js';
|
|
6
|
-
|
|
7
|
-
function useWalletConnectUri({ enabled } = {
|
|
8
|
-
enabled: true,
|
|
9
|
-
}) {
|
|
10
|
-
const { log } = usePayContext();
|
|
11
|
-
const [uri, setUri] = useState(undefined);
|
|
12
|
-
const connector = useWalletConnectConnector();
|
|
13
|
-
const { isConnected } = useAccount();
|
|
14
|
-
const { connectAsync } = useConnect();
|
|
15
|
-
useEffect(() => {
|
|
16
|
-
if (!enabled)
|
|
17
|
-
return;
|
|
18
|
-
async function handleMessage(message) {
|
|
19
|
-
const { type, data } = message;
|
|
20
|
-
log("WC Message", type, data);
|
|
21
|
-
if (type === "display_uri") {
|
|
22
|
-
setUri(data);
|
|
23
|
-
}
|
|
24
|
-
/*
|
|
25
|
-
// This has the URI as well, but we're probably better off using the one in the display_uri event
|
|
26
|
-
if (type === 'connecting') {
|
|
27
|
-
const p = await connector.getProvider();
|
|
28
|
-
const uri = p.signer.uri;
|
|
29
|
-
setConnectorUri(uri);
|
|
30
|
-
}
|
|
31
|
-
*/
|
|
32
|
-
}
|
|
33
|
-
async function handleDisconnect() {
|
|
34
|
-
log("WC Disconnect");
|
|
35
|
-
if (connector)
|
|
36
|
-
connectWallet(connector);
|
|
37
|
-
}
|
|
38
|
-
async function connectWallet(connector) {
|
|
39
|
-
const result = await connectAsync({ connector });
|
|
40
|
-
if (result)
|
|
41
|
-
return result;
|
|
42
|
-
return false;
|
|
43
|
-
}
|
|
44
|
-
async function connectWalletConnect(connector) {
|
|
45
|
-
try {
|
|
46
|
-
await connectWallet(connector);
|
|
47
|
-
}
|
|
48
|
-
catch (error) {
|
|
49
|
-
log("catch error");
|
|
50
|
-
log(error);
|
|
51
|
-
if (error.code) {
|
|
52
|
-
switch (error.code) {
|
|
53
|
-
case 4001:
|
|
54
|
-
log("error.code - User rejected");
|
|
55
|
-
connectWalletConnect(connector); // Regenerate QR code
|
|
56
|
-
break;
|
|
57
|
-
default:
|
|
58
|
-
log("error.code - Unknown Error");
|
|
59
|
-
break;
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
else {
|
|
63
|
-
// Sometimes the error doesn't respond with a code
|
|
64
|
-
log("WalletConnect cannot connect.", error);
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
if (isConnected) {
|
|
69
|
-
setUri(undefined);
|
|
70
|
-
}
|
|
71
|
-
else {
|
|
72
|
-
if (!connector || uri)
|
|
73
|
-
return;
|
|
74
|
-
if (connector && !isConnected) {
|
|
75
|
-
connectWalletConnect(connector);
|
|
76
|
-
log("add wc listeners");
|
|
77
|
-
connector.emitter.on("message", handleMessage);
|
|
78
|
-
connector.emitter.on("disconnect", handleDisconnect);
|
|
79
|
-
return () => {
|
|
80
|
-
log("remove wc listeners");
|
|
81
|
-
connector.emitter.off("message", handleMessage);
|
|
82
|
-
connector.emitter.off("disconnect", handleDisconnect);
|
|
83
|
-
};
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
}, [enabled, connector, isConnected]);
|
|
87
|
-
return {
|
|
88
|
-
uri,
|
|
89
|
-
};
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
export { useWalletConnectUri };
|
|
93
|
-
//# sourceMappingURL=useWalletConnectUri.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useWalletConnectUri.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { useConfig } from 'wagmi';
|
|
2
|
-
|
|
3
|
-
/** Determines whether the current wagmi configuration supports a given chain. */
|
|
4
|
-
function useChainIsSupported(chainId) {
|
|
5
|
-
const { chains } = useConfig();
|
|
6
|
-
if (!chainId)
|
|
7
|
-
return false;
|
|
8
|
-
return chains.some((x) => x.id === chainId);
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
export { useChainIsSupported };
|
|
12
|
-
//# sourceMappingURL=useChainIsSupported.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useChainIsSupported.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;"}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { useConfig } from 'wagmi';
|
|
2
|
-
|
|
3
|
-
/** Returns currently configured wagmi chains. */
|
|
4
|
-
function useChains() {
|
|
5
|
-
const wagmi = useConfig();
|
|
6
|
-
const chains = wagmi?.chains ?? [];
|
|
7
|
-
return chains.map((c) => c);
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
export { useChains };
|
|
11
|
-
//# sourceMappingURL=useChains.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useChains.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;"}
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import { useConnect as useConnect$1 } from 'wagmi';
|
|
2
|
-
import { usePayContext } from '../components/DaimoPay.js';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* This is a wrapper around wagmi's useConnect hook that adds some
|
|
6
|
-
* additional functionality.
|
|
7
|
-
*/
|
|
8
|
-
function useConnect({ ...props } = {}) {
|
|
9
|
-
const context = usePayContext();
|
|
10
|
-
const { connect, connectAsync, connectors, ...rest } = useConnect$1({
|
|
11
|
-
...props,
|
|
12
|
-
mutation: {
|
|
13
|
-
...props.mutation,
|
|
14
|
-
onError(err) {
|
|
15
|
-
if (err.message) {
|
|
16
|
-
if (err.message !== "User rejected request") {
|
|
17
|
-
context.log(err.message, err);
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
else {
|
|
21
|
-
context.log(`Could not connect.`, err);
|
|
22
|
-
}
|
|
23
|
-
},
|
|
24
|
-
},
|
|
25
|
-
});
|
|
26
|
-
return {
|
|
27
|
-
connect: ({ connector, chainId, mutation, }) => {
|
|
28
|
-
return connect({
|
|
29
|
-
connector,
|
|
30
|
-
chainId: chainId ?? context.options?.initialChainId,
|
|
31
|
-
}, mutation);
|
|
32
|
-
},
|
|
33
|
-
connectAsync: async ({ connector, chainId, mutation, }) => {
|
|
34
|
-
return connectAsync({
|
|
35
|
-
connector,
|
|
36
|
-
chainId: chainId ?? context.options?.initialChainId,
|
|
37
|
-
}, mutation);
|
|
38
|
-
},
|
|
39
|
-
connectors,
|
|
40
|
-
...rest,
|
|
41
|
-
};
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
export { useConnect };
|
|
45
|
-
//# sourceMappingURL=useConnect.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useConnect.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { useAccountEffect } from 'wagmi';
|
|
2
|
-
|
|
3
|
-
const useConnectCallback = ({ onConnect, onDisconnect, }) => {
|
|
4
|
-
useAccountEffect({
|
|
5
|
-
onConnect: ({ address, connector, isReconnected }) => {
|
|
6
|
-
if (!isReconnected) {
|
|
7
|
-
onConnect?.({
|
|
8
|
-
address: address,
|
|
9
|
-
connectorId: connector?.id,
|
|
10
|
-
});
|
|
11
|
-
}
|
|
12
|
-
},
|
|
13
|
-
onDisconnect: () => onDisconnect?.(),
|
|
14
|
-
});
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
export { useConnectCallback };
|
|
18
|
-
//# sourceMappingURL=useConnectCallback.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useConnectCallback.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;"}
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { useConnectors as useConnectors$1 } from 'wagmi';
|
|
2
|
-
|
|
3
|
-
function useConnectors() {
|
|
4
|
-
const connectors = useConnectors$1();
|
|
5
|
-
return connectors ?? [];
|
|
6
|
-
}
|
|
7
|
-
function useConnector(id, uuid) {
|
|
8
|
-
const connectors = useConnectors();
|
|
9
|
-
if (id === "injected" && uuid) {
|
|
10
|
-
return connectors.find((c) => c.id === id && c.name === uuid);
|
|
11
|
-
}
|
|
12
|
-
else if (id === "injected") {
|
|
13
|
-
return connectors.find((c) => c.id === id && c.name.includes("Injected"));
|
|
14
|
-
}
|
|
15
|
-
return connectors.find((c) => c.id === id);
|
|
16
|
-
}
|
|
17
|
-
function useWalletConnectConnector() {
|
|
18
|
-
/*
|
|
19
|
-
options: {
|
|
20
|
-
qrcode: false,
|
|
21
|
-
// or
|
|
22
|
-
showQrModal: false,
|
|
23
|
-
}
|
|
24
|
-
*/
|
|
25
|
-
return useConnector("walletConnect");
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
export { useConnector, useConnectors, useWalletConnectConnector };
|
|
29
|
-
//# sourceMappingURL=useConnectors.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useConnectors.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { writeDaimoPayOrderID } from '@daimo/pay-common';
|
|
2
|
-
import { usePayContext } from '../components/DaimoPay.js';
|
|
3
|
-
|
|
4
|
-
/** Returns the current payment, or undefined if there is none.
|
|
5
|
-
*
|
|
6
|
-
* Status values:
|
|
7
|
-
* - `payment_unpaid` - the user has not paid yet
|
|
8
|
-
* - `payment_started` - the user has paid & payment is in progress. This status
|
|
9
|
-
* typically lasts a few seconds.
|
|
10
|
-
* - `payment_completed` - the final call or transfer succeeded
|
|
11
|
-
* - `payment_bounced` - the final call or transfer reverted. Funds were sent
|
|
12
|
-
* to the payment's configured refund address on the destination chain.
|
|
13
|
-
*/
|
|
14
|
-
function useDaimoPayStatus() {
|
|
15
|
-
const { paymentState } = usePayContext();
|
|
16
|
-
if (!paymentState || !paymentState.daimoPayOrder)
|
|
17
|
-
return undefined;
|
|
18
|
-
const order = paymentState.daimoPayOrder;
|
|
19
|
-
const paymentId = writeDaimoPayOrderID(order.id);
|
|
20
|
-
return { paymentId, status: order.intentStatus };
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
export { useDaimoPayStatus };
|
|
24
|
-
//# sourceMappingURL=useDaimoPayStatus.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useDaimoPayStatus.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { useState, useEffect } from 'react';
|
|
2
|
-
|
|
3
|
-
function useDepositAddressOptions({ trpc, usdRequired, mode, }) {
|
|
4
|
-
const [options, setOptions] = useState([]);
|
|
5
|
-
const [loading, setLoading] = useState(false);
|
|
6
|
-
useEffect(() => {
|
|
7
|
-
const refreshDepositAddressOptions = async (usd, mode) => {
|
|
8
|
-
setLoading(true);
|
|
9
|
-
try {
|
|
10
|
-
const options = await trpc.getDepositAddressOptions.query({
|
|
11
|
-
usdRequired: usd,
|
|
12
|
-
mode,
|
|
13
|
-
});
|
|
14
|
-
setOptions(options);
|
|
15
|
-
}
|
|
16
|
-
catch (e) {
|
|
17
|
-
console.error(e);
|
|
18
|
-
}
|
|
19
|
-
finally {
|
|
20
|
-
setLoading(false);
|
|
21
|
-
}
|
|
22
|
-
};
|
|
23
|
-
if (usdRequired != null && mode != null) {
|
|
24
|
-
refreshDepositAddressOptions(usdRequired, mode);
|
|
25
|
-
}
|
|
26
|
-
}, [usdRequired, mode]);
|
|
27
|
-
return { options, loading };
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
export { useDepositAddressOptions };
|
|
31
|
-
//# sourceMappingURL=useDepositAddressOptions.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useDepositAddressOptions.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { createConfig, http } from 'wagmi';
|
|
2
|
-
import { mainnet } from 'wagmi/chains';
|
|
3
|
-
import { useChainIsSupported } from './useChainIsSupported.js';
|
|
4
|
-
|
|
5
|
-
const ensFallbackConfig = createConfig({
|
|
6
|
-
chains: [mainnet],
|
|
7
|
-
transports: {
|
|
8
|
-
[mainnet.id]: http(),
|
|
9
|
-
},
|
|
10
|
-
});
|
|
11
|
-
function useEnsFallbackConfig() {
|
|
12
|
-
return !useChainIsSupported(1) ? ensFallbackConfig : undefined;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
export { useEnsFallbackConfig };
|
|
16
|
-
//# sourceMappingURL=useEnsFallbackConfig.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useEnsFallbackConfig.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;"}
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import { ExternalPaymentOptions } from '@daimo/pay-common';
|
|
2
|
-
import { useState, useEffect } from 'react';
|
|
3
|
-
|
|
4
|
-
const DEFAULT_EXTERNAL_PAYMENT_OPTIONS = [
|
|
5
|
-
ExternalPaymentOptions.Coinbase,
|
|
6
|
-
ExternalPaymentOptions.Binance,
|
|
7
|
-
ExternalPaymentOptions.Daimo,
|
|
8
|
-
ExternalPaymentOptions.RampNetwork,
|
|
9
|
-
ExternalPaymentOptions.Lemon,
|
|
10
|
-
// Solana and ExternalChains are handled in the SelectMethod component.
|
|
11
|
-
];
|
|
12
|
-
function useExternalPaymentOptions({ trpc, filterIds, platform, usdRequired, mode, }) {
|
|
13
|
-
const [options, setOptions] = useState([]);
|
|
14
|
-
const [loading, setLoading] = useState(false);
|
|
15
|
-
useEffect(() => {
|
|
16
|
-
const refreshExternalPaymentOptions = async (usd, mode) => {
|
|
17
|
-
if (!platform)
|
|
18
|
-
return;
|
|
19
|
-
setLoading(true);
|
|
20
|
-
try {
|
|
21
|
-
const newOptions = await trpc.getExternalPaymentOptions.query({
|
|
22
|
-
platform,
|
|
23
|
-
mode,
|
|
24
|
-
usdRequired: usd,
|
|
25
|
-
});
|
|
26
|
-
// Filter out options not in options JSON
|
|
27
|
-
const enabledExtPaymentOptions = filterIds || DEFAULT_EXTERNAL_PAYMENT_OPTIONS;
|
|
28
|
-
const filteredOptions = newOptions.filter((option) => enabledExtPaymentOptions.includes(option.id));
|
|
29
|
-
setOptions(filteredOptions);
|
|
30
|
-
}
|
|
31
|
-
catch (error) {
|
|
32
|
-
console.error(error);
|
|
33
|
-
}
|
|
34
|
-
finally {
|
|
35
|
-
setLoading(false);
|
|
36
|
-
}
|
|
37
|
-
};
|
|
38
|
-
if (usdRequired != null && mode != null) {
|
|
39
|
-
refreshExternalPaymentOptions(usdRequired, mode);
|
|
40
|
-
}
|
|
41
|
-
}, [usdRequired, filterIds, platform, mode]);
|
|
42
|
-
return {
|
|
43
|
-
options,
|
|
44
|
-
loading,
|
|
45
|
-
};
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
export { useExternalPaymentOptions };
|
|
49
|
-
//# sourceMappingURL=useExternalPaymentOptions.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useExternalPaymentOptions.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -1,148 +0,0 @@
|
|
|
1
|
-
import { useCallback, useRef, useState, useEffect, useLayoutEffect } from 'react';
|
|
2
|
-
import ResizeObserver from 'resize-observer-polyfill';
|
|
3
|
-
|
|
4
|
-
// https://github.com/saltycrane/use-fit-text
|
|
5
|
-
const LOG_LEVEL = {
|
|
6
|
-
debug: 10,
|
|
7
|
-
info: 20,
|
|
8
|
-
warn: 30,
|
|
9
|
-
error: 40,
|
|
10
|
-
none: 100,
|
|
11
|
-
};
|
|
12
|
-
// Suppress `useLayoutEffect` warning when rendering on the server
|
|
13
|
-
// https://gist.github.com/gaearon/e7d97cdf38a2907924ea12e4ebdf3c85
|
|
14
|
-
const useIsoLayoutEffect = typeof window !== "undefined" &&
|
|
15
|
-
window.document &&
|
|
16
|
-
window.document.createElement !== undefined
|
|
17
|
-
? useLayoutEffect
|
|
18
|
-
: useEffect;
|
|
19
|
-
const useFitText = ({ logLevel: logLevelOption = "info", maxFontSize = 100, minFontSize = 20, onFinish, onStart, resolution = 5, } = {}) => {
|
|
20
|
-
const logLevel = LOG_LEVEL[logLevelOption];
|
|
21
|
-
const initState = useCallback(() => {
|
|
22
|
-
return {
|
|
23
|
-
calcKey: 0,
|
|
24
|
-
fontSize: maxFontSize,
|
|
25
|
-
fontSizePrev: minFontSize,
|
|
26
|
-
fontSizeMax: maxFontSize,
|
|
27
|
-
fontSizeMin: minFontSize,
|
|
28
|
-
};
|
|
29
|
-
}, [maxFontSize, minFontSize]);
|
|
30
|
-
const ref = useRef(null);
|
|
31
|
-
const innerHtmlPrevRef = useRef();
|
|
32
|
-
const isCalculatingRef = useRef(false);
|
|
33
|
-
const [state, setState] = useState(initState);
|
|
34
|
-
const { calcKey, fontSize, fontSizeMax, fontSizeMin, fontSizePrev } = state;
|
|
35
|
-
// Montior div size changes and recalculate on resize
|
|
36
|
-
let animationFrameId = null;
|
|
37
|
-
const [ro] = useState(() => new ResizeObserver(() => {
|
|
38
|
-
animationFrameId = window.requestAnimationFrame(() => {
|
|
39
|
-
if (isCalculatingRef.current) {
|
|
40
|
-
return;
|
|
41
|
-
}
|
|
42
|
-
onStart && onStart();
|
|
43
|
-
isCalculatingRef.current = true;
|
|
44
|
-
// `calcKey` is used in the dependencies array of
|
|
45
|
-
// `useIsoLayoutEffect` below. It is incremented so that the font size
|
|
46
|
-
// will be recalculated even if the previous state didn't change (e.g.
|
|
47
|
-
// when the text fit initially).
|
|
48
|
-
setState({
|
|
49
|
-
...initState(),
|
|
50
|
-
calcKey: calcKey + 1,
|
|
51
|
-
});
|
|
52
|
-
});
|
|
53
|
-
}));
|
|
54
|
-
useEffect(() => {
|
|
55
|
-
if (ref.current) {
|
|
56
|
-
ro.observe(ref.current);
|
|
57
|
-
}
|
|
58
|
-
return () => {
|
|
59
|
-
animationFrameId && window.cancelAnimationFrame(animationFrameId);
|
|
60
|
-
ro.disconnect();
|
|
61
|
-
};
|
|
62
|
-
}, [animationFrameId, ro]);
|
|
63
|
-
// Recalculate when the div contents change
|
|
64
|
-
const innerHtml = ref.current && ref.current.innerHTML;
|
|
65
|
-
useEffect(() => {
|
|
66
|
-
if (calcKey === 0 || isCalculatingRef.current)
|
|
67
|
-
return;
|
|
68
|
-
if (innerHtml !== innerHtmlPrevRef.current) {
|
|
69
|
-
onStart && onStart();
|
|
70
|
-
setState({
|
|
71
|
-
...initState(),
|
|
72
|
-
calcKey: calcKey + 1,
|
|
73
|
-
});
|
|
74
|
-
}
|
|
75
|
-
innerHtmlPrevRef.current = innerHtml;
|
|
76
|
-
}, [calcKey, initState, innerHtml, onStart]);
|
|
77
|
-
// Check overflow and resize font
|
|
78
|
-
useIsoLayoutEffect(() => {
|
|
79
|
-
// Don't start calculating font size until the `resizeKey` is incremented
|
|
80
|
-
// above in the `ResizeObserver` callback. This avoids an extra resize
|
|
81
|
-
// on initialization.
|
|
82
|
-
if (calcKey === 0) {
|
|
83
|
-
return;
|
|
84
|
-
}
|
|
85
|
-
const isWithinResolution = Math.abs(fontSize - fontSizePrev) <= resolution;
|
|
86
|
-
const isOverflow = !!ref.current &&
|
|
87
|
-
(ref.current.scrollHeight > ref.current.offsetHeight ||
|
|
88
|
-
ref.current.scrollWidth > ref.current.offsetWidth);
|
|
89
|
-
const isFailed = isOverflow && fontSize === fontSizePrev;
|
|
90
|
-
const isAsc = fontSize > fontSizePrev;
|
|
91
|
-
// Return if the font size has been adjusted "enough" (change within `resolution`)
|
|
92
|
-
// reduce font size by one increment if it's overflowing.
|
|
93
|
-
if (isWithinResolution) {
|
|
94
|
-
if (isFailed) {
|
|
95
|
-
isCalculatingRef.current = false;
|
|
96
|
-
if (logLevel <= LOG_LEVEL.info) {
|
|
97
|
-
console.info(`[use-fit-text] reached \`minFontSize = ${minFontSize}\` without fitting text`);
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
else if (isOverflow) {
|
|
101
|
-
setState({
|
|
102
|
-
fontSize: isAsc ? fontSizePrev : fontSizeMin,
|
|
103
|
-
fontSizeMax,
|
|
104
|
-
fontSizeMin,
|
|
105
|
-
fontSizePrev,
|
|
106
|
-
calcKey,
|
|
107
|
-
});
|
|
108
|
-
}
|
|
109
|
-
else {
|
|
110
|
-
isCalculatingRef.current = false;
|
|
111
|
-
onFinish && onFinish(fontSize);
|
|
112
|
-
}
|
|
113
|
-
return;
|
|
114
|
-
}
|
|
115
|
-
// Binary search to adjust font size
|
|
116
|
-
let delta;
|
|
117
|
-
let newMax = fontSizeMax;
|
|
118
|
-
let newMin = fontSizeMin;
|
|
119
|
-
if (isOverflow) {
|
|
120
|
-
delta = isAsc ? fontSizePrev - fontSize : fontSizeMin - fontSize;
|
|
121
|
-
newMax = Math.min(fontSizeMax, fontSize);
|
|
122
|
-
}
|
|
123
|
-
else {
|
|
124
|
-
delta = isAsc ? fontSizeMax - fontSize : fontSizePrev - fontSize;
|
|
125
|
-
newMin = Math.max(fontSizeMin, fontSize);
|
|
126
|
-
}
|
|
127
|
-
setState({
|
|
128
|
-
calcKey,
|
|
129
|
-
fontSize: fontSize + delta / 2,
|
|
130
|
-
fontSizeMax: newMax,
|
|
131
|
-
fontSizeMin: newMin,
|
|
132
|
-
fontSizePrev: fontSize,
|
|
133
|
-
});
|
|
134
|
-
}, [
|
|
135
|
-
calcKey,
|
|
136
|
-
fontSize,
|
|
137
|
-
fontSizeMax,
|
|
138
|
-
fontSizeMin,
|
|
139
|
-
fontSizePrev,
|
|
140
|
-
onFinish,
|
|
141
|
-
ref,
|
|
142
|
-
resolution,
|
|
143
|
-
]);
|
|
144
|
-
return { fontSize, ref };
|
|
145
|
-
};
|
|
146
|
-
|
|
147
|
-
export { useFitText as default };
|
|
148
|
-
//# sourceMappingURL=useFitText.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useFitText.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
import { jsx } from 'react/jsx-runtime';
|
|
2
|
-
import { useEffect, useRef } from 'react';
|
|
3
|
-
|
|
4
|
-
const KEYCODE_TAB = 9;
|
|
5
|
-
function useFocusTrap() {
|
|
6
|
-
const elRef = useRef(null);
|
|
7
|
-
function handleFocus(e) {
|
|
8
|
-
if (!elRef.current)
|
|
9
|
-
return;
|
|
10
|
-
var focusableEls = elRef.current.querySelectorAll(`
|
|
11
|
-
a[href]:not(:disabled),
|
|
12
|
-
button:not(:disabled),
|
|
13
|
-
textarea:not(:disabled),
|
|
14
|
-
input[type="text"]:not(:disabled),
|
|
15
|
-
input[type="radio"]:not(:disabled),
|
|
16
|
-
input[type="checkbox"]:not(:disabled),
|
|
17
|
-
select:not(:disabled)
|
|
18
|
-
`), firstFocusableEl = focusableEls[0], lastFocusableEl = focusableEls[focusableEls.length - 1];
|
|
19
|
-
var isTabPressed = e.key === "Tab" || e.keyCode === KEYCODE_TAB;
|
|
20
|
-
if (!isTabPressed) {
|
|
21
|
-
return;
|
|
22
|
-
}
|
|
23
|
-
if (e.shiftKey) {
|
|
24
|
-
/* shift + tab */ if (document.activeElement === firstFocusableEl) {
|
|
25
|
-
lastFocusableEl.focus();
|
|
26
|
-
e.preventDefault();
|
|
27
|
-
}
|
|
28
|
-
} /* tab */
|
|
29
|
-
else {
|
|
30
|
-
if (document.activeElement === lastFocusableEl) {
|
|
31
|
-
firstFocusableEl.focus();
|
|
32
|
-
e.preventDefault();
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
useEffect(() => {
|
|
37
|
-
if (elRef.current) {
|
|
38
|
-
elRef.current.addEventListener("keydown", handleFocus);
|
|
39
|
-
elRef.current.focus({ preventScroll: true });
|
|
40
|
-
}
|
|
41
|
-
return () => {
|
|
42
|
-
if (elRef.current) {
|
|
43
|
-
elRef.current.removeEventListener("keydown", handleFocus);
|
|
44
|
-
}
|
|
45
|
-
};
|
|
46
|
-
}, []);
|
|
47
|
-
return elRef;
|
|
48
|
-
}
|
|
49
|
-
function FocusTrap(props) {
|
|
50
|
-
const elRef = useFocusTrap();
|
|
51
|
-
useEffect(() => {
|
|
52
|
-
if (!elRef.current)
|
|
53
|
-
return;
|
|
54
|
-
elRef.current.focus({ preventScroll: true });
|
|
55
|
-
}, []);
|
|
56
|
-
return (jsx("div", { ref: elRef, tabIndex: 0, children: props.children }));
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
export { FocusTrap as default };
|
|
60
|
-
//# sourceMappingURL=useFocusTrap.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useFocusTrap.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import { useEffect } from 'react';
|
|
2
|
-
|
|
3
|
-
function useGoogleFont(font) {
|
|
4
|
-
useEffect(() => {
|
|
5
|
-
if (!font)
|
|
6
|
-
return;
|
|
7
|
-
font = font.replace(/ /g, "+");
|
|
8
|
-
const googleapis = document.createElement("link");
|
|
9
|
-
googleapis.href = `https://fonts.googleapis.com`;
|
|
10
|
-
googleapis.rel = "preconnect";
|
|
11
|
-
const gstatic = document.createElement("link");
|
|
12
|
-
gstatic.href = `https://fonts.gstatic.com`;
|
|
13
|
-
gstatic.rel = "preconnect";
|
|
14
|
-
gstatic.crossOrigin = "true";
|
|
15
|
-
const link = document.createElement("link");
|
|
16
|
-
link.href = `https://fonts.googleapis.com/css2?family=${font}:wght@400;500;600&display=swap`;
|
|
17
|
-
link.rel = "stylesheet";
|
|
18
|
-
document.head.appendChild(googleapis);
|
|
19
|
-
document.head.appendChild(gstatic);
|
|
20
|
-
document.head.appendChild(link);
|
|
21
|
-
return () => {
|
|
22
|
-
try {
|
|
23
|
-
document.head.removeChild(googleapis);
|
|
24
|
-
document.head.removeChild(gstatic);
|
|
25
|
-
document.head.removeChild(link);
|
|
26
|
-
}
|
|
27
|
-
catch { }
|
|
28
|
-
};
|
|
29
|
-
}, [font]);
|
|
30
|
-
}
|
|
31
|
-
// TODO: This could be dynamic if theming wasn't set up as css variables
|
|
32
|
-
function useThemeFont(theme) {
|
|
33
|
-
const themeFonts = {
|
|
34
|
-
web95: "Lato",
|
|
35
|
-
retro: "Nunito",
|
|
36
|
-
midnight: "Inter",
|
|
37
|
-
minimal: "Inter",
|
|
38
|
-
rounded: "Nunito",
|
|
39
|
-
};
|
|
40
|
-
const font = themeFonts[theme] ?? null;
|
|
41
|
-
useGoogleFont(font ?? "");
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
export { useGoogleFont, useThemeFont };
|
|
45
|
-
//# sourceMappingURL=useGoogleFont.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useGoogleFont.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { useState, useEffect } from 'react';
|
|
2
|
-
import { isMobile } from '../utils/index.js';
|
|
3
|
-
|
|
4
|
-
function useIsMobile() {
|
|
5
|
-
const [mobile, setMobile] = useState(isMobile());
|
|
6
|
-
useEffect(() => {
|
|
7
|
-
const handleResize = () => {
|
|
8
|
-
setMobile(isMobile());
|
|
9
|
-
};
|
|
10
|
-
window.addEventListener("resize", handleResize);
|
|
11
|
-
return () => window.removeEventListener("resize", handleResize);
|
|
12
|
-
}, []);
|
|
13
|
-
return mobile;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export { useIsMobile as default };
|
|
17
|
-
//# sourceMappingURL=useIsMobile.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useIsMobile.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;"}
|