@blocklet/payment-react 1.14.21 → 1.14.22

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 (136) hide show
  1. package/es/checkout/donate.d.ts +2 -1
  2. package/es/checkout/donate.js +9 -10
  3. package/es/checkout/form.d.ts +1 -1
  4. package/es/checkout/form.js +23 -1
  5. package/es/checkout/table.d.ts +1 -1
  6. package/es/checkout/table.js +8 -1
  7. package/es/components/blockchain/tx.js +2 -1
  8. package/es/components/country-select.d.ts +16 -0
  9. package/es/components/country-select.js +82 -0
  10. package/es/components/input.d.ts +21 -21
  11. package/es/components/input.js +43 -42
  12. package/es/components/livemode.js +1 -0
  13. package/es/components/pricing-table.js +0 -2
  14. package/es/components/status.js +2 -3
  15. package/es/components/table.d.ts +2 -0
  16. package/es/components/table.js +186 -0
  17. package/es/contexts/payment.d.ts +2 -0
  18. package/es/contexts/payment.js +5 -2
  19. package/es/history/invoice/list.d.ts +3 -1
  20. package/es/history/invoice/list.js +215 -48
  21. package/es/hooks/mobile.d.ts +4 -0
  22. package/es/hooks/mobile.js +10 -0
  23. package/es/index.d.ts +5 -1
  24. package/es/index.js +7 -1
  25. package/es/libs/util.d.ts +15 -2
  26. package/es/libs/util.js +92 -28
  27. package/es/locales/en.js +22 -7
  28. package/es/locales/index.d.ts +0 -1
  29. package/es/locales/index.js +10 -1
  30. package/es/locales/zh.js +21 -6
  31. package/es/payment/error.js +2 -2
  32. package/es/payment/footer.js +1 -1
  33. package/es/payment/form/address.d.ts +9 -2
  34. package/es/payment/form/address.js +69 -69
  35. package/es/payment/form/currency.js +39 -25
  36. package/es/payment/form/index.d.ts +1 -1
  37. package/es/payment/form/index.js +83 -81
  38. package/es/payment/form/phone.js +15 -51
  39. package/es/payment/index.d.ts +1 -10
  40. package/es/payment/index.js +274 -219
  41. package/es/payment/product-card.js +4 -4
  42. package/es/payment/product-donation.js +7 -2
  43. package/es/payment/product-item.d.ts +2 -2
  44. package/es/payment/product-item.js +120 -81
  45. package/es/payment/summary.js +188 -118
  46. package/es/theme/index.css +240 -0
  47. package/es/theme/index.d.ts +9 -0
  48. package/es/theme/index.js +243 -0
  49. package/es/theme/typography.d.ts +2 -0
  50. package/es/theme/typography.js +53 -0
  51. package/es/types/index.d.ts +11 -0
  52. package/lib/checkout/donate.d.ts +2 -1
  53. package/lib/checkout/donate.js +14 -2
  54. package/lib/checkout/form.d.ts +1 -1
  55. package/lib/checkout/form.js +22 -1
  56. package/lib/checkout/table.d.ts +1 -1
  57. package/lib/checkout/table.js +14 -1
  58. package/lib/components/blockchain/tx.js +4 -1
  59. package/lib/components/country-select.d.ts +16 -0
  60. package/lib/components/country-select.js +115 -0
  61. package/lib/components/input.d.ts +21 -21
  62. package/lib/components/input.js +21 -12
  63. package/lib/components/livemode.js +1 -0
  64. package/lib/components/pricing-table.js +0 -2
  65. package/lib/components/status.js +2 -3
  66. package/lib/components/table.d.ts +2 -0
  67. package/lib/components/table.js +220 -0
  68. package/lib/contexts/payment.d.ts +2 -0
  69. package/lib/contexts/payment.js +4 -1
  70. package/lib/history/invoice/list.d.ts +3 -1
  71. package/lib/history/invoice/list.js +290 -62
  72. package/lib/hooks/mobile.d.ts +4 -0
  73. package/lib/hooks/mobile.js +17 -0
  74. package/lib/index.d.ts +5 -1
  75. package/lib/index.js +36 -0
  76. package/lib/libs/util.d.ts +15 -2
  77. package/lib/libs/util.js +115 -37
  78. package/lib/locales/en.js +22 -7
  79. package/lib/locales/index.d.ts +0 -1
  80. package/lib/locales/index.js +14 -3
  81. package/lib/locales/zh.js +21 -6
  82. package/lib/payment/error.js +5 -1
  83. package/lib/payment/footer.js +1 -1
  84. package/lib/payment/form/address.d.ts +9 -2
  85. package/lib/payment/form/address.js +67 -59
  86. package/lib/payment/form/currency.js +31 -24
  87. package/lib/payment/form/index.d.ts +1 -1
  88. package/lib/payment/form/index.js +92 -93
  89. package/lib/payment/form/phone.js +11 -59
  90. package/lib/payment/index.d.ts +1 -10
  91. package/lib/payment/index.js +291 -219
  92. package/lib/payment/product-card.js +5 -4
  93. package/lib/payment/product-donation.js +9 -2
  94. package/lib/payment/product-item.d.ts +2 -2
  95. package/lib/payment/product-item.js +38 -19
  96. package/lib/payment/summary.js +219 -127
  97. package/lib/theme/index.css +240 -0
  98. package/lib/theme/index.d.ts +9 -0
  99. package/lib/theme/index.js +259 -0
  100. package/lib/theme/typography.d.ts +2 -0
  101. package/lib/theme/typography.js +59 -0
  102. package/lib/types/index.d.ts +11 -0
  103. package/package.json +14 -11
  104. package/src/checkout/donate.tsx +16 -10
  105. package/src/checkout/form.tsx +23 -0
  106. package/src/checkout/table.tsx +13 -1
  107. package/src/components/blockchain/tx.tsx +2 -1
  108. package/src/components/country-select.tsx +93 -0
  109. package/src/components/input.tsx +49 -46
  110. package/src/components/livemode.tsx +1 -0
  111. package/src/components/pricing-table.tsx +0 -2
  112. package/src/components/status.tsx +1 -2
  113. package/src/components/table.tsx +200 -0
  114. package/src/contexts/payment.tsx +6 -1
  115. package/src/history/invoice/list.tsx +254 -49
  116. package/src/hooks/mobile.ts +13 -0
  117. package/src/index.ts +7 -0
  118. package/src/libs/util.ts +120 -31
  119. package/src/locales/en.tsx +18 -4
  120. package/src/locales/index.tsx +10 -3
  121. package/src/locales/zh.tsx +17 -3
  122. package/src/payment/error.tsx +2 -2
  123. package/src/payment/footer.tsx +1 -1
  124. package/src/payment/form/address.tsx +56 -47
  125. package/src/payment/form/currency.tsx +29 -23
  126. package/src/payment/form/index.tsx +89 -76
  127. package/src/payment/form/phone.tsx +14 -51
  128. package/src/payment/index.tsx +294 -242
  129. package/src/payment/product-card.tsx +4 -4
  130. package/src/payment/product-donation.tsx +7 -3
  131. package/src/payment/product-item.tsx +49 -20
  132. package/src/payment/summary.tsx +191 -108
  133. package/src/theme/index.css +240 -0
  134. package/src/theme/index.tsx +250 -0
  135. package/src/theme/typography.ts +56 -0
  136. package/src/types/index.ts +12 -0
