@blocklet/payment-react 1.14.21 → 1.14.23

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 (137) hide show
  1. package/README.md +77 -0
  2. package/es/checkout/donate.d.ts +4 -2
  3. package/es/checkout/donate.js +13 -10
  4. package/es/checkout/form.d.ts +1 -1
  5. package/es/checkout/form.js +50 -4
  6. package/es/checkout/table.d.ts +1 -1
  7. package/es/checkout/table.js +11 -1
  8. package/es/components/blockchain/tx.js +2 -1
  9. package/es/components/country-select.d.ts +16 -0
  10. package/es/components/country-select.js +82 -0
  11. package/es/components/input.d.ts +21 -21
  12. package/es/components/input.js +43 -42
  13. package/es/components/livemode.js +1 -0
  14. package/es/components/pricing-table.js +0 -2
  15. package/es/components/status.js +2 -3
  16. package/es/components/table.d.ts +2 -0
  17. package/es/components/table.js +186 -0
  18. package/es/contexts/payment.d.ts +2 -0
  19. package/es/contexts/payment.js +5 -2
  20. package/es/history/invoice/list.d.ts +3 -1
  21. package/es/history/invoice/list.js +215 -48
  22. package/es/hooks/mobile.d.ts +4 -0
  23. package/es/hooks/mobile.js +10 -0
  24. package/es/index.d.ts +5 -1
  25. package/es/index.js +7 -1
  26. package/es/libs/util.d.ts +21 -8
  27. package/es/libs/util.js +92 -28
  28. package/es/locales/en.js +22 -7
  29. package/es/locales/index.d.ts +0 -1
  30. package/es/locales/index.js +10 -1
  31. package/es/locales/zh.js +21 -6
  32. package/es/payment/error.js +2 -2
  33. package/es/payment/footer.js +1 -1
  34. package/es/payment/form/address.d.ts +9 -2
  35. package/es/payment/form/address.js +69 -69
  36. package/es/payment/form/currency.js +39 -25
  37. package/es/payment/form/index.d.ts +1 -1
  38. package/es/payment/form/index.js +83 -81
  39. package/es/payment/form/phone.js +15 -51
  40. package/es/payment/index.d.ts +3 -10
  41. package/es/payment/index.js +295 -224
  42. package/es/payment/product-card.js +4 -4
  43. package/es/payment/product-donation.js +9 -3
  44. package/es/payment/product-item.d.ts +2 -2
  45. package/es/payment/product-item.js +120 -81
  46. package/es/payment/summary.js +188 -118
  47. package/es/theme/index.css +240 -0
  48. package/es/theme/index.d.ts +14 -0
  49. package/es/theme/index.js +256 -0
  50. package/es/theme/typography.d.ts +2 -0
  51. package/es/theme/typography.js +53 -0
  52. package/es/types/index.d.ts +16 -0
  53. package/lib/checkout/donate.d.ts +4 -2
  54. package/lib/checkout/donate.js +23 -2
  55. package/lib/checkout/form.d.ts +1 -1
  56. package/lib/checkout/form.js +60 -15
  57. package/lib/checkout/table.d.ts +1 -1
  58. package/lib/checkout/table.js +22 -1
  59. package/lib/components/blockchain/tx.js +4 -1
  60. package/lib/components/country-select.d.ts +16 -0
  61. package/lib/components/country-select.js +115 -0
  62. package/lib/components/input.d.ts +21 -21
  63. package/lib/components/input.js +21 -12
  64. package/lib/components/livemode.js +1 -0
  65. package/lib/components/pricing-table.js +0 -2
  66. package/lib/components/status.js +2 -3
  67. package/lib/components/table.d.ts +2 -0
  68. package/lib/components/table.js +220 -0
  69. package/lib/contexts/payment.d.ts +2 -0
  70. package/lib/contexts/payment.js +4 -1
  71. package/lib/history/invoice/list.d.ts +3 -1
  72. package/lib/history/invoice/list.js +290 -62
  73. package/lib/hooks/mobile.d.ts +4 -0
  74. package/lib/hooks/mobile.js +17 -0
  75. package/lib/index.d.ts +5 -1
  76. package/lib/index.js +36 -0
  77. package/lib/libs/util.d.ts +21 -8
  78. package/lib/libs/util.js +115 -37
  79. package/lib/locales/en.js +22 -7
  80. package/lib/locales/index.d.ts +0 -1
  81. package/lib/locales/index.js +14 -3
  82. package/lib/locales/zh.js +21 -6
  83. package/lib/payment/error.js +5 -1
  84. package/lib/payment/footer.js +1 -1
  85. package/lib/payment/form/address.d.ts +9 -2
  86. package/lib/payment/form/address.js +67 -59
  87. package/lib/payment/form/currency.js +31 -24
  88. package/lib/payment/form/index.d.ts +1 -1
  89. package/lib/payment/form/index.js +92 -93
  90. package/lib/payment/form/phone.js +11 -59
  91. package/lib/payment/index.d.ts +3 -10
  92. package/lib/payment/index.js +302 -225
  93. package/lib/payment/product-card.js +5 -4
  94. package/lib/payment/product-donation.js +11 -7
  95. package/lib/payment/product-item.d.ts +2 -2
  96. package/lib/payment/product-item.js +38 -19
  97. package/lib/payment/summary.js +219 -127
  98. package/lib/theme/index.css +240 -0
  99. package/lib/theme/index.d.ts +14 -0
  100. package/lib/theme/index.js +273 -0
  101. package/lib/theme/typography.d.ts +2 -0
  102. package/lib/theme/typography.js +59 -0
  103. package/lib/types/index.d.ts +16 -0
  104. package/package.json +14 -11
  105. package/src/checkout/donate.tsx +25 -11
  106. package/src/checkout/form.tsx +63 -15
  107. package/src/checkout/table.tsx +20 -1
  108. package/src/components/blockchain/tx.tsx +2 -1
  109. package/src/components/country-select.tsx +93 -0
  110. package/src/components/input.tsx +49 -46
  111. package/src/components/livemode.tsx +1 -0
  112. package/src/components/pricing-table.tsx +0 -2
  113. package/src/components/status.tsx +1 -2
  114. package/src/components/table.tsx +200 -0
  115. package/src/contexts/payment.tsx +6 -1
  116. package/src/history/invoice/list.tsx +254 -49
  117. package/src/hooks/mobile.ts +13 -0
  118. package/src/index.ts +7 -0
  119. package/src/libs/util.ts +120 -31
  120. package/src/locales/en.tsx +18 -4
  121. package/src/locales/index.tsx +10 -3
  122. package/src/locales/zh.tsx +17 -3
  123. package/src/payment/error.tsx +2 -2
  124. package/src/payment/footer.tsx +1 -1
  125. package/src/payment/form/address.tsx +56 -47
  126. package/src/payment/form/currency.tsx +29 -23
  127. package/src/payment/form/index.tsx +89 -76
  128. package/src/payment/form/phone.tsx +14 -51
  129. package/src/payment/index.tsx +298 -231
  130. package/src/payment/product-card.tsx +4 -4
  131. package/src/payment/product-donation.tsx +9 -4
  132. package/src/payment/product-item.tsx +49 -20
  133. package/src/payment/summary.tsx +191 -108
  134. package/src/theme/index.css +240 -0
  135. package/src/theme/index.tsx +271 -0
  136. package/src/theme/typography.ts +56 -0
  137. package/src/types/index.ts +17 -0
