@blocklet/payment-react 1.14.20 → 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 +5 -1
  20. package/es/history/invoice/list.js +218 -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 +23 -7
  28. package/es/locales/index.d.ts +0 -1
  29. package/es/locales/index.js +10 -1
  30. package/es/locales/zh.js +22 -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 +5 -1
  71. package/lib/history/invoice/list.js +293 -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 +23 -7
  79. package/lib/locales/index.d.ts +0 -1
  80. package/lib/locales/index.js +14 -3
  81. package/lib/locales/zh.js +22 -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 +258 -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 +19 -4
  120. package/src/locales/index.tsx +10 -3
  121. package/src/locales/zh.tsx +18 -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
@@ -20,7 +20,7 @@ function ProductCard({
20
20
  };
21
21
  return /* @__PURE__ */(0, _jsxRuntime.jsxs)(_material.Stack, {
22
22
  direction: "row",
23
- alignItems: "flex-start",
23
+ alignItems: "center",
24
24
  spacing: 1,
25
25
  flex: 2,
26
26
  sx: {
@@ -56,7 +56,8 @@ function ProductCard({
56
56
  sx: {
57
57
  fontWeight: 500,
58
58
  mb: 0.5,
59
- lineHeight: 1
59
+ lineHeight: 1,
60
+ fontSize: 16
60
61
  },
61
62
  color: "text.primary",
62
63
  children: name
@@ -69,14 +70,14 @@ function ProductCard({
69
70
  lineHeight: 1,
70
71
  textAlign: "left"
71
72
  },
72
- color: "text.secondary",
73
+ color: "text.lighter",
73
74
  children: description
74
75
  }), extra && /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Typography, {
75
76
  variant: "body1",
76
77
  sx: {
77
78
  fontSize: "0.85rem"
78
79
  },
79
- color: "text.secondary",
80
+ color: "text.lighter",
80
81
  children: extra
81
82
  })]
82
83
  })]
@@ -11,6 +11,7 @@ var _ahooks = require("ahooks");
11
11
  var _react = require("react");
12
12
  var _switchButton = _interopRequireDefault(require("../components/switch-button"));
13
13
  var _util = require("../libs/util");