@@ -1,3 +1,4 @@
1
+ /* eslint-disable react/require-default-props */
1
2
  /* eslint-disable @typescript-eslint/indent */
2
3
  import Dialog from '@arcblock/ux/lib/Dialog';
3
4
  import { useLocaleContext } from '@arcblock/ux/lib/Locale/context';
@@ -36,6 +37,7 @@ import api from '../libs/api';
36
37
  import { formatAmount, formatBNStr, formatDateTime, formatError, lazyLoad } from '../libs/util';
37
38
  import { CheckoutProps } from '../types';
38
39
  import CheckoutForm from './form';
40
+ import { PaymentThemeProvider } from '../theme';
39
41
 
40
42
  export type DonateHistory = {
41
43
  supporters: TCheckoutSessionExpanded[];
@@ -58,6 +60,7 @@ export type DonateProps = Pick<CheckoutProps, 'onPaid' | 'onError'> & {
58
60
  inlineOptions?: {
59
61
  button?: ButtonType;
60
62
  };
63
+ customTheme?: boolean;
61
64
  };
62
65
 
63
66
  const donationCache: { [key: string]: Promise<TPaymentLink> } = {};
@@ -298,15 +301,7 @@ function useDonation(settings: DonationSettings, livemode: boolean = true, mode
298
301
  };
299
302
  }