package/README.md CHANGED
@@ -68,3 +68,80 @@ import zh from './zh';
68
68
  // eslint-disable-next-line import/prefer-default-export
69
69
  export const translations = merge({ zh, en }, extraTranslations);
70
70
  ```
71
+
72
+ ## Updates
73
+
74
+ #### theme
75
+ Since version 1.14.22, the component includes a built-in theme provider. If you need to modify the styles of internal components, you need to pass the `theme` property to override or inherit the external theme.
76
+
77
+ | option |description |
78
+ | --- | --- |
79
+ | default [default value] | wrapped with built-in PaymentThemeProvider |
80
+ | inherit | use the parent component's themeProvider |
81
+ | PaymentThemeOptions | override some styles of PaymentThemeProvider |
82
+
83
+ ```ts
84
+ export type PaymentThemeOptions = ThemeOptions & {
85
+ sx?: SxProps;
86
+ };
87
+
88
+ ```
89
+ ```js
90
+ // 1. use themeOptions
91
+ <CheckoutForm
92
+ id="plink_oB1I6FNeHKSkuq81fhJy0vIZ"
93
+ onChange={console.info}
94
+ theme={{
95
+ components: {
96
+ MuiButton: {
97
+ styleOverrides: {
98
+ containedPrimary: {
99
+ backgroundColor: '#1DC1C7',
100
+ color: '#fff',
101
+ '&:hover': {
102
+ backgroundColor: 'rgb(20, 135, 139)',
103
+ },
104
+ },
105
+ },
106
+ },
107
+ },
108
+ }}
109
+ />
110
+
111
+ // 2. use theme sx
112
+ <CheckoutForm
113
+ id="plink_oB1I6FNeHKSkuq81fhJy0vIZ"
114
+ mode="inline-minimal"
115
+ onChange={console.info}
116
+ theme={{
117
+ sx: {
118
+ '.cko-submit-button': {
119
+ backgroundColor: '#1DC1C7',
120
+ color: '#fff',
121
+ '&:hover': {
122
+ backgroundColor: 'rgb(20, 135, 139)',
123
+ },
124
+ },
125
+ },
126
+ }}
127
+ />
128
+ ```
129
+
130
+ #### showCheckoutSummary
131
+
132
+ Since version 1.14.23, if you need to hide the product column, we recommend using `showCheckoutSummary=false` instead of `mode=inline-minimal`. We aim for better semantics.
133
+ ```js
134
+ // bad
135
+ <CheckoutForm
136
+ id="plink_oB1I6FNeHKSkuq81fhJy0vIZ"
137
+ mode="inline-minimal"
138
+ onChange={console.info}
139
+ />
140
+
141
+ // good
142
+ <CheckoutForm
143
+ id="plink_oB1I6FNeHKSkuq81fhJy0vIZ"
144
+ showCheckoutSummary={false}
145
+ onChange={console.info}
146
+ />
147
+ ```
@@ -1,7 +1,7 @@
1
1
  /// <reference types="react" />
2
2
  import type { DonationSettings, TCheckoutSessionExpanded, TPaymentCurrency, TPaymentMethod } from '@blocklet/payment-types';
3
3
  import { ButtonProps as MUIButtonProps } from '@mui/material';
4
- import { CheckoutProps } from '../types';
4
+ import { CheckoutProps, PaymentThemeOptions } from '../types';
5
5
  export type DonateHistory = {
6
6
  supporters: TCheckoutSessionExpanded[];
7
7
  currency: TPaymentCurrency;
@@ -20,10 +20,12 @@ export type DonateProps = Pick<CheckoutProps, 'onPaid' | 'onError'> & {
20
20
  inlineOptions?: {
21
21
  button?: ButtonType;
22
22
  };
23
+ theme?: 'default' | 'inherit' | PaymentThemeOptions;
23
24
  };
24
- declare function CheckoutDonate({ settings, livemode, timeout, onPaid, onError, mode, inlineOptions, }: DonateProps): import("react").JSX.Element;
25
+ declare function CheckoutDonate(props: DonateProps): import("react").JSX.Element;
25
26
  declare namespace CheckoutDonate {
26
27
  var defaultProps: {
28
+ theme: string;
27
29
  livemode: boolean;
28
30
  timeout: number;
29
31
  mode: string;
@@ -25,6 +25,7 @@ import TxLink from "../components/blockchain/tx.js";
25
25
  import api from "../libs/api.js";
26
26
  import { formatAmount, formatBNStr, formatDateTime, formatError, lazyLoad } from "../libs/util.js";
27
27
  import CheckoutForm from "./form.js";
28
+ import { PaymentThemeProvider } from "../theme/index.js";
28
29
  const donationCache = {};
29
30
  const createOrUpdateDonation = (settings, livemode = true) => {
30
31
  if (!donationCache[settings.target]) {
@@ -210,15 +211,7 @@ function useDonation(settings, livemode = true, mode = "default") {
210
211
  setState
211
212
  };
212
213
  }
213
- export default function CheckoutDonate({
214
- settings,
215
- livemode,
216
- timeout,
217
- onPaid,
218
- onError,
219
- mode,
220
- inlineOptions = {}
221
- }) {
214
+ function CheckoutDonateInner({ settings, livemode, timeout, onPaid, onError, mode, inlineOptions = {} }) {
222
215
  const { state, setState, donation, supporters } = useDonation(settings, livemode, mode);
223
216
  const [anchorEl, setAnchorEl] = useState(null);
224
217
  const [popoverOpen, setPopoverOpen] = useState(false);
@@ -348,7 +341,7 @@ export default function CheckoutDonate({
348
341
  showCloseButton: true,
349
342
  disableEscapeKeyDown: true,
350
343
  onClose: (e, reason) => setState({ open: reason === "backdropClick" }),
351
- children: /* @__PURE__ */ jsx(Box, { sx: { mb: 1, mt: -2, height: "100%" }, children: /* @__PURE__ */ jsx(
344
+ children: /* @__PURE__ */ jsx(Box, { sx: { mb: 1, height: "100%" }, children: /* @__PURE__ */ jsx(
352
345
  CheckoutForm,
353
346
  {
354
347
  id: donation.data?.id,
@@ -362,7 +355,17 @@ export default function CheckoutDonate({
362
355
  )
363
356
  ] });
364
357
  }
358
+ export default function CheckoutDonate(props) {
359
+ if (props.theme === "inherit") {
360
+ return /* @__PURE__ */ jsx(CheckoutDonateInner, { ...props });
361
+ }
362
+ if (props.theme && typeof props.theme === "object") {
363
+ return /* @__PURE__ */ jsx(PaymentThemeProvider, { theme: props.theme, children: /* @__PURE__ */ jsx(CheckoutDonateInner, { ...props }) });
364
+ }
365
+ return /* @__PURE__ */ jsx(PaymentThemeProvider, { children: /* @__PURE__ */ jsx(CheckoutDonateInner, { ...props }) });
366
+ }
365
367
  CheckoutDonate.defaultProps = {
368
+ theme: "default",
366
369
  livemode: true,
367
370
  timeout: 5e3,
368
371
  mode: "default",
@@ -1,6 +1,6 @@
1
1
  /// <reference types="react" />
2
2
  import { CheckoutProps } from '../types';
3
- declare function CheckoutForm({ id, mode, onPaid, onError, onChange, goBack, extraParams, action, }: CheckoutProps): import("react").JSX.Element;
3
+ declare function CheckoutForm({ id, mode, onPaid, onError, onChange, goBack, extraParams, action, theme, ...restProps }: CheckoutProps): import("react").JSX.Element;
4
4
  declare namespace CheckoutForm {
5
5
  var defaultProps: {
6
6
  onPaid: any;
@@ -6,6 +6,7 @@ import { joinURL } from "ufo";
6
6
  import api from "../libs/api.js";
7
7
  import { getPrefix, mergeExtraParams } from "../libs/util.js";
8
8
  import Payment from "../payment/index.js";
9
+ import { PaymentThemeProvider } from "../theme/index.js";
9
10
  const promises = {};
10
11
  const startFromPaymentLink = (id, params) => {
11
12
  if (!promises[id]) {
@@ -29,7 +30,9 @@ export default function CheckoutForm({
29
30
  onChange,
30
31
  goBack,
31
32
  extraParams,
32
- action
33
+ action,
34
+ theme = "default",
35
+ ...restProps
33
36
  }) {
34
37
  if (!id.startsWith("plink_") && !id.startsWith("cs_")) {
35
38
  throw new Error("Either a checkoutSession or a paymentLink id is required.");
@@ -57,7 +60,49 @@ export default function CheckoutForm({
57
60
  setState({ appError: err });
58
61
  onError?.(err);
59
62
  };
60
- return /* @__PURE__ */ jsx(
63
+ if (theme === "inherit") {
64
+ return /* @__PURE__ */ jsx(
65
+ Payment,
66
+ {
67
+ checkoutSession: data?.checkoutSession,
68
+ paymentMethods: data?.paymentMethods,
69
+ paymentIntent: data?.paymentIntent,
70
+ paymentLink: data?.paymentLink,
71
+ customer: data?.customer,
72
+ completed: state.completed,
73
+ error: apiError || state.appError,
74
+ onPaid: handlePaid,
75
+ onError: handleError,
76
+ onChange,
77
+ goBack,
78
+ mode,
79
+ action,
80
+ ...restProps
81
+ }
82
+ );
83
+ }
84
+ if (theme && typeof theme === "object") {
85
+ return /* @__PURE__ */ jsx(PaymentThemeProvider, { theme, children: /* @__PURE__ */ jsx(
86
+ Payment,
87
+ {
88
+ checkoutSession: data?.checkoutSession,
89
+ paymentMethods: data?.paymentMethods,
90
+ paymentIntent: data?.paymentIntent,
91
+ paymentLink: data?.paymentLink,
92
+ customer: data?.customer,
93
+ completed: state.completed,
94
+ error: apiError || state.appError,
95
+ onPaid: handlePaid,
96
+ onError: handleError,
97
+ onChange,
98
+ goBack,
99
+ mode,
100
+ action,
101
+ ...restProps
102
+ }
103
+ ) });
104
+ }
105
+ return /* @__PURE__ */ jsx(PaymentThemeProvider, { children: /* @__PURE__ */ jsx(
61
106
  Payment,
62
107
  {
63
108
  checkoutSession: data?.checkoutSession,
@@ -72,9 +117,10 @@ export default function CheckoutForm({
72
117
  onChange,
73
118
  goBack,
74
119
  mode,
75
- action
120
+ action,
121
+ ...restProps
76
122
  }
77
- );
123
+ ) });
78
124
  }
79
125
  CheckoutForm.defaultProps = {
80
126
  onPaid: noop,
@@ -1,3 +1,3 @@
1
1
  /// <reference types="react" />
2
2
  import { CheckoutProps } from '../types';
3
- export default function CheckoutTable({ id, mode, onPaid, onError, onChange, extraParams, goBack }: CheckoutProps): import("react").JSX.Element;
3
+ export default function CheckoutTable(props: CheckoutProps): import("react").JSX.Element;
@@ -10,6 +10,7 @@ import PricingTable from "../components/pricing-table.js";
10
10
  import api from "../libs/api.js";
11
11
  import { mergeExtraParams } from "../libs/util.js";
12
12
  import CheckoutForm from "./form.js";
13
+ import { PaymentThemeProvider } from "../theme/index.js";
13
14
  const fetchData = async (id) => {
14
15
  const { data } = await api.get(`/api/pricing-tables/${id}`);
15
16
  return data;
@@ -20,7 +21,7 @@ const ensureProtocol = (url) => {
20
21
  }
21
22
  return url;
22
23
  };
23
- export default function CheckoutTable({ id, mode, onPaid, onError, onChange, extraParams, goBack }) {
24
+ function CheckoutTableInner({ id, mode, onPaid, onError, onChange, extraParams, goBack }) {
24
25
  if (!id.startsWith("prctbl_")) {
25
26
  throw new Error("A valid pricing table id is required.");
26
27
  }
@@ -109,3 +110,12 @@ export default function CheckoutTable({ id, mode, onPaid, onError, onChange, ext
109
110
  }
110
111
  ) });
111
112
  }
113
+ export default function CheckoutTable(props) {
114
+ if (props.theme === "inherit") {
115
+ return /* @__PURE__ */ jsx(CheckoutTableInner, { ...props });
116
+ }
117
+ if (props.theme && typeof props.theme === "object") {
118
+ return /* @__PURE__ */ jsx(PaymentThemeProvider, { theme: props.theme, children: /* @__PURE__ */ jsx(CheckoutTableInner, { ...props }) });
119
+ }
120
+ return /* @__PURE__ */ jsx(PaymentThemeProvider, { children: /* @__PURE__ */ jsx(CheckoutTableInner, { ...props }) });
121
+ }
@@ -21,9 +21,10 @@ export default function TxLink(props) {
21
21
  direction: "row",
22
22
  alignItems: "center",
23
23
  justifyContent: props.align === "left" ? "flex-start" : "flex-end",
24
+ sx: { color: "text.link" },
24
25
  spacing: 1,
25
26
  children: [
26
- /* @__PURE__ */ jsx(Typography, { component: "span", color: "primary", children: text.length > 40 ? [text.slice(0, 6), text.slice(-6)].join("...") : text }),
27
+ /* @__PURE__ */ jsx(Typography, { component: "span", color: "text.link", children: text.length > 40 ? [text.slice(0, 6), text.slice(-6)].join("...") : text }),
27
28
  /* @__PURE__ */ jsx(OpenInNewOutlined, { fontSize: "small" })
28
29
  ]
29
30
  }
@@ -0,0 +1,16 @@
1
+ /// <reference types="react" />
2
+ import { SxProps } from '@mui/material';
3
+ import { CountryIso2 } from 'react-international-phone';
4
+ export type CountrySelectProps = {
5
+ value: CountryIso2;
6
+ onChange: (value: CountryIso2) => void;
7
+ name: string;
8
+ sx?: SxProps;
9
+ };
10
+ declare function CountrySelect({ value, onChange, name, sx }: CountrySelectProps): JSX.Element;
11
+ declare namespace CountrySelect {
12
+ var defaultProps: {
13
+ sx: {};
14
+ };
15
+ }
16
+ export default CountrySelect;
@@ -0,0 +1,82 @@
1
+ import { jsx, jsxs } from "react/jsx-runtime";
2
+ import { useMemo } from "react";
3
+ import { Box, MenuItem, Select, Typography } from "@mui/material";
4
+ import { useFormContext } from "react-hook-form";
5
+ import { FlagEmoji, defaultCountries, parseCountry } from "react-international-phone";
6
+ CountrySelect.defaultProps = {
7
+ sx: {}
8
+ };
9
+ export default function CountrySelect({ value, onChange, name, sx }) {
10
+ const { setValue } = useFormContext();
11
+ const countryDetail = useMemo(() => {
12
+ const item = defaultCountries.find((v) => v[1] === value);
13
+ return value && item ? parseCountry(item) : { name: "" };
14
+ }, [value]);
15
+ const onCountryChange = (e) => {
16
+ onChange(e.target.value);
17
+ setValue(name, e.target.value);
18
+ };
19
+ return /* @__PURE__ */ jsx(
20
+ Select,
21
+ {
22
+ MenuProps: {
23
+ style: {
24
+ height: "300px",
25
+ top: "10px"
26
+ },
27
+ anchorOrigin: {
28
+ vertical: "bottom",
29
+ horizontal: "left"
30
+ },
31
+ transformOrigin: {
32
+ vertical: "top",
33
+ horizontal: "left"
34
+ }
35
+ },
36
+ sx: {
37
+ width: "100%",
38
+ // Remove default outline (display only on focus)
39
+ fieldset: {
40
+ display: "none"
41
+ },
42
+ '&.Mui-focused:has(div[aria-expanded="false"])': {
43
+ fieldset: {
44
+ display: "block"
45
+ }
46
+ },
47
+ // Update default spacing
48
+ ".MuiSelect-select": {
49
+ padding: "8px",
50
+ paddingRight: "24px !important"
51
+ },
52
+ svg: {
53
+ right: 0
54
+ },
55
+ ".MuiMenuItem-root": {
56
+ justifyContent: "flex-start"
57
+ // 确保内容左对齐
58
+ },
59
+ ...sx
60
+ },
61
+ value,
62
+ onChange: onCountryChange,
63
+ renderValue: (code) => {
64
+ return /* @__PURE__ */ jsxs(Box, { display: "flex", alignItems: "center", flexWrap: "nowrap", gap: 0.5, sx: { cursor: "pointer" }, children: [
65
+ /* @__PURE__ */ jsx(FlagEmoji, { iso2: code, style: { display: "flex" } }),
66
+ /* @__PURE__ */ jsx(Typography, { children: countryDetail?.name })
67
+ ] });
68
+ },
69
+ children: defaultCountries.map((c) => {
70
+ const parsed = parseCountry(c);
71
+ return /* @__PURE__ */ jsxs(MenuItem, { value: parsed.iso2, children: [
72
+ /* @__PURE__ */ jsx(FlagEmoji, { iso2: parsed.iso2, style: { marginRight: "8px" } }),
73
+ /* @__PURE__ */ jsx(Typography, { marginRight: "8px", children: parsed.name }),
74
+ /* @__PURE__ */ jsxs(Typography, { color: "gray", children: [
75
+ "+",
76
+ parsed.dialCode
77
+ ] })
78
+ ] }, parsed.iso2);
79
+ })
80
+ }
81
+ );
82
+ }
@@ -1,25 +1,25 @@
1
1
  /// <reference types="react" />
2
- import { TextFieldProps } from '@mui/material';
3
2
  import { RegisterOptions } from 'react-hook-form';
4
- type InputProps = TextFieldProps & {
3
+ declare const FormInput: import("react").ForwardRefExoticComponent<(Omit<import("@mui/material").OutlinedTextFieldProps & {
5
4
  name: string;
6
- label?: string;
7
- placeholder?: string;
8
- errorPosition?: 'right' | 'bottom';
9
- rules?: RegisterOptions;
10
- wrapperStyle?: React.CSSProperties;
11
- };
12
- export declare function FormInputError({ error }: {
13
- error: string;
14
- }): import("react").JSX.Element;
15
- declare function FormInput({ name, label, placeholder, rules, errorPosition, wrapperStyle, ...rest }: InputProps): import("react").JSX.Element;
16
- declare namespace FormInput {
17
- var defaultProps: {
18
- label: string;
19
- placeholder: string;
20
- errorPosition: string;
21
- rules: {};
22
- wrapperStyle: {};
23
- };
24
- }
5
+ label?: string | undefined;
6
+ placeholder?: string | undefined;
7
+ errorPosition?: "bottom" | "right" | undefined;
8
+ rules?: RegisterOptions<import("react-hook-form").FieldValues, string> | undefined;
9
+ wrapperStyle?: any;
10
+ }, "ref"> | Omit<import("@mui/material").FilledTextFieldProps & {
11
+ name: string;
12
+ label?: string | undefined;
13
+ placeholder?: string | undefined;
14
+ errorPosition?: "bottom" | "right" | undefined;
15
+ rules?: RegisterOptions<import("react-hook-form").FieldValues, string> | undefined;
16
+ wrapperStyle?: any;
17
+ }, "ref"> | Omit<import("@mui/material").StandardTextFieldProps & {
18
+ name: string;
19
+ label?: string | undefined;
20
+ placeholder?: string | undefined;
21
+ errorPosition?: "bottom" | "right" | undefined;
22
+ rules?: RegisterOptions<import("react-hook-form").FieldValues, string> | undefined;
23
+ wrapperStyle?: any;
24
+ }, "ref">) & import("react").RefAttributes<HTMLInputElement>>;
25
25
  export default FormInput;
@@ -1,7 +1,49 @@
1
1
  import { jsx, jsxs } from "react/jsx-runtime";
2
+ import { forwardRef, useImperativeHandle, useRef } from "react";
2
3
  import { Box, FormLabel, InputAdornment, TextField, Typography } from "@mui/material";
3
4
  import get from "lodash/get";
4
5
  import { Controller, useFormContext } from "react-hook-form";
6
+ function FormInputError({ error }) {
7
+ return /* @__PURE__ */ jsx(InputAdornment, { position: "end", children: /* @__PURE__ */ jsx(Typography, { component: "span", color: "error", children: error }) });
8
+ }
9
+ const FormInput = forwardRef(
10
+ ({ name, label, placeholder, rules, errorPosition, wrapperStyle, ...rest }, ref) => {
11
+ const { control, formState } = useFormContext();
12
+ const inputRef = useRef(null);
13
+ useImperativeHandle(ref, () => {
14
+ return inputRef.current;
15
+ });
16
+ const error = get(formState.errors, name)?.message;
17
+ return /* @__PURE__ */ jsx(
18
+ Controller,
19
+ {
20
+ name,
21
+ control,
22
+ rules,
23
+ render: ({ field }) => /* @__PURE__ */ jsxs(Box, { sx: { width: "100%", ...wrapperStyle }, children: [
24
+ !!label && /* @__PURE__ */ jsx(FormLabel, { sx: { color: "text.primary" }, children: label }),
25
+ /* @__PURE__ */ jsx(
26
+ TextField,
27
+ {
28
+ fullWidth: true,
29
+ error: !!get(formState.errors, name),
30
+ helperText: errorPosition === "bottom" && error ? error : "",
31
+ placeholder,
32
+ size: "small",
33
+ ...field,
34
+ ...rest,
35
+ inputRef,
36
+ InputProps: Object.assign(
37
+ rest.InputProps || {},
38
+ errorPosition === "right" && error ? { endAdornment: /* @__PURE__ */ jsx(FormInputError, { error }) } : {}
39
+ )
40
+ }
41
+ )
42
+ ] })
43
+ }
44
+ );
45
+ }
46
+ );
5
47
  FormInput.defaultProps = {
6
48
  label: "",
7
49
  placeholder: "",
@@ -9,45 +51,4 @@ FormInput.defaultProps = {
9
51
  rules: {},
10
52
  wrapperStyle: {}
11
53
  };
12
- export function FormInputError({ error }) {
13
- return /* @__PURE__ */ jsx(InputAdornment, { position: "end", children: /* @__PURE__ */ jsx(Typography, { component: "span", color: "error", children: error }) });
14
- }
15
- export default function FormInput({
16
- name,
17
- label,
18
- placeholder,
19
- rules,
20
- errorPosition,
21
- wrapperStyle,
22
- ...rest
23
- }) {
24
- const { control, formState } = useFormContext();
25
- const error = get(formState.errors, name)?.message;
26
- return /* @__PURE__ */ jsx(
27
- Controller,
28
- {
29
- name,
30
- control,
31
- rules,
32
- render: ({ field }) => /* @__PURE__ */ jsxs(Box, { sx: { width: "100%", ...wrapperStyle }, children: [
33
- !!label && /* @__PURE__ */ jsx(FormLabel, { children: label }),
34
- /* @__PURE__ */ jsx(
35
- TextField,
36
- {
37
- fullWidth: true,
38
- error: !!get(formState.errors, name),
39
- helperText: errorPosition === "bottom" && error ? error : "",
40
- placeholder,
41
- size: "small",
42
- ...field,
43
- ...rest,
44
- InputProps: Object.assign(
45
- rest.InputProps || {},
46
- errorPosition === "right" && error ? { endAdornment: /* @__PURE__ */ jsx(FormInputError, { error }) } : {}
47
- )
48
- }
49
- )
50
- ] })
51
- }
52
- );
53
- }
54
+ export default FormInput;
@@ -8,6 +8,7 @@ export default function Livemode({ color, backgroundColor, sx }) {
8
8
  {
9
9
  label: t("common.livemode"),
10
10
  size: "small",
11
+ color: "warning",
11
12
  sx: {
12
13
  ml: 2,
13
14
  height: 18,
@@ -254,7 +254,6 @@ export default function PricingTable({ table, alignItems, interval, mode, onSele
254
254
  color: "text.primary",
255
255
  fontWeight: 600,
256
256
  sx: {
257
- color: "#4B5563",
258
257
  fontSize: "18px !important",
259
258
  fontWeight: "600"
260
259
  },
@@ -288,7 +287,6 @@ export default function PricingTable({ table, alignItems, interval, mode, onSele
288
287
  color: "text.secondary",
289
288
  sx: {
290
289
  marginTop: "0px !important",
291
- color: "#4b5563",
292
290
  fontWeight: "400",
293
291
  fontSize: "16px",
294
292
  textAlign: "left"
@@ -5,14 +5,13 @@ export default function Status(props) {
5
5
  Chip,
6
6
  {
7
7
  size: "small",
8
- variant: "outlined",
8
+ variant: "filled",
9
9
  ...props,
10
10
  sx: {
11
11
  ...props.sx || {},
12
12
  borderRadius: "4px",
13
13
  height: 20,
14
- textTransform: "capitalize",
15
- marginRight: "10px"
14
+ textTransform: "capitalize"
16
15
  }
17
16
  }
18
17
  );
@@ -0,0 +1,2 @@
1
+ declare const Table: any;
2
+ export default Table;