@blocklet/payment-react 1.16.12 → 1.16.16

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.
Files changed (115) hide show
  1. package/es/checkout/donate.d.ts +2 -3
  2. package/es/checkout/donate.js +2 -2
  3. package/es/checkout/form.d.ts +1 -2
  4. package/es/checkout/form.js +1 -1
  5. package/es/checkout/table.d.ts +1 -2
  6. package/es/components/blockchain/gas.d.ts +0 -1
  7. package/es/components/blockchain/tx.d.ts +0 -1
  8. package/es/components/country-select.d.ts +2 -3
  9. package/es/components/input.d.ts +13 -14
  10. package/es/components/livemode.d.ts +1 -2
  11. package/es/components/over-due-invoice-payment.d.ts +0 -1
  12. package/es/components/pricing-item.d.ts +1 -2
  13. package/es/components/pricing-item.js +1 -1
  14. package/es/components/pricing-table.d.ts +0 -1
  15. package/es/components/status.d.ts +1 -2
  16. package/es/components/switch-button.d.ts +5 -4
  17. package/es/components/switch-button.js +40 -37
  18. package/es/components/truncated-text.d.ts +0 -1
  19. package/es/contexts/payment.d.ts +0 -1
  20. package/es/history/invoice/list.d.ts +0 -1
  21. package/es/history/payment/list.d.ts +0 -1
  22. package/es/libs/util.d.ts +2 -5
  23. package/es/libs/util.js +1 -1
  24. package/es/locales/index.d.ts +1 -1
  25. package/es/payment/amount.d.ts +1 -2
  26. package/es/payment/error.d.ts +0 -1
  27. package/es/payment/footer.d.ts +0 -1
  28. package/es/payment/form/addon.d.ts +0 -1
  29. package/es/payment/form/address.d.ts +1 -2
  30. package/es/payment/form/currency.d.ts +0 -1
  31. package/es/payment/form/index.d.ts +1 -2
  32. package/es/payment/form/index.js +4 -1
  33. package/es/payment/form/phone.d.ts +0 -1
  34. package/es/payment/form/stripe/form.d.ts +0 -1
  35. package/es/payment/form/stripe/index.d.ts +0 -1
  36. package/es/payment/header.d.ts +0 -1
  37. package/es/payment/index.d.ts +5 -6
  38. package/es/payment/product-card.d.ts +0 -1
  39. package/es/payment/product-donation.d.ts +0 -1
  40. package/es/payment/product-skeleton.d.ts +0 -1
  41. package/es/payment/skeleton/overview.d.ts +0 -1
  42. package/es/payment/skeleton/payment.d.ts +0 -1
  43. package/es/payment/success.d.ts +0 -1
  44. package/es/payment/summary.d.ts +0 -1
  45. package/es/payment/summary.js +1 -11
  46. package/es/theme/index.d.ts +1 -1
  47. package/es/types/index.d.ts +2 -2
  48. package/lib/checkout/donate.d.ts +2 -3
  49. package/lib/checkout/donate.js +2 -2
  50. package/lib/checkout/form.d.ts +1 -2
  51. package/lib/checkout/form.js +1 -1
  52. package/lib/checkout/table.d.ts +1 -2
  53. package/lib/components/blockchain/gas.d.ts +0 -1
  54. package/lib/components/blockchain/tx.d.ts +0 -1
  55. package/lib/components/country-select.d.ts +2 -3
  56. package/lib/components/input.d.ts +13 -14
  57. package/lib/components/livemode.d.ts +1 -2
  58. package/lib/components/over-due-invoice-payment.d.ts +0 -1
  59. package/lib/components/pricing-item.d.ts +1 -2
  60. package/lib/components/pricing-item.js +1 -1
  61. package/lib/components/pricing-table.d.ts +0 -1
  62. package/lib/components/status.d.ts +1 -2
  63. package/lib/components/switch-button.d.ts +5 -4
  64. package/lib/components/switch-button.js +3 -2
  65. package/lib/components/truncated-text.d.ts +0 -1
  66. package/lib/contexts/payment.d.ts +0 -1
  67. package/lib/history/invoice/list.d.ts +0 -1
  68. package/lib/history/payment/list.d.ts +0 -1
  69. package/lib/libs/util.d.ts +2 -5
  70. package/lib/libs/util.js +1 -1
  71. package/lib/locales/index.d.ts +1 -1
  72. package/lib/payment/amount.d.ts +1 -2
  73. package/lib/payment/error.d.ts +0 -1
  74. package/lib/payment/footer.d.ts +0 -1
  75. package/lib/payment/form/addon.d.ts +0 -1
  76. package/lib/payment/form/address.d.ts +1 -2
  77. package/lib/payment/form/currency.d.ts +0 -1
  78. package/lib/payment/form/index.d.ts +1 -2
  79. package/lib/payment/form/index.js +4 -1
  80. package/lib/payment/form/phone.d.ts +0 -1
  81. package/lib/payment/form/stripe/form.d.ts +0 -1
  82. package/lib/payment/form/stripe/index.d.ts +0 -1
  83. package/lib/payment/header.d.ts +0 -1
  84. package/lib/payment/index.d.ts +5 -6
  85. package/lib/payment/product-card.d.ts +0 -1
  86. package/lib/payment/product-donation.d.ts +0 -1
  87. package/lib/payment/product-skeleton.d.ts +0 -1
  88. package/lib/payment/skeleton/overview.d.ts +0 -1
  89. package/lib/payment/skeleton/payment.d.ts +0 -1
  90. package/lib/payment/success.d.ts +0 -1
  91. package/lib/payment/summary.d.ts +0 -1
  92. package/lib/theme/index.d.ts +1 -1
  93. package/lib/types/index.d.ts +2 -2
  94. package/package.json +16 -15
  95. package/src/checkout/donate.tsx +4 -4
  96. package/src/checkout/form.tsx +2 -2
  97. package/src/checkout/table.tsx +3 -3
  98. package/src/components/country-select.tsx +5 -3
  99. package/src/components/input.tsx +4 -2
  100. package/src/components/livemode.tsx +2 -1
  101. package/src/components/pricing-item.tsx +2 -2
  102. package/src/components/status.tsx +2 -1
  103. package/src/components/switch-button.tsx +44 -39
  104. package/src/components/truncated-text.tsx +2 -1
  105. package/src/contexts/payment.tsx +2 -2
  106. package/src/libs/api.ts +2 -2
  107. package/src/libs/util.ts +4 -5
  108. package/src/payment/amount.tsx +2 -1
  109. package/src/payment/form/address.tsx +2 -1
  110. package/src/payment/form/index.tsx +2 -1
  111. package/src/payment/form/phone.tsx +3 -2
  112. package/src/payment/index.tsx +4 -3
  113. package/src/payment/summary.tsx +2 -12
  114. package/src/theme/index.tsx +1 -1
  115. package/src/types/index.ts +2 -2