300
303
 
301
- export default function CheckoutDonate({
302
- settings,
303
- livemode,
304
- timeout,
305
- onPaid,
306
- onError,
307
- mode,
308
- inlineOptions = {},
309
- }: DonateProps) {
304
+ function CheckoutDonateInner({ settings, livemode, timeout, onPaid, onError, mode, inlineOptions = {} }: DonateProps) {
310
305
  // eslint-disable-line
311
306
  const { state, setState, donation, supporters } = useDonation(settings, livemode, mode);
312
307
 
@@ -448,7 +443,7 @@ export default function CheckoutDonate({
448
443
  showCloseButton
449
444
  disableEscapeKeyDown
450
445
  onClose={(e: any, reason: string) => setState({ open: reason === 'backdropClick' })}>
451
- <Box sx={{ mb: 1, mt: -2, height: '100%' }}>
446
+ <Box sx={{ mb: 1, height: '100%' }}>
452
447
  <CheckoutForm
453
448
  id={donation.data?.id}
454
449
  onPaid={handlePaid}
@@ -463,6 +458,17 @@ export default function CheckoutDonate({
463
458
  );
464
459
  }
465
460
 
461
+ export default function CheckoutDonate(props: DonateProps) {
462
+ if (props.customTheme) {
463
+ return <CheckoutDonateInner {...props} />;
464
+ }
465
+ return (
466
+ <PaymentThemeProvider>
467
+ <CheckoutDonateInner {...props} />
468
+ </PaymentThemeProvider>
469
+ );
470
+ }
471
+
466
472
  CheckoutDonate.defaultProps = {
467
473
  livemode: true,
468
474
  timeout: 5000,
@@ -8,6 +8,7 @@ import api from '../libs/api';
8
8
  import { getPrefix, mergeExtraParams } from '../libs/util';
9
9
  import Payment from '../payment';
10
10
  import { CheckoutContext, CheckoutProps } from '../types';
11
+ import { PaymentThemeProvider } from '../theme';
11
12
 
12
13
  const promises: { [key: string]: Promise<any> } = {};
13
14
  const startFromPaymentLink = (id: string, params?: Record<string, any>): Promise<CheckoutContext> => {
@@ -39,6 +40,7 @@ export default function CheckoutForm({
39
40
  goBack,
40
41
  extraParams,
41
42
  action,
43
+ customTheme = false,
42
44
  }: CheckoutProps) {
43
45
  if (!id.startsWith('plink_') && !id.startsWith('cs_')) {
44
46
  throw new Error('Either a checkoutSession or a paymentLink id is required.');
@@ -73,6 +75,27 @@ export default function CheckoutForm({
73
75
  onError?.(err);
74
76
  };
75
77
 
78
+ if (!customTheme) {
79
+ return (
80
+ <PaymentThemeProvider>
81
+ <Payment
82
+ checkoutSession={data?.checkoutSession as TCheckoutSessionExpanded}
83
+ paymentMethods={data?.paymentMethods as TPaymentMethodExpanded[]}
84
+ paymentIntent={data?.paymentIntent}
85
+ paymentLink={data?.paymentLink}
86
+ customer={data?.customer}
87
+ completed={state.completed}
88
+ error={apiError || state.appError}
89
+ onPaid={handlePaid}
90
+ onError={handleError}
91
+ onChange={onChange}
92
+ goBack={goBack}
93
+ mode={mode as string}
94
+ action={action}
95
+ />
96
+ </PaymentThemeProvider>
97
+ );
98
+ }
76
99
  return (
77
100
  <Payment
78
101
  checkoutSession={data?.checkoutSession as TCheckoutSessionExpanded}
@@ -12,6 +12,7 @@ import api from '../libs/api';
12
12
  import { mergeExtraParams } from '../libs/util';
13
13
  import { CheckoutProps } from '../types';
14
14
  import CheckoutForm from './form';
15
+ import { PaymentThemeProvider } from '../theme';
15
16
 
16
17
  const fetchData = async (id: string): Promise<TPricingTableExpanded> => {
17
18
  const { data } = await api.get(`/api/pricing-tables/${id}`);
@@ -25,7 +26,7 @@ const ensureProtocol = (url: string): string => {
25
26
  return url;
26
27
  };
27
28
 
28
- export default function CheckoutTable({ id, mode, onPaid, onError, onChange, extraParams, goBack }: CheckoutProps) {
29
+ function CheckoutTableInner({ id, mode, onPaid, onError, onChange, extraParams, goBack }: CheckoutProps) {
29
30
  if (!id.startsWith('prctbl_')) {
30
31
  throw new Error('A valid pricing table id is required.');
31
32
  }
@@ -123,3 +124,14 @@ export default function CheckoutTable({ id, mode, onPaid, onError, onChange, ext
123
124
  </Box>
124
125
  );
125
126
  }
127
+
128
+ export default function CheckoutTable(props: CheckoutProps) {
129
+ if (props.customTheme) {
130
+ return <CheckoutTableInner {...props} />;
131
+ }
132
+ return (
133
+ <PaymentThemeProvider>
134
+ <CheckoutTableInner {...props} />
135
+ </PaymentThemeProvider>
136
+ );
137
+ }
@@ -36,8 +36,9 @@ export default function TxLink(props: {
36
36
  direction="row"
37
37
  alignItems="center"
38
38
  justifyContent={props.align === 'left' ? 'flex-start' : 'flex-end'}
39
+ sx={{ color: 'text.link' }}
39
40
  spacing={1}>
40
- <Typography component="span" color="primary">
41
+ <Typography component="span" color="text.link">
41
42
  {text.length > 40 ? [text.slice(0, 6), text.slice(-6)].join('...') : text}
42
43
  </Typography>
43
44
  <OpenInNewOutlined fontSize="small" />
@@ -0,0 +1,93 @@
1
+ /* eslint-disable react/prop-types */
2
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
3
+ import React, { useMemo } from 'react';
4
+ import { Box, MenuItem, Select, SxProps, Typography } from '@mui/material';
5
+ import { useFormContext } from 'react-hook-form';
6
+ import { CountryIso2, FlagEmoji, defaultCountries, parseCountry } from 'react-international-phone';
7
+
8
+ export type CountrySelectProps = {
9
+ value: CountryIso2;
10
+ onChange: (value: CountryIso2) => void;
11
+ name: string;
12
+ sx?: SxProps;
13
+ };
14
+
15
+ CountrySelect.defaultProps = {
16
+ sx: {},
17
+ };
18
+
19
+ export default function CountrySelect({ value, onChange, name, sx }: CountrySelectProps) {
20
+ const { setValue } = useFormContext();
21
+ const countryDetail = useMemo(() => {
22
+ const item = defaultCountries.find((v) => v[1] === value);
23
+ return value && item ? parseCountry(item) : { name: '' };
24
+ }, [value]);
25
+
26
+ const onCountryChange = (e: any) => {
27
+ onChange(e.target.value as CountryIso2);
28
+ setValue(name, e.target.value);
29
+ };
30
+
31
+ return (
32
+ <Select
33
+ MenuProps={{
34
+ style: {
35
+ height: '300px',
36
+ top: '10px',
37
+ },
38
+ anchorOrigin: {
39
+ vertical: 'bottom',
40
+ horizontal: 'left',
41
+ },
42
+ transformOrigin: {
43
+ vertical: 'top',
44
+ horizontal: 'left',
45
+ },
46
+ }}
47
+ sx={{
48
+ width: '100%',
49
+ // Remove default outline (display only on focus)
50
+ fieldset: {
51
+ display: 'none',
52
+ },
53
+ '&.Mui-focused:has(div[aria-expanded="false"])': {
54
+ fieldset: {
55
+ display: 'block',
56
+ },
57
+ },
58
+ // Update default spacing
59
+ '.MuiSelect-select': {
60
+ padding: '8px',
61
+ paddingRight: '24px !important',
62
+ },
63
+ svg: {
64
+ right: 0,
65
+ },
66
+ '.MuiMenuItem-root': {
67
+ justifyContent: 'flex-start', // 确保内容左对齐
68
+ },
69
+ ...sx,
70
+ }}
71
+ value={value}
72
+ onChange={onCountryChange}
73
+ renderValue={(code) => {
74
+ return (
75
+ <Box display="flex" alignItems="center" flexWrap="nowrap" gap={0.5} sx={{ cursor: 'pointer' }}>
76
+ <FlagEmoji iso2={code} style={{ display: 'flex' }} />
77
+ <Typography>{countryDetail?.name}</Typography>
78
+ </Box>
79
+ );
80
+ }}>
81
+ {defaultCountries.map((c) => {
82
+ const parsed = parseCountry(c);
83
+ return (
84
+ <MenuItem key={parsed.iso2} value={parsed.iso2}>
85
+ <FlagEmoji iso2={parsed.iso2} style={{ marginRight: '8px' }} />
86
+ <Typography marginRight="8px">{parsed.name}</Typography>
87
+ <Typography color="gray">+{parsed.dialCode}</Typography>
88
+ </MenuItem>
89
+ );
90
+ })}
91
+ </Select>
92
+ );
93
+ }
@@ -1,3 +1,4 @@
1
+ import React, { forwardRef, useImperativeHandle, useRef } from 'react';
1
2
  import { Box, FormLabel, InputAdornment, TextField, TextFieldProps, Typography } from '@mui/material';
2
3
  import get from 'lodash/get';
3
4
  import { Controller, RegisterOptions, useFormContext } from 'react-hook-form';
@@ -11,15 +12,7 @@ type InputProps = TextFieldProps & {
11
12
  wrapperStyle?: React.CSSProperties;
12
13
  };
13
14
 
14
- FormInput.defaultProps = {
15
- label: '',
16
- placeholder: '',
17
- errorPosition: 'bottom',
18
- rules: {},
19
- wrapperStyle: {},
20
- };
21
-
22
- export function FormInputError({ error }: { error: string }) {
15
+ function FormInputError({ error }: { error: string }) {
23
16
  return (
24
17
  <InputAdornment position="end">
25
18
  <Typography component="span" color="error">
@@ -29,40 +22,50 @@ export function FormInputError({ error }: { error: string }) {
29
22
  );
30
23
  }
31
24
 
32
- export default function FormInput({
33
- name,
34
- label,
35
- placeholder,
36
- rules,
37
- errorPosition,
38
- wrapperStyle,
39
- ...rest
40
- }: InputProps) {
41
- const { control, formState } = useFormContext();
42
- const error = get(formState.errors, name)?.message as string;
43
- return (
44
- <Controller
45
- name={name}
46
- control={control}
47
- rules={rules}
48
- render={({ field }) => (
49
- <Box sx={{ width: '100%', ...wrapperStyle }}>
50
- {!!label && <FormLabel>{label}</FormLabel>}
51
- <TextField
52
- fullWidth
53
- error={!!get(formState.errors, name)}
54
- helperText={errorPosition === 'bottom' && error ? error : ''}
55
- placeholder={placeholder}
56
- size="small"
57
- {...field}
58
- {...rest}
59
- InputProps={Object.assign(
60
- rest.InputProps || {},
61
- errorPosition === 'right' && error ? { endAdornment: <FormInputError error={error} /> } : {}
62
- )}
63
- />
64
- </Box>
65
- )}
66
- />
67
- );
68
- }
25
+ const FormInput = forwardRef<HTMLInputElement, InputProps>(
26
+ ({ name, label, placeholder, rules, errorPosition, wrapperStyle, ...rest }, ref) => {
27
+ const { control, formState } = useFormContext();
28
+ const inputRef = useRef<HTMLInputElement | null>(null);
29
+ useImperativeHandle(ref, () => {
30
+ return inputRef.current as HTMLInputElement;
31
+ });
32
+ const error = get(formState.errors, name)?.message as string;
33
+
34
+ return (
35
+ <Controller
36
+ name={name}
37
+ control={control}
38
+ rules={rules}
39
+ render={({ field }) => (
40
+ <Box sx={{ width: '100%', ...wrapperStyle }}>
41
+ {!!label && <FormLabel sx={{ color: 'text.primary' }}>{label}</FormLabel>}
42
+ <TextField
43
+ fullWidth
44
+ error={!!get(formState.errors, name)}
45
+ helperText={errorPosition === 'bottom' && error ? error : ''}
46
+ placeholder={placeholder}
47
+ size="small"
48
+ {...field}
49
+ {...rest}
50
+ inputRef={inputRef}
51
+ InputProps={Object.assign(
52
+ rest.InputProps || {},
53
+ errorPosition === 'right' && error ? { endAdornment: <FormInputError error={error} /> } : {}
54
+ )}
55
+ />
56
+ </Box>
57
+ )}
58
+ />
59
+ );
60
+ }
61
+ );
62
+
63
+ FormInput.defaultProps = {
64
+ label: '',
65
+ placeholder: '',
66
+ errorPosition: 'bottom',
67
+ rules: {},
68
+ wrapperStyle: {},
69
+ };
70
+
71
+ export default FormInput;
@@ -12,6 +12,7 @@ export default function Livemode({ color, backgroundColor, sx }: Props) {
12
12
  <Chip
13
13
  label={t('common.livemode')}
14
14
  size="small"
15
+ color="warning"
15
16
  sx={{
16
17
  ml: 2,
17
18
  height: 18,
@@ -276,7 +276,6 @@ export default function PricingTable({ table, alignItems, interval, mode, onSele
276
276
  color="text.primary"
277
277
  fontWeight={600}
278
278
  sx={{
279
- color: '#4B5563',
280
279
  fontSize: '18px !important',
281
280
  fontWeight: '600',
282
281
  }}>
@@ -303,7 +302,6 @@ export default function PricingTable({ table, alignItems, interval, mode, onSele
303
302
  color="text.secondary"
304
303
  sx={{
305
304
  marginTop: '0px !important',
306
- color: '#4b5563',
307
305
  fontWeight: '400',
308
306
  fontSize: '16px',
309
307
  textAlign: 'left',
@@ -4,14 +4,13 @@ export default function Status(props: ChipProps) {
4
4
  return (
5
5
  <Chip
6
6
  size="small"
7
- variant="outlined"
7
+ variant="filled"
8
8
  {...props}
9
9
  sx={{
10
10
  ...(props.sx || {}),
11
11
  borderRadius: '4px',
12
12
  height: 20,
13
13
  textTransform: 'capitalize',
14
- marginRight: '10px',
15
14
  }}
16
15
  />
17
16
  );
@@ -0,0 +1,200 @@
1
+ /* eslint-disable @typescript-eslint/indent */
2
+ import React from 'react';
3
+ import Empty from '@arcblock/ux/lib/Empty';
4
+ import Datatable from '@arcblock/ux/lib/Datatable';
5
+ import { useLocaleContext } from '@arcblock/ux/lib/Locale/context';
6
+ import { styled } from '@mui/system';
7
+
8
+ import { useMobile } from '../hooks/mobile';
9
+
10
+ function EmptyStub() {
11
+ return null;
12
+ }
13
+
14
+ const Table = React.memo(
15
+ ({ options, columns, toolbar = true, footer = true, hasRowLink = false, emptyNodeText = '', ...rest }: any) => {
16
+ const { locale, t } = useLocaleContext();
17
+ const { isMobile } = useMobile();
18
+
19
+ const defaultOptions = {
20
+ print: false,
21
+ download: false,
22
+ filter: false,
23
+ selectableRows: 'none',
24
+ rowsPerPage: 10,
25
+ rowsPerPageOptions: [10, 20, 50, 100],
26
+ searchDebounceTime: 300,
27
+ tableBodyHeight: '100%',
28
+ loading: true,
29
+ };
30
+
31
+ const components: any = {};
32
+ if (!toolbar) {
33
+ components.TableToolbar = EmptyStub;
34
+ }
35
+ if (!footer) {
36
+ components.TableFooter = EmptyStub;
37
+ }
38
+
39
+ // components.TableHead = EmptyStub2
40
+ return (
41
+ <Wrapped
42
+ locale={locale}
43
+ options={{ ...defaultOptions, ...options }}
44
+ columns={columns.map((x: any) => {
45
+ x.options = x.options || {};
46
+ x.options.filter = x.options.filter || false;
47
+ x.options.sort = x.options.sort || false;
48
+ return x;
49
+ })}
50
+ emptyNode={<Empty>{emptyNodeText || t('empty.records')}</Empty>}
51
+ {...rest}
52
+ components={components}
53
+ hasRowLink={hasRowLink}
54
+ isMobile={isMobile}
55
+ />
56
+ );
57
+ }
58
+ );
59
+
60
+ const Wrapped = styled(Datatable)`
61
+ ${(props) =>
62
+ props.hasRowLink
63
+ ? `.MuiTableCell-root {
64
+ font-size: 1rem !important;
65
+ }`
66
+ : ''}
67
+ .MuiPaper-root {
68
+ border-radius: 8px;
69
+ overflow: hidden;
70
+ }
71
+ table.MuiTable-root {
72
+ outline: 1px solid var(--stroke-border-base, #eff1f5);
73
+ border-radius: var(--radius-m, 8px);
74
+ overflow: hidden;
75
+ }
76
+ [class*='MUIDataTable-responsiveBase'] {
77
+ outline: 1px solid var(--stroke-border-base, #eff1f5);
78
+ border-radius: var(--radius-m, 8px);
79
+ }
80
+
81
+ th.MuiTableCell-head {
82
+ padding: 8px 16px 8px 16px;
83
+ text-transform: inherit;
84
+ background: var(--backgrounds-bg-subtle, #f9fafb);
85
+ border-bottom: none;
86
+ &:first-of-type {
87
+ border-top-left-radius: 8px;
88
+ padding-left: 20px;
89
+ }
90
+ &:last-of-type {
91
+ border-top-right-radius: 8px;
92
+ }
93
+ }
94
+
95
+ tr.MuiTableRow-root:not(.MuiTableRow-footer):hover {
96
+ background: #f5f5f5;
97
+ }
98
+ tr.MuiTableRow-root:last-of-type td:first-of-type {
99
+ border-bottom-left-radius: 8px;
100
+ }
101
+
102
+ tr.MuiTableRow-root:last-of-type td:last-of-type {
103
+ border-bottom-right-radius: 8px;
104
+ }
105
+
106
+ tr.MuiTableRow-root:nth-of-type(even) {
107
+ background: var(--backgrounds-bg-subtle, #f9fafb);
108
+ }
109
+ td.MuiTableCell-root {
110
+ border-bottom: none;
111
+ &:first-of-type {
112
+ padding-left: 20px;
113
+ }
114
+ &.MuiTableCell-footer {
115
+ border: none;
116
+ }
117
+ }
118
+
119
+ .datatable-footer {
120
+ .MuiTableRow-root.MuiTableRow-footer {
121
+ border: none;
122
+ }
123
+ table.MuiTable-root {
124
+ outline: none;
125
+ overflow: hidden;
126
+ }
127
+ .MuiTablePagination-input {
128
+ background: none;
129
+ }
130
+ div.MuiSelect-select {
131
+ padding: 0 24px 0 0;
132
+ }
133
+ }
134
+
135
+ th a,
136
+ td a {
137
+ text-decoration: none;
138
+ display: block;
139
+ color: inherit;
140
+ &:first-of-type {
141
+ padding-left: 0;
142
+ }
143
+ }
144
+
145
+ > div {
146
+ overflow: auto;
147
+ }
148
+ @media (max-width: ${({ theme }) => theme.breakpoints.values.md}px) {
149
+ th a,
150
+ td a {
151
+ text-decoration: none;
152
+ display: block;
153
+ color: inherit;
154
+ padding-top: 0;
155
+ padding-bottom: 0;
156
+ padding-right: 0;
157
+ }
158
+ tr.MuiTableRow-root {
159
+ border: none;
160
+ padding: 20px;
161
+ display: block;
162
+ }
163
+ td.MuiTableCell-root:first-of-type {
164
+ padding-left: 0;
165
+ margin-top: 0;
166
+ }
167
+ td.MuiTableCell-root {
168
+ margin: 0;
169
+ margin-top: 8px;
170
+ align-items: center;
171
+ padding: 0;
172
+ flex-wrap: wrap;
173
+ flex-direction: ${({ mobileTDFlexDirection = 'column' }) => mobileTDFlexDirection || 'row'};
174
+ align-items: ${({ mobileTDFlexDirection = 'column' }) =>
175
+ mobileTDFlexDirection === 'column' ? 'flex-start' : 'center'};
176
+ justify-content: ${({ mobileTDFlexDirection = 'column' }) =>
177
+ mobileTDFlexDirection === 'column' ? 'flex-start' : 'space-between'};
178
+ }
179
+ td.MuiTableCell-root > div {
180
+ margin-bottom: 4px;
181
+ }
182
+ .MuiTable-root > .MuiTableBody-root > .MuiTableRow-root > td.MuiTableCell-root {
183
+ display: flex;
184
+ flex-direction: ${({ mobileTDFlexDirection = 'column' }) => mobileTDFlexDirection || 'row'};
185
+ align-items: flex-start;
186
+ justify-content: ${({ mobileTDFlexDirection = 'column' }) =>
187
+ mobileTDFlexDirection === 'row' ? 'space-between' : 'flex-start'};
188
+ flex-wrap: ${({ mobileTDFlexDirection = 'column' }) => (mobileTDFlexDirection === 'row' ? 'nowrap' : 'wrap')};
189
+ word-break: break-all;
190
+ &.datatables-noprint {
191
+ justify-content: center;
192
+ }
193
+ }
194
+ [class*='MUIDataTable-responsiveBase'] tr:not([class*='responsiveSimple']) td.MuiTableCell-body > div {
195
+ width: inherit;
196
+ }
197
+ }
198
+ `;
199
+
200
+ export default Table;
@@ -2,7 +2,7 @@ import type { TPaymentCurrency, TPaymentMethodExpanded } from '@blocklet/payment
2
2
  import { Alert } from '@mui/material';
3
3
  import { useLocalStorageState, useRequest } from 'ahooks';
4
4
  import type { Axios } from 'axios';
5
- import { createContext, useContext } from 'react';
5
+ import { createContext, useContext, useState } from 'react';
6
6
 
7
7
  import api from '../libs/api';
8
8
  import { getPrefix } from '../libs/util';
@@ -23,6 +23,8 @@ export type PaymentContextType = {
23
23
  getMethod: (methodId: string) => TPaymentMethodExpanded | undefined;
24
24
  setLivemode: (livemode: boolean) => void;
25
25
  api: Axios;
26
+ payable: boolean;
27
+ setPayable: (status: boolean) => void;
26
28
  };
27
29
 
28
30
  export type PaymentContextProps = {
@@ -60,6 +62,7 @@ function PaymentProvider({ session, connect, children, baseUrl }: PaymentContext
60
62
  const { data, error, run, loading } = useRequest(getSettings);
61
63
  const [livemode, setLivemode] = useLocalStorageState('livemode', { defaultValue: true });
62
64
  const prefix = getPrefix();
65
+ const [payable, setPayable] = useState(true);
63
66
 
64
67
  if (error) {
65
68
  return <Alert severity="error">{error.message}</Alert>;
@@ -82,6 +85,8 @@ function PaymentProvider({ session, connect, children, baseUrl }: PaymentContext
82
85
  refresh: run,
83
86
  setLivemode,
84
87
  api,
88
+ payable,
89
+ setPayable,
85
90
  }}>
86
91
  {children}
87
92
  </Provider>