14
+ var _payment = require("../contexts/payment");
14
15
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
15
16
  function ProductDonation({
16
17
  item,
@@ -22,6 +23,9 @@ function ProductDonation({
22
23
  t,
23
24
  locale
24
25
  } = (0, _context.useLocaleContext)();
26
+ const {
27
+ setPayable
28
+ } = (0, _payment.usePaymentContext)();
25
29
  const preset = settings.amount.preset || settings.amount.presets?.[0] || "0";
26
30
  const [state, setState] = (0, _ahooks.useSetState)({
27
31
  selected: preset,
@@ -73,6 +77,7 @@ function ProductDonation({
73
77
  input: value,
74
78
  error: (0, _util.formatAmountPrecisionLimit)(value, locale, precision)
75
79
  });
80
+ setPayable(false);
76
81
  return;
77
82
  }
78
83
  if (value < min || value > max) {
@@ -83,8 +88,10 @@ function ProductDonation({
83
88
  max
84
89
  })
85
90
  });
91
+ setPayable(false);
86
92
  return;
87
93
  }
94
+ setPayable(true);
88
95
  setState({
89
96
  error: "",
90
97
  input: value
@@ -126,7 +133,7 @@ function ProductDonation({
126
133
  sx: {
127
134
  marginRight: 2,
128
135
  marginLeft: 0.5,
129
- color: "text.secondary"
136
+ color: "text.lighter"
130
137
  }
131
138
  }), !state.custom && /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Box, {
132
139
  display: "flex",
@@ -136,7 +143,7 @@ function ProductDonation({
136
143
  children: settings.amount.presets && settings.amount.presets.length > 0 && settings.amount.presets.map(amount => /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Card, {
137
144
  variant: "outlined",
138
145
  sx: {
139
- minWidth: 120,
146
+ minWidth: 115,
140
147
  textAlign: "center",
141
148
  ...(state.selected === amount && !state.custom ? {
142
149
  borderColor: "primary.main"
@@ -1,5 +1,5 @@
1
- /// <reference types="react" />
2
1
  import type { TLineItemExpanded, TPaymentCurrency } from '@blocklet/payment-types';
2
+ import React from 'react';
3
3
  type Props = {
4
4
  item: TLineItemExpanded;
5
5
  items: TLineItemExpanded[];
@@ -10,7 +10,7 @@ type Props = {
10
10
  mode?: 'normal' | 'cross-sell';
11
11
  children?: React.ReactNode;
12
12
  };
13
- declare function ProductItem({ item, items, trialInDays, currency, mode, children, onUpsell, onDownsell, }: Props): import("react").JSX.Element;
13
+ declare function ProductItem({ item, items, trialInDays, currency, mode, children, onUpsell, onDownsell, }: Props): JSX.Element;
14
14
  declare namespace ProductItem {
15
15
  var defaultProps: {
16
16
  mode: string;
@@ -7,6 +7,7 @@ module.exports = ProductItem;
7
7
  var _jsxRuntime = require("react/jsx-runtime");
8
8
  var _context = require("@arcblock/ux/lib/Locale/context");
9
9
  var _material = require("@mui/material");
10
+ var _react = require("react");
10
11
  var _status = _interopRequireDefault(require("../components/status"));
11
12
  var _switchButton = _interopRequireDefault(require("../components/switch-button"));
12
13
  var _util = require("../libs/util");
@@ -34,6 +35,14 @@ function ProductItem({
34
35
  const saving = (0, _util.formatUpsellSaving)(items, currency);
35
36
  const metered = item.price?.recurring?.usage_type === "metered" ? t("common.metered") : "";
36
37
  const canUpsell = mode === "normal" && items.length === 1;
38
+ const primaryText = (0, _react.useMemo)(() => {
39
+ const price = item.upsell_price || item.price || {};
40
+ const isRecurring = price?.type === "recurring" && price?.recurring;
41
+ if (isRecurring && trialInDays <= 0 && price?.recurring?.usage_type !== "metered") {
42
+ return `${pricing.primary} ${price.recurring ? (0, _util.formatRecurring)(price.recurring, false, "slash", locale) : ""}`;
43
+ }
44
+ return pricing.primary;
45
+ }, [trialInDays, pricing, item, locale]);
37
46
  return /* @__PURE__ */(0, _jsxRuntime.jsxs)(_material.Stack, {
38
47
  direction: "column",
39
48
  alignItems: "flex-start",
@@ -41,15 +50,18 @@ function ProductItem({
41
50
  sx: {
42
51
  width: "100%"
43
52
  },
53
+ className: "product-item",
44
54
  children: [/* @__PURE__ */(0, _jsxRuntime.jsxs)(_material.Stack, {
45
55
  direction: "column",
46
- alignItems: "flex-end",
56
+ alignItems: "flex-start",
47
57
  sx: {
48
58
  width: "100%"
49
59
  },
60
+ className: "product-item-content",
50
61
  children: [/* @__PURE__ */(0, _jsxRuntime.jsxs)(_material.Stack, {
51
62
  direction: "row",
52
- alignItems: "flex-start",
63
+ alignItems: "center",
64
+ flexWrap: "wrap",
53
65
  spacing: 0.5,
54
66
  justifyContent: "space-between",
55
67
  sx: {
@@ -58,19 +70,12 @@ function ProductItem({
58
70
  children: [/* @__PURE__ */(0, _jsxRuntime.jsx)(_productCard.default, {
59
71
  logo: item.price.product?.images[0],
60
72
  name: item.price.product?.name,
61
- description: item.price.product?.description,
62
- extra: /* @__PURE__ */(0, _jsxRuntime.jsxs)(_material.Box, {
73
+ extra: /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Box, {
63
74
  display: "flex",
64
75
  alignItems: "center",
65
- children: [item.price.type === "recurring" && item.price.recurring ? [pricing.quantity, t("common.billed", {
76
+ children: item.price.type === "recurring" && item.price.recurring ? [pricing.quantity, t("common.billed", {
66
77
  rule: `${(0, _util.formatRecurring)(item.upsell_price?.recurring || item.price.recurring, true, "per", locale)} ${metered}`
67
- })].filter(Boolean).join(", ") : pricing.quantity, (0, _util.formatQuantityInventory)(item.price, item.quantity, locale) ? /* @__PURE__ */(0, _jsxRuntime.jsxs)(_material.Typography, {
68
- sx: {
69
- fontSize: "0.85rem",
70
- color: "red"
71
- },
72
- children: ["\uFF08", (0, _util.formatQuantityInventory)(item.price, item.quantity, locale), "\uFF09"]
73
- }) : ""]
78
+ })].filter(Boolean).join(", ") : pricing.quantity
74
79
  })
75
80
  }), /* @__PURE__ */(0, _jsxRuntime.jsxs)(_material.Stack, {
76
81
  direction: "column",
@@ -79,19 +84,29 @@ function ProductItem({
79
84
  children: [/* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Typography, {
80
85
  sx: {
81
86
  color: "text.primary",
82
- fontWeight: 500
87
+ fontWeight: 500,
88
+ whiteSpace: "nowrap"
83
89
  },
84
90
  gutterBottom: true,
85
- children: pricing.primary
91
+ children: primaryText
86
92
  }), pricing.secondary && /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Typography, {
87
93
  sx: {
88
94
  fontSize: "0.85rem",
89
- color: "text.secondary"
95
+ color: "text.lighter"
90
96
  },
91
97
  children: pricing.secondary
92
98
  })]
93
99
  })]
94
- }), children]
100
+ }), (0, _util.formatQuantityInventory)(item.price, item.quantity, locale) ? /* @__PURE__ */(0, _jsxRuntime.jsx)(_status.default, {
101
+ label: (0, _util.formatQuantityInventory)(item.price, item.quantity, locale),
102
+ variant: "outlined",
103
+ sx: {
104
+ mt: 1,
105
+ borderColor: "var(--tags-tag-red-border, #FFC8D3)",
106
+ background: "var(--tags-tag-red-bg, #FFE2E6)",
107
+ color: "var(--tags-tag-red-text, #E40031)"
108
+ }
109
+ }) : null, children]
95
110
  }), canUpsell && !item.upsell_price_id && item.price.upsell?.upsells_to && /* @__PURE__ */(0, _jsxRuntime.jsxs)(_material.Stack, {
96
111
  direction: "row",
97
112
  alignItems: "center",
@@ -99,13 +114,14 @@ function ProductItem({
99
114
  sx: {
100
115
  width: "100%"
101
116
  },
117
+ className: "product-item-upsell",
102
118
  children: [/* @__PURE__ */(0, _jsxRuntime.jsxs)(_material.Typography, {
103
119
  component: "label",
104
120
  htmlFor: "upsell-switch",
105
121
  sx: {
106
122
  fontSize: 12,
107
123
  cursor: "pointer",
108
- color: "text.primary"
124
+ color: "text.secondary"
109
125
  },
110
126
  children: [/* @__PURE__ */(0, _jsxRuntime.jsx)(_switchButton.default, {
111
127
  id: "upsell-switch",
@@ -121,10 +137,12 @@ function ProductItem({
121
137
  label: t("payment.checkout.upsell.off", {
122
138
  saving
123
139
  }),
124
- color: "primary",
125
140
  variant: "outlined",
126
141
  sx: {
127
- ml: 1
142
+ ml: 1,
143
+ borderColor: " var(--tags-tag-orange-border, #FFE467)",
144
+ background: "var(--tags-tag-orange-bg, #FFF4BC)",
145
+ color: "var(--tags-tag-orange-text, #D24000)"
128
146
  }
129
147
  })]
130
148
  }), /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Typography, {
@@ -141,6 +159,7 @@ function ProductItem({
141
159
  sx: {
142
160
  width: "100%"
143
161
  },
162
+ className: "product-item-upsell",
144
163
  children: [/* @__PURE__ */(0, _jsxRuntime.jsxs)(_material.Typography, {
145
164
  component: "label",
146
165
  htmlFor: "upsell-switch",
@@ -13,30 +13,36 @@ var _util = require("@ocap/util");
13
13
  var _ahooks = require("ahooks");
14
14
  var _noop = _interopRequireDefault(require("lodash/noop"));
15
15
  var _useBus = _interopRequireDefault(require("use-bus"));
16
+ var _ExpandMore = _interopRequireDefault(require("@mui/icons-material/ExpandMore"));
17
+ var _styles = require("@mui/material/styles");
16
18
  var _status = _interopRequireDefault(require("../components/status"));
17
19
  var _api = _interopRequireDefault(require("../libs/api"));
18
20
  var _util2 = require("../libs/util");
19
21
  var _amount = _interopRequireDefault(require("./amount"));
20
22
  var _productDonation = _interopRequireDefault(require("./product-donation"));
21
23
  var _productItem = _interopRequireDefault(require("./product-item"));
24
+ var _livemode = _interopRequireDefault(require("../components/livemode"));
25
+ var _payment = require("../contexts/payment");
26
+ var _mobile = require("../hooks/mobile");
22
27
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
23
- const shake = (0, _material.keyframes)`
24
- 0% {
25
- transform: rotate(0deg);
26
- }
27
- 25% {
28
- transform: rotate(2deg);
29
- }
30
- 50% {
31
- transform: rotate(0eg);
32
- }
33
- 75% {
34
- transform: rotate(-2deg);
35
- }
36
- 100% {
37
- transform: rotate(0deg);
38
- }
39
- `;
28
+ const ExpandMore = (0, _styles.styled)(props => {
29
+ const {
30
+ expand,
31
+ ...other
32
+ } = props;
33
+ return /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.IconButton, {
34
+ ...other
35
+ });
36
+ })(({
37
+ theme,
38
+ expand
39
+ }) => ({
40
+ transform: !expand ? "rotate(0deg)" : "rotate(180deg)",
41
+ marginLeft: "auto",
42
+ transition: theme.transitions.create("transform", {
43
+ duration: theme.transitions.duration.shortest
44
+ })
45
+ }));
40
46
  async function fetchCrossSell(id) {
41
47
  try {
42
48
  const {
@@ -107,9 +113,14 @@ function PaymentSummary({
107
113
  t,
108
114
  locale
109
115
  } = (0, _context.useLocaleContext)();
116
+ const {
117
+ isMobile
118
+ } = (0, _mobile.useMobile)();
119
+ const settings = (0, _payment.usePaymentContext)();
110
120
  const [state, setState] = (0, _ahooks.useSetState)({
111
121
  loading: false,
112
- shake: false
122
+ shake: false,
123
+ expanded: items?.length < 3
113
124
  });
114
125
  const {
115
126
  data,
@@ -117,6 +128,7 @@ function PaymentSummary({
117
128
  } = (0, _ahooks.useRequest)(() => checkoutSessionId ? fetchCrossSell(checkoutSessionId) : Promise.resolve(null));
118
129
  const headlines = (0, _util2.formatCheckoutHeadlines)(items, currency, trialInDays, locale);
119
130
  const staking = showStaking ? getStakingSetup(items, currency, billingThreshold) : "0";
131
+ const totalAmount = (0, _util.fromUnitToToken)(new _util.BN((0, _util.fromTokenToUnit)(headlines.actualAmount, currency?.decimal)).add(new _util.BN(staking)).toString(), currency?.decimal);
120
132
  (0, _useBus.default)("error.REQUIRE_CROSS_SELL", () => {
121
133
  setState({
122
134
  shake: true
@@ -165,60 +177,37 @@ function PaymentSummary({
165
177
  });
166
178
  }
167
179
  };
168
- return /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Fade, {
169
- in: true,
170
- children: /* @__PURE__ */(0, _jsxRuntime.jsxs)(_material.Stack, {
171
- className: "cko-product",
172
- direction: "column",
173
- ...rest,
174
- children: [/* @__PURE__ */(0, _jsxRuntime.jsxs)(_material.Stack, {
175
- className: "cko-product-summary",
176
- direction: "column",
177
- alignItems: "flex-start",
178
- sx: {
179
- mb: {
180
- xs: 1,
181
- sm: 3
182
- }
183
- },
184
- children: [/* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Typography, {
185
- className: "cko-ellipsis",
186
- component: "div",
187
- title: action || headlines.action,
188
- sx: {
189
- fontWeight: 500,
190
- fontSize: "1.15rem",
191
- color: "text.secondary"
192
- },
193
- children: action || headlines.action
194
- }), /* @__PURE__ */(0, _jsxRuntime.jsx)(_amount.default, {
195
- amount: headlines.amount
196
- }), headlines.then && /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Typography, {
197
- component: "div",
180
+ const ProductCardList = /* @__PURE__ */(0, _jsxRuntime.jsxs)(_material.Stack, {
181
+ className: "cko-product-list",
182
+ sx: {
183
+ flex: "0 1 auto",
184
+ overflow: "auto"
185
+ },
186
+ children: [/* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Stack, {
187
+ spacing: {
188
+ xs: 1,
189
+ sm: 2
190
+ },
191
+ children: items.map(x => x.price.custom_unit_amount && onChangeAmount && donationSettings ? /* @__PURE__ */(0, _jsxRuntime.jsx)(_productDonation.default, {
192
+ item: x,
193
+ settings: donationSettings,
194
+ onChange: onChangeAmount,
195
+ currency
196
+ }, `${x.price_id}-${currency.id}`) : /* @__PURE__ */(0, _jsxRuntime.jsx)(_productItem.default, {
197
+ item: x,
198
+ items,
199
+ trialInDays,
200
+ currency,
201
+ onUpsell: handleUpsell,
202
+ onDownsell: handleDownsell,
203
+ children: x.cross_sell && /* @__PURE__ */(0, _jsxRuntime.jsxs)(_material.Stack, {
204
+ direction: "row",
205
+ alignItems: "center",
206
+ justifyContent: "space-between",
198
207
  sx: {
199
- fontSize: "0.9rem",
200
- color: "text.secondary"
208
+ width: 1
201
209
  },
202
- children: headlines.then
203
- })]
204
- }), /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Stack, {
205
- spacing: {
206
- xs: 1,
207
- sm: 2
208
- },
209
- children: items.map(x => x.price.custom_unit_amount && onChangeAmount && donationSettings ? /* @__PURE__ */(0, _jsxRuntime.jsx)(_productDonation.default, {
210
- item: x,
211
- settings: donationSettings,
212
- onChange: onChangeAmount,
213
- currency
214
- }, `${x.price_id}-${currency.id}`) : /* @__PURE__ */(0, _jsxRuntime.jsx)(_productItem.default, {
215
- item: x,
216
- items,
217
- trialInDays,
218
- currency,
219
- onUpsell: handleUpsell,
220
- onDownsell: handleDownsell,
221
- children: x.cross_sell && /* @__PURE__ */(0, _jsxRuntime.jsx)(_lab.LoadingButton, {
210
+ children: [/* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Typography, {}), /* @__PURE__ */(0, _jsxRuntime.jsx)(_lab.LoadingButton, {
222
211
  size: "small",
223
212
  loadingPosition: "end",
224
213
  color: "error",
@@ -226,37 +215,26 @@ function PaymentSummary({
226
215
  loading: state.loading,
227
216
  onClick: handleCancelCrossSell,
228
217
  children: t("payment.checkout.cross_sell.remove")
229
- })
230
- }, `${x.price_id}-${currency.id}`))
231
- }), data && items.some(x => x.price_id === data.id) === false && /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Grow, {
232
- in: true,
233
- children: /* @__PURE__ */(0, _jsxRuntime.jsxs)(_material.Stack, {
234
- direction: "column",
235
- alignItems: "flex-end",
236
- spacing: 0.5,
237
- sx: {
238
- border: "1px solid #eee",
239
- borderRadius: 1,
240
- padding: 1,
241
- animation: state.shake ? `${shake} 0.2s 5 ease-in-out` : "none",
242
- mt: {
243
- xs: 1,
244
- sm: 2
245
- }
218
+ })]
219
+ })
220
+ }, `${x.price_id}-${currency.id}`))
221
+ }), data && items.some(x => x.price_id === data.id) === false && /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Grow, {
222
+ in: true,
223
+ children: /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Stack, {
224
+ mt: 1,
225
+ children: /* @__PURE__ */(0, _jsxRuntime.jsx)(_productItem.default, {
226
+ item: {
227
+ quantity: 1,
228
+ price: data,
229
+ price_id: data.id,
230
+ cross_sell: true
246
231
  },
247
- children: [/* @__PURE__ */(0, _jsxRuntime.jsx)(_productItem.default, {
248
- item: {
249
- quantity: 1,
250
- price: data,
251
- price_id: data.id,
252
- cross_sell: true
253
- },
254
- items,
255
- trialInDays,
256
- currency,
257
- onUpsell: _noop.default,
258
- onDownsell: _noop.default
259
- }), /* @__PURE__ */(0, _jsxRuntime.jsxs)(_material.Stack, {
232
+ items,
233
+ trialInDays,
234
+ currency,
235
+ onUpsell: _noop.default,
236
+ onDownsell: _noop.default,
237
+ children: /* @__PURE__ */(0, _jsxRuntime.jsxs)(_material.Stack, {
260
238
  direction: "row",
261
239
  alignItems: "center",
262
240
  justifyContent: "space-between",
@@ -281,44 +259,158 @@ function PaymentSummary({
281
259
  onClick: handleApplyCrossSell,
282
260
  children: t("payment.checkout.cross_sell.add")
283
261
  })]
284
- })]
262
+ })
285
263
  })
286
- }), staking > 0 && /* @__PURE__ */(0, _jsxRuntime.jsxs)(_material.Stack, {
287
- direction: "row",
288
- justifyContent: "space-between",
264
+ })
265
+ })]
266
+ });
267
+ return /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Fade, {
268
+ in: true,
269
+ children: /* @__PURE__ */(0, _jsxRuntime.jsxs)(_material.Stack, {
270
+ className: "cko-product",
271
+ direction: "column",
272
+ ...rest,
273
+ children: [/* @__PURE__ */(0, _jsxRuntime.jsxs)(_material.Box, {
274
+ display: "flex",
289
275
  alignItems: "center",
290
- spacing: 1,
291
276
  sx: {
292
- border: "1px solid #eee",
293
- borderRadius: 1,
294
- padding: 1,
295
- mt: {
296
- xs: 1,
297
- sm: 2
298
- }
277
+ mb: 2.5
299
278
  },
279
+ children: [/* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Typography, {
280
+ title: t("payment.checkout.orderSummary"),
281
+ sx: {
282
+ color: "text.primary",
283
+ fontSize: {
284
+ xs: "18px",
285
+ md: "24px"
286
+ },
287
+ fontWeight: "700",
288
+ lineHeight: "32px"
289
+ },
290
+ children: action || t("payment.checkout.orderSummary")
291
+ }), !settings.livemode && /* @__PURE__ */(0, _jsxRuntime.jsx)(_livemode.default, {})]
292
+ }), isMobile ? /* @__PURE__ */(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
300
293
  children: [/* @__PURE__ */(0, _jsxRuntime.jsxs)(_material.Stack, {
301
- direction: "row",
294
+ justifyContent: "space-between",
295
+ flexDirection: "row",
302
296
  alignItems: "center",
303
- spacing: 0.5,
297
+ mb: 1.5,
298
+ onClick: () => setState({
299
+ expanded: !state.expanded
300
+ }),
304
301
  children: [/* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Typography, {
305
- children: t("payment.checkout.staking.title")
306
- }), /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Tooltip, {
307
- title: t("payment.checkout.staking.tooltip"),
308
- placement: "top",
309
- sx: {
310
- maxWidth: "150px"
311
- },
312
- children: /* @__PURE__ */(0, _jsxRuntime.jsx)(_iconsMaterial.InfoOutlined, {
313
- fontSize: "small",
302
+ children: t("payment.checkout.productListTotal", {
303
+ total: items.length
304
+ })
305
+ }), /* @__PURE__ */(0, _jsxRuntime.jsx)(ExpandMore, {
306
+ expand: state.expanded,
307
+ "aria-expanded": state.expanded,
308
+ "aria-label": "show more",
309
+ children: /* @__PURE__ */(0, _jsxRuntime.jsx)(_ExpandMore.default, {})
310
+ })]
311
+ }), /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Collapse, {
312
+ in: state.expanded || !isMobile,
313
+ timeout: "auto",
314
+ unmountOnExit: true,
315
+ children: ProductCardList
316
+ })]
317
+ }) : ProductCardList, /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Divider, {
318
+ sx: {
319
+ mt: 2.5,
320
+ mb: 2.5
321
+ }
322
+ }), staking > 0 && /* @__PURE__ */(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
323
+ children: [/* @__PURE__ */(0, _jsxRuntime.jsxs)(_material.Stack, {
324
+ direction: "row",
325
+ justifyContent: "space-between",
326
+ alignItems: "center",
327
+ spacing: 1,
328
+ children: [/* @__PURE__ */(0, _jsxRuntime.jsxs)(_material.Stack, {
329
+ direction: "row",
330
+ alignItems: "center",
331
+ spacing: 0.5,
332
+ children: [/* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Typography, {
314
333
  sx: {
315
334
  color: "text.secondary"
316
- }
317
- })
335
+ },
336
+ children: t("payment.checkout.paymentRequired")
337
+ }), /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Tooltip, {
338
+ title: /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Typography, {
339
+ children: t("payment.checkout.stakingConfirm")
340
+ }),
341
+ placement: "top",
342
+ sx: {
343
+ maxWidth: "150px"
344
+ },
345
+ children: /* @__PURE__ */(0, _jsxRuntime.jsx)(_iconsMaterial.HelpOutline, {
346
+ fontSize: "small",
347
+ sx: {
348
+ color: "text.lighter"
349
+ }
350
+ })
351
+ })]
352
+ }), /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Typography, {
353
+ children: headlines.amount
354
+ })]
355
+ }), /* @__PURE__ */(0, _jsxRuntime.jsxs)(_material.Stack, {
356
+ direction: "row",
357
+ justifyContent: "space-between",
358
+ alignItems: "center",
359
+ spacing: 1,
360
+ children: [/* @__PURE__ */(0, _jsxRuntime.jsxs)(_material.Stack, {
361
+ direction: "row",
362
+ alignItems: "center",
363
+ spacing: 0.5,
364
+ children: [/* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Typography, {
365
+ sx: {
366
+ color: "text.secondary"
367
+ },
368
+ children: t("payment.checkout.staking.title")
369
+ }), /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Tooltip, {
370
+ title: /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Typography, {
371
+ children: t("payment.checkout.staking.tooltip")
372
+ }),
373
+ placement: "top",
374
+ sx: {
375
+ maxWidth: "150px"
376
+ },
377
+ children: /* @__PURE__ */(0, _jsxRuntime.jsx)(_iconsMaterial.HelpOutline, {
378
+ fontSize: "small",
379
+ sx: {
380
+ color: "text.lighter"
381
+ }
382
+ })
383
+ })]
384
+ }), /* @__PURE__ */(0, _jsxRuntime.jsxs)(_material.Typography, {
385
+ children: [(0, _util2.formatAmount)(staking, currency.decimal), " ", currency.symbol]
318
386
  })]
319
- }), /* @__PURE__ */(0, _jsxRuntime.jsxs)(_material.Typography, {
320
- children: [(0, _util2.formatAmount)(staking, currency.decimal), " ", currency.symbol]
321
387
  })]
388
+ }), /* @__PURE__ */(0, _jsxRuntime.jsxs)(_material.Stack, {
389
+ display: "flex",
390
+ justifyContent: "space-between",
391
+ flexDirection: "row",
392
+ alignItems: "center",
393
+ sx: {
394
+ width: "100%"
395
+ },
396
+ children: [/* @__PURE__ */(0, _jsxRuntime.jsxs)(_material.Box, {
397
+ className: "base-label",
398
+ children: [t("common.total"), " "]
399
+ }), /* @__PURE__ */(0, _jsxRuntime.jsx)(_amount.default, {
400
+ amount: `${totalAmount} ${currency.symbol}`,
401
+ sx: {
402
+ fontSize: "16px"
403
+ }
404
+ })]
405
+ }), headlines.then && headlines.showThen && /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Typography, {
406
+ component: "div",
407
+ sx: {
408
+ fontSize: "0.9rem",
409
+ color: "text.lighter",
410
+ textAlign: "right",
411
+ margin: "-2px 0 8px"
412
+ },
413
+ children: headlines.then
322
414
  })]
323
415
  })
324
416
  });