@@ -1,48 +1,53 @@
1
1
  import { Switch } from '@mui/material';
2
2
  import { styled } from '@mui/system';
3
3
  import type { LiteralUnion } from 'type-fest';
4
+ import type { SwitchProps as MuiSwitchProps } from '@mui/material';
4
5
 
5
- type SwitchProps = {
6
+ type CustomSwitchProps = {
6
7
  variant?: LiteralUnion<'success' | 'error' | 'warning' | 'info' | 'primary' | 'secondary', string>;
7
- };
8
+ } & MuiSwitchProps;
8
9
 
9
- export default styled(Switch)<SwitchProps>(({ variant = 'success', theme }) => ({
10
- width: 28,
11
- height: 16,
12
- padding: 0,
13
- display: 'inline-flex',
14
- '&:active': {
15
- '& .MuiSwitch-thumb': {
16
- width: 15,
17
- },
18
- '& .MuiSwitch-switchBase.Mui-checked': {
19
- transform: 'translateX(9px)',
10
+ const SwitchButton: React.FC<CustomSwitchProps> = styled(Switch)<CustomSwitchProps>(
11
+ ({ variant = 'success', theme }) => ({
12
+ width: 28,
13
+ height: 16,
14
+ padding: 0,
15
+ display: 'inline-flex',
16
+ '&:active': {
17
+ '& .MuiSwitch-thumb': {
18
+ width: 15,
19
+ },
20
+ '& .MuiSwitch-switchBase.Mui-checked': {
21
+ transform: 'translateX(9px)',
22
+ },
20
23
  },
21
- },
22
- '& .MuiSwitch-switchBase': {
23
- padding: 2,
24
- '&.Mui-checked': {
25
- transform: 'translateX(12px)',
26
- color: '#fff',
27
- '& + .MuiSwitch-track': {
28
- opacity: 1,
29
- backgroundColor: theme.palette[variant]?.light,
24
+ '& .MuiSwitch-switchBase': {
25
+ padding: 2,
26
+ '&.Mui-checked': {
27
+ transform: 'translateX(12px)',
28
+ color: '#fff',
29
+ '& + .MuiSwitch-track': {
30
+ opacity: 1,
31
+ backgroundColor: theme.palette[variant]?.light,
32
+ },
30
33
  },
31
34
  },
32
- },
33
- '& .MuiSwitch-thumb': {
34
- boxShadow: '0 2px 4px 0 rgb(0 35 11 / 20%)',
35
- width: 12,
36
- height: 12,
37
- borderRadius: 6,
38
- transition: (theme.transitions as any)?.create(['width'], {
39
- duration: 200,
40
- }),
41
- },
42
- '& .MuiSwitch-track': {
43
- borderRadius: 16 / 2,
44
- opacity: 1,
45
- backgroundColor: theme.palette.mode === 'dark' ? 'rgba(255,255,255,.35)' : 'rgba(0,0,0,.25)',
46
- boxSizing: 'border-box',
47
- },
48
- }));
35
+ '& .MuiSwitch-thumb': {
36
+ boxShadow: '0 2px 4px 0 rgb(0 35 11 / 20%)',
37
+ width: 12,
38
+ height: 12,
39
+ borderRadius: 6,
40
+ transition: (theme.transitions as any)?.create(['width'], {
41
+ duration: 200,
42
+ }),
43
+ },
44
+ '& .MuiSwitch-track': {
45
+ borderRadius: 16 / 2,
46
+ opacity: 1,
47
+ backgroundColor: theme.palette.mode === 'dark' ? 'rgba(255,255,255,.35)' : 'rgba(0,0,0,.25)',
48
+ boxSizing: 'border-box',
49
+ },
50
+ })
51
+ );
52
+
53
+ export default SwitchButton;
@@ -1,4 +1,5 @@
1
- import { Tooltip, TooltipProps } from '@mui/material';
1
+ import { Tooltip } from '@mui/material';
2
+ import type { TooltipProps } from '@mui/material';
2
3
  import { tooltipClasses } from '@mui/material/Tooltip';
3
4
  import { styled } from '@mui/system';
4
5
  import { truncateText } from '../libs/util';
@@ -50,11 +50,11 @@ const getSettings = () => {
50
50
  if (!settingsPromise) {
51
51
  settingsPromise = api
52
52
  .get('/api/settings', { params: { livemode } })
53
- .then(({ data }) => {
53
+ .then(({ data }: any) => {
54
54
  sessionStorage.setItem(cacheKey, JSON.stringify(data));
55
55
  return data;
56
56
  })
57
- .catch((error) => {
57
+ .catch((error: any) => {
58
58
  throw error;
59
59
  })
60
60
  .finally(() => {
package/src/libs/api.ts CHANGED
@@ -8,7 +8,7 @@ import { getPrefix } from './util';
8
8
  const api = createAxios();
9
9
 
10
10
  api.interceptors.request.use(
11
- (config) => {
11
+ (config: any) => {
12
12
  const prefix = getPrefix();
13
13
  config.baseURL = prefix || '';
14
14
 
@@ -23,7 +23,7 @@ api.interceptors.request.use(
23
23
 
24
24
  return config;
25
25
  },
26
- (err) => Promise.reject(err)
26
+ (err: any) => Promise.reject(err)
27
27
  );
28
28
 
29
29
  export default api;
package/src/libs/util.ts CHANGED
@@ -15,7 +15,6 @@ import type {
15
15
  TSubscriptionExpanded,
16
16
  TSubscriptionItemExpanded,
17
17
  } from '@blocklet/payment-types';
18
- import type { TComponent } from '@blocklet/sdk/lib/config';
19
18
  import { BN, fromUnitToToken } from '@ocap/util';
20
19
  import omit from 'lodash/omit';
21
20
  import trimEnd from 'lodash/trimEnd';
@@ -27,7 +26,7 @@ import { joinURL } from 'ufo';
27
26
 
28
27
  import { t } from '../locales';
29
28
  import dayjs from './dayjs';
30
- import { ActionProps, PricingRenderProps } from '../types';
29
+ import type { ActionProps, PricingRenderProps } from '../types';
31
30
 
32
31
  export const PAYMENT_KIT_DID = 'z2qaCNvKMv5GjouKdcDWexv6WqtHbpNPQDnAk';
33
32
 
@@ -54,7 +53,7 @@ export const getPrefix = (): string => {
54
53
  if (componentId === PAYMENT_KIT_DID) {
55
54
  return joinURL(baseUrl, prefix);
56
55
  }
57
- const component = (window.blocklet?.componentMountPoints || []).find((x: TComponent) => x.did === PAYMENT_KIT_DID);
56
+ const component = (window.blocklet?.componentMountPoints || []).find((x: any) => x?.did === PAYMENT_KIT_DID);
58
57
  if (component) {
59
58
  return joinURL(baseUrl, component.mountPoint);
60
59
  }
@@ -774,7 +773,7 @@ export function findCurrency(methods: TPaymentMethodExpanded[], currencyId: stri
774
773
  }
775
774
 
776
775
  export function isValidCountry(code: string) {
777
- return defaultCountries.some((x) => x[1] === code);
776
+ return defaultCountries.some((x: any) => x[1] === code);
778
777
  }
779
778
 
780
779
  export function stopEvent(e: React.SyntheticEvent<any>) {
@@ -874,7 +873,7 @@ export const mergeExtraParams = (extra: Record<string, any> = {}) => {
874
873
  return params.toString();
875
874
  };
876
875
 
877
- export const flattenPaymentMethods = (methods: TPaymentMethodExpanded[] = []) => {
876
+ export const flattenPaymentMethods = (methods: TPaymentMethodExpanded[] = []): TPaymentCurrency[] => {
878
877
  const out: TPaymentCurrency[] = [];
879
878
 
880
879
  methods.forEach((method: any) => {
@@ -1,4 +1,5 @@
1
- import { Typography, TypographyProps } from '@mui/material';
1
+ import { Typography } from '@mui/material';
2
+ import type { TypographyProps } from '@mui/material';
2
3
 
3
4
  type Props = { amount: string } & TypographyProps;
4
5
 
@@ -1,5 +1,6 @@
1
1
  import { useLocaleContext } from '@arcblock/ux/lib/Locale/context';
2
- import { Fade, FormLabel, InputAdornment, Stack, SxProps } from '@mui/material';
2
+ import { Fade, FormLabel, InputAdornment, Stack } from '@mui/material';
3
+ import type { SxProps } from '@mui/material';
3
4
  import { Controller, useFormContext } from 'react-hook-form';
4
5
  import FormInput from '../../components/input';
5
6
  import CountrySelect from '../../components/country-select';
@@ -34,7 +34,7 @@ import {
34
34
  getQueryParams,
35
35
  getStatementDescriptor,
36
36
  } from '../../libs/util';
37
- import { CheckoutCallbacks, CheckoutContext } from '../../types';
37
+ import type { CheckoutCallbacks, CheckoutContext } from '../../types';
38
38
  import AddressForm from './address';
39
39
  import CurrencySelector from './currency';
40
40
  import PhoneInput from './phone';
@@ -59,6 +59,7 @@ const waitForCheckoutComplete = async (sessionId: string) => {
59
59
  result = data;
60
60
 
61
61
  return (
62
+ // eslint-disable-next-line @typescript-eslint/return-await
62
63
  data.checkoutSession?.status === 'complete' &&
63
64
  ['paid', 'no_payment_required'].includes(data.checkoutSession?.payment_status)
64
65
  );
@@ -3,7 +3,8 @@ import { InputAdornment } from '@mui/material';
3
3
  import omit from 'lodash/omit';
4
4
  import { useEffect } from 'react';
5
5
  import { useFormContext, useWatch } from 'react-hook-form';
6
- import { CountryIso2, defaultCountries, usePhoneInput } from 'react-international-phone';
6
+ import { defaultCountries, usePhoneInput } from 'react-international-phone';
7
+ import type { CountryIso2 } from 'react-international-phone';
7
8
 
8
9
  import FormInput from '../../components/input';
9
10
  import { isValidCountry } from '../../libs/util';
@@ -18,7 +19,7 @@ export default function PhoneInput({ ...props }) {
18
19
  defaultCountry: isValidCountry(values[countryFieldName]) ? values[countryFieldName] : 'us',
19
20
  value: values[props.name] || '',
20
21
  countries: defaultCountries,
21
- onChange: (data) => {
22
+ onChange: (data: any) => {
22
23
  setValue(props.name, data.phone);
23
24
  setValue(countryFieldName, data.country);
24
25
  },
@@ -12,7 +12,7 @@ import type {
12
12
  TPaymentMethodExpanded,
13
13
  } from '@blocklet/payment-types';
14
14
  import { ArrowBackOutlined } from '@mui/icons-material';
15
- import { Box, Fade, Stack } from '@mui/material';
15
+ import { Box, Fade, Stack, type BoxProps } from '@mui/material';
16
16
  import { styled } from '@mui/system';
17
17
  import { fromTokenToUnit } from '@ocap/util';
18
18
  import { useSetState } from 'ahooks';
@@ -31,7 +31,7 @@ import {
31
31
  isMobileSafari,
32
32
  isValidCountry,
33
33
  } from '../libs/util';
34
- import { CheckoutCallbacks, CheckoutContext, CheckoutFormData } from '../types';
34
+ import type { CheckoutCallbacks, CheckoutContext, CheckoutFormData } from '../types';
35
35
  import PaymentError from './error';
36
36
  import CheckoutFooter from './footer';
37
37
  import PaymentForm from './form';
@@ -470,7 +470,8 @@ export default function Payment({
470
470
 
471
471
  type MainProps = CheckoutContext & CheckoutCallbacks & { completed?: boolean; showCheckoutSummary?: boolean };
472
472
 
473
- export const Root = styled(Box)<{ mode: LiteralUnion<'standalone' | 'inline' | 'popup', string> }>`
473
+ type RootProps = { mode: LiteralUnion<'standalone' | 'inline' | 'popup', string> } & BoxProps;
474
+ export const Root: React.FC<RootProps> = styled(Box)<RootProps>`
474
475
  box-sizing: border-box;
475
476
  display: flex;
476
477
  flex-direction: column;
@@ -2,18 +2,8 @@ import { useLocaleContext } from '@arcblock/ux/lib/Locale/context';
2
2
  import type { DonationSettings, TLineItemExpanded, TPaymentCurrency } from '@blocklet/payment-types';
3
3
  import { HelpOutline } from '@mui/icons-material';
4
4
  import { LoadingButton } from '@mui/lab';
5
- import {
6
- Box,
7
- Divider,
8
- Fade,
9
- Grow,
10
- Stack,
11
- Tooltip,
12
- Typography,
13
- Collapse,
14
- IconButton,
15
- IconButtonProps,
16
- } from '@mui/material';
5
+ import { Box, Divider, Fade, Grow, Stack, Tooltip, Typography, Collapse, IconButton } from '@mui/material';
6
+ import type { IconButtonProps } from '@mui/material';
17
7
  import { BN, fromTokenToUnit, fromUnitToToken } from '@ocap/util';
18
8
  import { useRequest, useSetState } from 'ahooks';
19
9
  import noop from 'lodash/noop';
@@ -7,7 +7,7 @@ import React from 'react';
7
7
 
8
8
  import { typography } from './typography';
9
9
  import './index.css';
10
- import { PaymentThemeOptions } from '../types';
10
+ import type { PaymentThemeOptions } from '../types';
11
11
 
12
12
  export { typography };
13
13
 
@@ -6,8 +6,8 @@ import type {
6
6
  TPaymentLink,
7
7
  TPaymentMethodExpanded,
8
8
  } from '@blocklet/payment-types';
9
- import { SxProps, ThemeOptions } from '@mui/material';
10
- import { LiteralUnion } from 'type-fest';
9
+ import type { SxProps, ThemeOptions } from '@mui/material';
10
+ import type { LiteralUnion } from 'type-fest';
11
11
 
12
12
  export type CheckoutContext = {
13
13
  checkoutSession: TCheckoutSessionExpanded;