@blocklet/payment-react 1.18.56 → 1.19.1

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 (251) hide show
  1. package/es/checkout/donate.d.ts +1 -15
  2. package/es/checkout/donate.js +301 -189
  3. package/es/checkout/form.d.ts +1 -15
  4. package/es/checkout/form.js +5 -13
  5. package/es/checkout/table.js +3 -3
  6. package/es/components/blockchain/gas.d.ts +1 -5
  7. package/es/components/blockchain/gas.js +10 -2
  8. package/es/components/blockchain/tx.d.ts +1 -8
  9. package/es/components/blockchain/tx.js +29 -10
  10. package/es/components/confirm.d.ts +1 -10
  11. package/es/components/confirm.js +4 -10
  12. package/es/components/country-select.d.ts +3 -2
  13. package/es/components/country-select.js +375 -352
  14. package/es/components/date-range-picker.d.ts +13 -0
  15. package/es/components/date-range-picker.js +279 -0
  16. package/es/components/input.d.ts +14 -20
  17. package/es/components/input.js +51 -44
  18. package/es/components/label.d.ts +7 -0
  19. package/es/components/label.js +49 -0
  20. package/es/components/lazy-loader.js +1 -2
  21. package/es/components/link.d.ts +2 -9
  22. package/es/components/link.js +9 -6
  23. package/es/components/livemode.d.ts +2 -8
  24. package/es/components/livemode.js +1 -5
  25. package/es/components/loading-button.d.ts +6 -1
  26. package/es/components/loading-button.js +56 -66
  27. package/es/components/over-due-invoice-payment.d.ts +0 -18
  28. package/es/components/over-due-invoice-payment.js +138 -95
  29. package/es/components/payment-beneficiaries.d.ts +2 -7
  30. package/es/components/payment-beneficiaries.js +86 -40
  31. package/es/components/pricing-item.d.ts +0 -5
  32. package/es/components/pricing-item.js +1 -4
  33. package/es/components/pricing-table.d.ts +2 -10
  34. package/es/components/pricing-table.js +8 -7
  35. package/es/components/resume-subscription.d.ts +0 -10
  36. package/es/components/resume-subscription.js +42 -21
  37. package/es/components/truncated-text.d.ts +2 -9
  38. package/es/components/truncated-text.js +0 -5
  39. package/es/contexts/donate.d.ts +0 -7
  40. package/es/contexts/donate.js +10 -8
  41. package/es/contexts/payment.d.ts +1 -4
  42. package/es/contexts/payment.js +7 -2
  43. package/es/history/credit/grants-list.d.ts +14 -0
  44. package/es/history/credit/grants-list.js +215 -0
  45. package/es/history/credit/transactions-list.d.ts +13 -0
  46. package/es/history/credit/transactions-list.js +255 -0
  47. package/es/history/invoice/list.d.ts +2 -18
  48. package/es/history/invoice/list.js +172 -74
  49. package/es/history/payment/list.js +115 -38
  50. package/es/hooks/keyboard.d.ts +1 -1
  51. package/es/hooks/keyboard.js +2 -4
  52. package/es/index.d.ts +5 -1
  53. package/es/index.js +10 -1
  54. package/es/libs/cached-request.js +2 -4
  55. package/es/libs/phone-validator.js +1 -2
  56. package/es/libs/util.d.ts +2 -0
  57. package/es/libs/util.js +14 -4
  58. package/es/libs/validator.js +2 -4
  59. package/es/locales/en.js +20 -2
  60. package/es/locales/zh.js +20 -2
  61. package/es/payment/amount.d.ts +2 -7
  62. package/es/payment/amount.js +1 -5
  63. package/es/payment/donation-form.d.ts +2 -10
  64. package/es/payment/donation-form.js +196 -160
  65. package/es/payment/error.d.ts +2 -8
  66. package/es/payment/error.js +40 -20
  67. package/es/payment/footer.d.ts +2 -3
  68. package/es/payment/footer.js +19 -6
  69. package/es/payment/form/addon.js +14 -4
  70. package/es/payment/form/address.d.ts +2 -9
  71. package/es/payment/form/address.js +3 -6
  72. package/es/payment/form/currency.js +45 -25
  73. package/es/payment/form/index.d.ts +2 -8
  74. package/es/payment/form/index.js +151 -71
  75. package/es/payment/form/phone.js +2 -4
  76. package/es/payment/form/stripe/form.d.ts +2 -8
  77. package/es/payment/form/stripe/form.js +1 -3
  78. package/es/payment/header.js +38 -16
  79. package/es/payment/index.d.ts +2 -9
  80. package/es/payment/index.js +23 -17
  81. package/es/payment/product-card.d.ts +2 -11
  82. package/es/payment/product-card.js +84 -50
  83. package/es/payment/product-donation.js +175 -114
  84. package/es/payment/product-item.d.ts +9 -9
  85. package/es/payment/product-item.js +320 -145
  86. package/es/payment/product-skeleton.js +2 -2
  87. package/es/payment/skeleton/donation.js +27 -7
  88. package/es/payment/skeleton/overview.js +22 -2
  89. package/es/payment/skeleton/payment.js +33 -5
  90. package/es/payment/success.d.ts +2 -9
  91. package/es/payment/success.js +41 -14
  92. package/es/payment/summary.d.ts +4 -17
  93. package/es/payment/summary.js +193 -111
  94. package/es/theme/index.d.ts +0 -5
  95. package/es/theme/index.js +2 -5
  96. package/es/theme/typography.d.ts +2 -2
  97. package/lib/checkout/donate.d.ts +1 -15
  98. package/lib/checkout/donate.js +75 -54
  99. package/lib/checkout/form.d.ts +1 -15
  100. package/lib/checkout/form.js +7 -15
  101. package/lib/checkout/table.js +4 -4
  102. package/lib/components/blockchain/gas.d.ts +1 -5
  103. package/lib/components/blockchain/gas.js +3 -2
  104. package/lib/components/blockchain/tx.d.ts +1 -8
  105. package/lib/components/blockchain/tx.js +15 -10
  106. package/lib/components/confirm.d.ts +1 -10
  107. package/lib/components/confirm.js +5 -11
  108. package/lib/components/country-select.d.ts +3 -2
  109. package/lib/components/country-select.js +23 -22
  110. package/lib/components/date-range-picker.d.ts +13 -0
  111. package/lib/components/date-range-picker.js +329 -0
  112. package/lib/components/input.d.ts +14 -20
  113. package/lib/components/input.js +28 -27
  114. package/lib/components/label.d.ts +7 -0
  115. package/lib/components/label.js +60 -0
  116. package/lib/components/lazy-loader.js +1 -1
  117. package/lib/components/link.d.ts +2 -9
  118. package/lib/components/link.js +3 -8
  119. package/lib/components/livemode.d.ts +2 -8
  120. package/lib/components/livemode.js +3 -7
  121. package/lib/components/loading-button.d.ts +6 -1
  122. package/lib/components/loading-button.js +9 -17
  123. package/lib/components/over-due-invoice-payment.d.ts +0 -18
  124. package/lib/components/over-due-invoice-payment.js +31 -33
  125. package/lib/components/payment-beneficiaries.d.ts +2 -7
  126. package/lib/components/payment-beneficiaries.js +12 -11
  127. package/lib/components/pricing-item.d.ts +0 -5
  128. package/lib/components/pricing-item.js +2 -5
  129. package/lib/components/pricing-table.d.ts +2 -10
  130. package/lib/components/pricing-table.js +5 -11
  131. package/lib/components/resume-subscription.d.ts +0 -10
  132. package/lib/components/resume-subscription.js +16 -16
  133. package/lib/components/table.js +1 -1
  134. package/lib/components/truncated-text.d.ts +2 -9
  135. package/lib/components/truncated-text.js +1 -6
  136. package/lib/contexts/donate.d.ts +0 -7
  137. package/lib/contexts/donate.js +4 -7
  138. package/lib/contexts/payment.d.ts +1 -4
  139. package/lib/contexts/payment.js +4 -7
  140. package/lib/history/credit/grants-list.d.ts +14 -0
  141. package/lib/history/credit/grants-list.js +277 -0
  142. package/lib/history/credit/transactions-list.d.ts +13 -0
  143. package/lib/history/credit/transactions-list.js +301 -0
  144. package/lib/history/invoice/list.d.ts +2 -18
  145. package/lib/history/invoice/list.js +73 -37
  146. package/lib/history/payment/list.js +30 -16
  147. package/lib/hooks/keyboard.d.ts +1 -1
  148. package/lib/hooks/mobile.js +1 -1
  149. package/lib/hooks/subscription.js +1 -1
  150. package/lib/index.d.ts +5 -1
  151. package/lib/index.js +41 -2
  152. package/lib/libs/api.js +1 -1
  153. package/lib/libs/dayjs.js +1 -1
  154. package/lib/libs/phone-validator.js +0 -2
  155. package/lib/libs/theme.js +1 -1
  156. package/lib/libs/util.d.ts +2 -0
  157. package/lib/libs/util.js +15 -1
  158. package/lib/libs/validator.js +1 -1
  159. package/lib/locales/en.js +21 -3
  160. package/lib/locales/index.js +1 -1
  161. package/lib/locales/zh.js +21 -3
  162. package/lib/payment/amount.d.ts +2 -7
  163. package/lib/payment/amount.js +2 -6
  164. package/lib/payment/donation-form.d.ts +2 -10
  165. package/lib/payment/donation-form.js +33 -38
  166. package/lib/payment/error.d.ts +2 -8
  167. package/lib/payment/error.js +11 -13
  168. package/lib/payment/footer.d.ts +2 -3
  169. package/lib/payment/footer.js +5 -5
  170. package/lib/payment/form/addon.js +5 -3
  171. package/lib/payment/form/address.d.ts +2 -9
  172. package/lib/payment/form/address.js +5 -8
  173. package/lib/payment/form/currency.js +3 -3
  174. package/lib/payment/form/index.d.ts +2 -8
  175. package/lib/payment/form/index.js +64 -21
  176. package/lib/payment/form/phone.js +1 -1
  177. package/lib/payment/form/stripe/form.d.ts +2 -8
  178. package/lib/payment/form/stripe/form.js +3 -6
  179. package/lib/payment/header.js +8 -4
  180. package/lib/payment/index.d.ts +2 -9
  181. package/lib/payment/index.js +27 -18
  182. package/lib/payment/product-card.d.ts +2 -11
  183. package/lib/payment/product-card.js +13 -20
  184. package/lib/payment/product-donation.js +71 -66
  185. package/lib/payment/product-item.d.ts +9 -9
  186. package/lib/payment/product-item.js +168 -29
  187. package/lib/payment/product-skeleton.js +2 -2
  188. package/lib/payment/skeleton/donation.js +8 -4
  189. package/lib/payment/skeleton/overview.js +6 -2
  190. package/lib/payment/skeleton/payment.js +9 -3
  191. package/lib/payment/success.d.ts +2 -9
  192. package/lib/payment/success.js +12 -15
  193. package/lib/payment/summary.d.ts +4 -17
  194. package/lib/payment/summary.js +53 -45
  195. package/lib/theme/index.d.ts +0 -5
  196. package/lib/theme/index.js +2 -5
  197. package/lib/theme/typography.d.ts +2 -2
  198. package/package.json +40 -40
  199. package/src/checkout/donate.tsx +103 -35
  200. package/src/checkout/form.tsx +5 -14
  201. package/src/checkout/table.tsx +3 -3
  202. package/src/components/blockchain/gas.tsx +5 -3
  203. package/src/components/blockchain/tx.tsx +19 -11
  204. package/src/components/confirm.tsx +4 -11
  205. package/src/components/country-select.tsx +391 -378
  206. package/src/components/date-range-picker.tsx +310 -0
  207. package/src/components/input.tsx +61 -46
  208. package/src/components/label.tsx +58 -0
  209. package/src/components/link.tsx +9 -7
  210. package/src/components/livemode.tsx +2 -6
  211. package/src/components/loading-button.tsx +63 -76
  212. package/src/components/over-due-invoice-payment.tsx +43 -28
  213. package/src/components/payment-beneficiaries.tsx +33 -14
  214. package/src/components/pricing-item.tsx +1 -4
  215. package/src/components/pricing-table.tsx +8 -8
  216. package/src/components/resume-subscription.tsx +20 -14
  217. package/src/components/table.tsx +2 -2
  218. package/src/components/truncated-text.tsx +0 -6
  219. package/src/contexts/donate.tsx +6 -7
  220. package/src/contexts/payment.tsx +7 -3
  221. package/src/history/credit/grants-list.tsx +276 -0
  222. package/src/history/credit/transactions-list.tsx +317 -0
  223. package/src/history/invoice/list.tsx +92 -36
  224. package/src/history/payment/list.tsx +53 -16
  225. package/src/hooks/keyboard.ts +1 -1
  226. package/src/index.ts +9 -0
  227. package/src/libs/util.ts +14 -0
  228. package/src/locales/en.tsx +20 -0
  229. package/src/locales/zh.tsx +19 -0
  230. package/src/payment/amount.tsx +1 -6
  231. package/src/payment/donation-form.tsx +47 -29
  232. package/src/payment/error.tsx +16 -8
  233. package/src/payment/footer.tsx +11 -3
  234. package/src/payment/form/addon.tsx +6 -1
  235. package/src/payment/form/address.tsx +3 -7
  236. package/src/payment/form/currency.tsx +12 -2
  237. package/src/payment/form/index.tsx +121 -45
  238. package/src/payment/form/stripe/form.tsx +1 -5
  239. package/src/payment/header.tsx +14 -2
  240. package/src/payment/index.tsx +27 -22
  241. package/src/payment/product-card.tsx +41 -18
  242. package/src/payment/product-donation.tsx +85 -47
  243. package/src/payment/product-item.tsx +198 -28
  244. package/src/payment/product-skeleton.tsx +3 -2
  245. package/src/payment/skeleton/donation.tsx +12 -2
  246. package/src/payment/skeleton/overview.tsx +12 -2
  247. package/src/payment/skeleton/payment.tsx +16 -3
  248. package/src/payment/success.tsx +26 -15
  249. package/src/payment/summary.tsx +87 -44
  250. package/src/theme/index.tsx +5 -8
  251. package/src/theme/typography.ts +2 -2
@@ -1,10 +1,12 @@
1
1
  import { jsx, jsxs } from "react/jsx-runtime";
2
2
  import { useLocaleContext } from "@arcblock/ux/lib/Locale/context";
3
- import { Box, Stack, Typography } from "@mui/material";
4
- import { useMemo } from "react";
3
+ import { Box, Stack, Typography, IconButton, TextField, Alert } from "@mui/material";
4
+ import { Add, Remove } from "@mui/icons-material";
5
+ import { useMemo, useState } from "react";
5
6
  import Status from "../components/status.js";
6
7
  import Switch from "../components/switch-button.js";
7
8
  import {
9
+ findCurrency,
8
10
  formatLineItemPricing,
9
11
  formatPrice,
10
12
  formatQuantityInventory,
@@ -13,27 +15,87 @@ import {
13
15
  } from "../libs/util.js";
14
16
  import ProductCard from "./product-card.js";
15
17
  import dayjs from "../libs/dayjs.js";
16
- ProductItem.defaultProps = {
17
- mode: "normal",
18
- children: null,
19
- trialEnd: 0
20
- };
18
+ import { usePaymentContext } from "../contexts/payment.js";
21
19
  export default function ProductItem({
22
20
  item,
23
21
  items,
24
22
  trialInDays,
25
23
  trialEnd = 0,
26
24
  currency,
27
- mode,
28
- children,
25
+ mode = "normal",
26
+ children = null,
29
27
  onUpsell,
30
- onDownsell
28
+ onDownsell,
29
+ completed = false,
30
+ adjustableQuantity = { enabled: false },
31
+ onQuantityChange = () => {
32
+ }
31
33
  }) {
32
34
  const { t, locale } = useLocaleContext();
35
+ const { settings } = usePaymentContext();
33
36
  const pricing = formatLineItemPricing(item, currency, { trialEnd, trialInDays }, locale);
34
37
  const saving = formatUpsellSaving(items, currency);
35
38
  const metered = item.price?.recurring?.usage_type === "metered" ? t("common.metered") : "";
36
39
  const canUpsell = mode === "normal" && items.length === 1;
40
+ const isCreditProduct = item.price.product?.type === "credit" && item.price.metadata?.credit_config?.credit_amount;
41
+ const creditAmount = isCreditProduct ? Number(item.price.metadata.credit_config.credit_amount) : 0;
42
+ const creditCurrency = isCreditProduct ? findCurrency(settings.paymentMethods, item.price.metadata?.credit_config?.currency_id ?? "") : null;
43
+ const validDuration = item.price.metadata?.credit_config?.valid_duration_value;
44
+ const validDurationUnit = item.price.metadata?.credit_config?.valid_duration_unit || "days";
45
+ const [localQuantity, setLocalQuantity] = useState(item.quantity);
46
+ const canAdjustQuantity = adjustableQuantity.enabled && mode === "normal";
47
+ const minQuantity = Math.max(adjustableQuantity.minimum || 1, 1);
48
+ const quantityAvailable = Math.min(item.price.quantity_limit_per_checkout, item.price.quantity_available);
49
+ const maxQuantity = Math.min(adjustableQuantity.maximum || 999, quantityAvailable || 999);
50
+ const handleQuantityChange = (newQuantity) => {
51
+ if (newQuantity >= minQuantity && newQuantity <= maxQuantity) {
52
+ setLocalQuantity(newQuantity);
53
+ if (formatQuantityInventory(item.price, newQuantity, locale)) {
54
+ return;
55
+ }
56
+ onQuantityChange(item.price_id, newQuantity);
57
+ }
58
+ };
59
+ const handleQuantityIncrease = () => {
60
+ if (localQuantity < maxQuantity) {
61
+ handleQuantityChange(localQuantity + 1);
62
+ }
63
+ };
64
+ const handleQuantityDecrease = () => {
65
+ if (localQuantity > minQuantity) {
66
+ handleQuantityChange(localQuantity - 1);
67
+ }
68
+ };
69
+ const handleQuantityInputChange = (event) => {
70
+ const value = parseInt(event.target.value, 10);
71
+ if (!Number.isNaN(value)) {
72
+ handleQuantityChange(value);
73
+ }
74
+ };
75
+ const formatCreditInfo = () => {
76
+ if (!isCreditProduct) return null;
77
+ const isRecurring = item.price.type === "recurring";
78
+ const totalCredit = creditAmount * localQuantity;
79
+ let message = "";
80
+ if (isRecurring) {
81
+ message = t("payment.checkout.credit.recurringInfo", {
82
+ amount: totalCredit,
83
+ period: formatRecurring(item.price.recurring, true, "per", locale)
84
+ });
85
+ } else {
86
+ message = t("payment.checkout.credit.oneTimeInfo", {
87
+ amount: totalCredit,
88
+ symbol: creditCurrency?.symbol || "Credits"
89
+ });
90
+ }
91
+ if (validDuration && validDuration > 0) {
92
+ message += `\uFF0C${t("payment.checkout.credit.expiresIn", {
93
+ duration: validDuration,
94
+ unit: t(`common.${validDurationUnit}`)
95
+ })}`;
96
+ }
97
+ return message;
98
+ };
37
99
  const primaryText = useMemo(() => {
38
100
  const price = item.upsell_price || item.price || {};
39
101
  const isRecurring = price?.type === "recurring" && price?.recurring;
@@ -43,140 +105,253 @@ export default function ProductItem({
43
105
  }
44
106
  return pricing.primary;
45
107
  }, [trialInDays, trialEnd, pricing, item, locale]);
46
- return /* @__PURE__ */ jsxs(Stack, { direction: "column", alignItems: "flex-start", spacing: 1, sx: { width: "100%" }, className: "product-item", children: [
47
- /* @__PURE__ */ jsxs(Stack, { direction: "column", alignItems: "flex-start", sx: { width: "100%" }, className: "product-item-content", children: [
48
- /* @__PURE__ */ jsxs(
49
- Stack,
50
- {
51
- direction: "row",
52
- alignItems: "center",
53
- flexWrap: "wrap",
54
- spacing: 0.5,
55
- justifyContent: "space-between",
56
- sx: { width: "100%" },
57
- children: [
58
- /* @__PURE__ */ jsx(
59
- ProductCard,
60
- {
61
- logo: item.price.product?.images[0],
62
- name: item.price.product?.name,
63
- extra: /* @__PURE__ */ jsx(Box, { display: "flex", alignItems: "center", children: item.price.type === "recurring" && item.price.recurring ? [pricing.quantity, t("common.billed", { rule: `${formatRecurring(item.upsell_price?.recurring || item.price.recurring, true, "per", locale)} ${metered}` })].filter(Boolean).join(", ") : pricing.quantity })
64
- }
65
- ),
66
- /* @__PURE__ */ jsxs(Stack, { direction: "column", alignItems: "flex-end", flex: 1, children: [
67
- /* @__PURE__ */ jsx(Typography, { sx: { color: "text.primary", fontWeight: 500, whiteSpace: "nowrap" }, gutterBottom: true, children: primaryText }),
68
- pricing.secondary && /* @__PURE__ */ jsx(Typography, { sx: { fontSize: "0.74375rem", color: "text.lighter" }, children: pricing.secondary })
69
- ] })
70
- ]
71
- }
72
- ),
73
- formatQuantityInventory(item.price, item.quantity, locale) ? /* @__PURE__ */ jsx(
74
- Status,
75
- {
76
- label: formatQuantityInventory(item.price, item.quantity, locale),
77
- variant: "outlined",
78
- sx: {
79
- mt: 1,
80
- borderColor: "chip.error.border",
81
- backgroundColor: "chip.error.background",
82
- color: "chip.error.text"
83
- }
84
- }
85
- ) : null,
86
- children
87
- ] }),
88
- canUpsell && !item.upsell_price_id && item.price.upsell?.upsells_to && /* @__PURE__ */ jsxs(
89
- Stack,
90
- {
91
- direction: "row",
92
- alignItems: "center",
93
- justifyContent: "space-between",
94
- sx: { width: "100%" },
95
- className: "product-item-upsell",
96
- children: [
97
- /* @__PURE__ */ jsxs(
98
- Typography,
99
- {
100
- component: "label",
101
- htmlFor: "upsell-switch",
102
- sx: {
103
- fontSize: 12,
104
- cursor: "pointer",
105
- color: "text.secondary"
106
- },
107
- children: [
108
- /* @__PURE__ */ jsx(
109
- Switch,
110
- {
111
- id: "upsell-switch",
112
- sx: { mr: 1 },
113
- variant: "success",
114
- checked: false,
115
- onChange: () => onUpsell(item.price_id, item.price.upsell?.upsells_to_id)
108
+ const quantityInventoryError = formatQuantityInventory(item.price, localQuantity, locale);
109
+ return /* @__PURE__ */ jsxs(
110
+ Stack,
111
+ {
112
+ direction: "column",
113
+ spacing: 1,
114
+ className: "product-item",
115
+ sx: {
116
+ alignItems: "flex-start",
117
+ width: "100%"
118
+ },
119
+ children: [
120
+ /* @__PURE__ */ jsxs(
121
+ Stack,
122
+ {
123
+ direction: "column",
124
+ className: "product-item-content",
125
+ sx: {
126
+ alignItems: "flex-start",
127
+ width: "100%"
128
+ },
129
+ children: [
130
+ /* @__PURE__ */ jsxs(
131
+ Stack,
132
+ {
133
+ direction: "row",
134
+ spacing: 0.5,
135
+ sx: {
136
+ alignItems: "center",
137
+ flexWrap: "wrap",
138
+ justifyContent: "space-between",
139
+ width: "100%"
140
+ },
141
+ children: [
142
+ /* @__PURE__ */ jsx(
143
+ ProductCard,
144
+ {
145
+ logo: item.price.product?.images[0],
146
+ name: item.price.product?.name,
147
+ extra: /* @__PURE__ */ jsx(
148
+ Box,
149
+ {
150
+ sx: {
151
+ display: "flex",
152
+ alignItems: "center"
153
+ },
154
+ children: item.price.type === "recurring" && item.price.recurring ? [pricing.quantity, t("common.billed", { rule: `${formatRecurring(item.upsell_price?.recurring || item.price.recurring, true, "per", locale)} ${metered}` })].filter(Boolean).join(", ") : pricing.quantity
155
+ }
156
+ )
157
+ }
158
+ ),
159
+ /* @__PURE__ */ jsxs(
160
+ Stack,
161
+ {
162
+ direction: "column",
163
+ sx: {
164
+ alignItems: "flex-end",
165
+ flex: 1
166
+ },
167
+ children: [
168
+ /* @__PURE__ */ jsx(Typography, { sx: { color: "text.primary", fontWeight: 500, whiteSpace: "nowrap" }, gutterBottom: true, children: primaryText }),
169
+ pricing.secondary && /* @__PURE__ */ jsx(Typography, { sx: { fontSize: "0.74375rem", color: "text.lighter" }, children: pricing.secondary })
170
+ ]
171
+ }
172
+ )
173
+ ]
174
+ }
175
+ ),
176
+ quantityInventoryError ? /* @__PURE__ */ jsx(
177
+ Status,
178
+ {
179
+ label: quantityInventoryError,
180
+ variant: "outlined",
181
+ sx: {
182
+ mt: 1,
183
+ borderColor: "chip.error.border",
184
+ backgroundColor: "chip.error.background",
185
+ color: "chip.error.text"
116
186
  }
117
- ),
118
- t("payment.checkout.upsell.save", {
119
- recurring: formatRecurring(item.price.upsell.upsells_to.recurring, true, "per", locale)
120
- }),
121
- /* @__PURE__ */ jsx(
122
- Status,
123
- {
124
- label: t("payment.checkout.upsell.off", { saving }),
125
- variant: "outlined",
126
- sx: {
127
- ml: 1,
128
- borderColor: "chip.warning.border",
129
- backgroundColor: "chip.warning.background",
130
- color: "chip.warning.text"
131
- }
132
- }
133
- )
134
- ]
135
- }
136
- ),
137
- /* @__PURE__ */ jsx(Typography, { component: "span", sx: { fontSize: 12 }, children: formatPrice(item.price.upsell.upsells_to, currency, item.price.product?.unit_label, 1, true, locale) })
138
- ]
139
- }
140
- ),
141
- canUpsell && item.upsell_price_id && /* @__PURE__ */ jsxs(
142
- Stack,
143
- {
144
- direction: "row",
145
- alignItems: "center",
146
- justifyContent: "space-between",
147
- sx: { width: "100%" },
148
- className: "product-item-upsell",
149
- children: [
150
- /* @__PURE__ */ jsxs(
151
- Typography,
152
- {
153
- component: "label",
154
- htmlFor: "upsell-switch",
155
- sx: {
156
- fontSize: 12,
157
- cursor: "pointer",
158
- color: "text.secondary"
159
- },
160
- children: [
161
- /* @__PURE__ */ jsx(
162
- Switch,
163
- {
164
- id: "upsell-switch",
165
- sx: { mr: 1 },
166
- variant: "success",
167
- checked: true,
168
- onChange: () => onDownsell(item.upsell_price_id)
169
- }
170
- ),
171
- t("payment.checkout.upsell.revert", {
172
- recurring: t(`common.${formatRecurring(item.price.recurring)}`)
173
- })
174
- ]
175
- }
176
- ),
177
- /* @__PURE__ */ jsx(Typography, { component: "span", sx: { fontSize: 12 }, children: formatPrice(item.price, currency, item.price.product?.unit_label, 1, true, locale) })
178
- ]
179
- }
180
- )
181
- ] });
187
+ }
188
+ ) : null,
189
+ canAdjustQuantity && !completed && /* @__PURE__ */ jsx(Box, { sx: { mt: 1, p: 1 }, children: /* @__PURE__ */ jsxs(
190
+ Stack,
191
+ {
192
+ direction: "row",
193
+ spacing: 1,
194
+ sx: {
195
+ alignItems: "center"
196
+ },
197
+ children: [
198
+ /* @__PURE__ */ jsxs(
199
+ Typography,
200
+ {
201
+ variant: "body2",
202
+ sx: {
203
+ color: "text.secondary",
204
+ minWidth: "fit-content"
205
+ },
206
+ children: [
207
+ t("common.quantity"),
208
+ ":"
209
+ ]
210
+ }
211
+ ),
212
+ /* @__PURE__ */ jsx(
213
+ IconButton,
214
+ {
215
+ size: "small",
216
+ onClick: handleQuantityDecrease,
217
+ disabled: localQuantity <= minQuantity,
218
+ sx: { minWidth: 32, width: 32, height: 32 },
219
+ children: /* @__PURE__ */ jsx(Remove, { fontSize: "small" })
220
+ }
221
+ ),
222
+ /* @__PURE__ */ jsx(
223
+ TextField,
224
+ {
225
+ size: "small",
226
+ value: localQuantity,
227
+ onChange: handleQuantityInputChange,
228
+ sx: { width: 60 },
229
+ type: "number",
230
+ slotProps: {
231
+ htmlInput: {
232
+ min: minQuantity,
233
+ max: maxQuantity,
234
+ style: { textAlign: "center", padding: "4px" }
235
+ }
236
+ }
237
+ }
238
+ ),
239
+ /* @__PURE__ */ jsx(
240
+ IconButton,
241
+ {
242
+ size: "small",
243
+ onClick: handleQuantityIncrease,
244
+ disabled: localQuantity >= maxQuantity,
245
+ sx: { minWidth: 32, width: 32, height: 32 },
246
+ children: /* @__PURE__ */ jsx(Add, { fontSize: "small" })
247
+ }
248
+ )
249
+ ]
250
+ }
251
+ ) }),
252
+ isCreditProduct && /* @__PURE__ */ jsx(Alert, { severity: "info", sx: { mt: 1, fontSize: "0.875rem" }, icon: false, children: formatCreditInfo() }),
253
+ children
254
+ ]
255
+ }
256
+ ),
257
+ canUpsell && !item.upsell_price_id && item.price.upsell?.upsells_to && /* @__PURE__ */ jsxs(
258
+ Stack,
259
+ {
260
+ direction: "row",
261
+ className: "product-item-upsell",
262
+ sx: {
263
+ alignItems: "center",
264
+ justifyContent: "space-between",
265
+ width: "100%"
266
+ },
267
+ children: [
268
+ /* @__PURE__ */ jsxs(
269
+ Typography,
270
+ {
271
+ component: "label",
272
+ htmlFor: "upsell-switch",
273
+ sx: {
274
+ fontSize: 12,
275
+ cursor: "pointer",
276
+ color: "text.secondary"
277
+ },
278
+ children: [
279
+ /* @__PURE__ */ jsx(
280
+ Switch,
281
+ {
282
+ id: "upsell-switch",
283
+ sx: { mr: 1 },
284
+ variant: "success",
285
+ checked: false,
286
+ onChange: () => onUpsell(item.price_id, item.price.upsell?.upsells_to_id)
287
+ }
288
+ ),
289
+ t("payment.checkout.upsell.save", {
290
+ recurring: formatRecurring(item.price.upsell.upsells_to.recurring, true, "per", locale)
291
+ }),
292
+ /* @__PURE__ */ jsx(
293
+ Status,
294
+ {
295
+ label: t("payment.checkout.upsell.off", { saving }),
296
+ variant: "outlined",
297
+ sx: {
298
+ ml: 1,
299
+ borderColor: "chip.warning.border",
300
+ backgroundColor: "chip.warning.background",
301
+ color: "chip.warning.text"
302
+ }
303
+ }
304
+ )
305
+ ]
306
+ }
307
+ ),
308
+ /* @__PURE__ */ jsx(Typography, { component: "span", sx: { fontSize: 12 }, children: formatPrice(item.price.upsell.upsells_to, currency, item.price.product?.unit_label, 1, true, locale) })
309
+ ]
310
+ }
311
+ ),
312
+ canUpsell && item.upsell_price_id && /* @__PURE__ */ jsxs(
313
+ Stack,
314
+ {
315
+ direction: "row",
316
+ className: "product-item-upsell",
317
+ sx: {
318
+ alignItems: "center",
319
+ justifyContent: "space-between",
320
+ width: "100%"
321
+ },
322
+ children: [
323
+ /* @__PURE__ */ jsxs(
324
+ Typography,
325
+ {
326
+ component: "label",
327
+ htmlFor: "upsell-switch",
328
+ sx: {
329
+ fontSize: 12,
330
+ cursor: "pointer",
331
+ color: "text.secondary"
332
+ },
333
+ children: [
334
+ /* @__PURE__ */ jsx(
335
+ Switch,
336
+ {
337
+ id: "upsell-switch",
338
+ sx: { mr: 1 },
339
+ variant: "success",
340
+ checked: true,
341
+ onChange: () => onDownsell(item.upsell_price_id)
342
+ }
343
+ ),
344
+ t("payment.checkout.upsell.revert", {
345
+ recurring: t(`common.${formatRecurring(item.price.recurring)}`)
346
+ })
347
+ ]
348
+ }
349
+ ),
350
+ /* @__PURE__ */ jsx(Typography, { component: "span", sx: { fontSize: 12 }, children: formatPrice(item.price, currency, item.price.product?.unit_label, 1, true, locale) })
351
+ ]
352
+ }
353
+ )
354
+ ]
355
+ }
356
+ );
182
357
  }
@@ -5,10 +5,10 @@ export default function ProductSkeleton({ count }) {
5
5
  Stack,
6
6
  {
7
7
  direction: "column",
8
- alignItems: "center",
9
- padding: 4,
10
8
  spacing: 1,
11
9
  sx: {
10
+ alignItems: "center",
11
+ padding: 4,
12
12
  width: 320,
13
13
  border: "1px solid",
14
14
  borderColor: "grey.100",
@@ -19,12 +19,32 @@ export default function DonationSkeleton() {
19
19
  }
20
20
  }
21
21
  ),
22
- /* @__PURE__ */ jsxs(Stack, { direction: "row", justifyContent: "space-between", spacing: 2, children: [
23
- /* @__PURE__ */ jsx(Skeleton, { variant: "text", sx: { fontSize: "1.5rem", width: "40%" } }),
24
- /* @__PURE__ */ jsxs(Box, { display: "flex", alignItems: "center", gap: 2, children: [
25
- /* @__PURE__ */ jsx(Box, { children: /* @__PURE__ */ jsx(Skeleton, { height: 60, width: 80 }) }),
26
- /* @__PURE__ */ jsx(Box, { children: /* @__PURE__ */ jsx(Skeleton, { height: 60, width: 120 }) })
27
- ] })
28
- ] })
22
+ /* @__PURE__ */ jsxs(
23
+ Stack,
24
+ {
25
+ direction: "row",
26
+ spacing: 2,
27
+ sx: {
28
+ justifyContent: "space-between"
29
+ },
30
+ children: [
31
+ /* @__PURE__ */ jsx(Skeleton, { variant: "text", sx: { fontSize: "1.5rem", width: "40%" } }),
32
+ /* @__PURE__ */ jsxs(
33
+ Box,
34
+ {
35
+ sx: {
36
+ display: "flex",
37
+ alignItems: "center",
38
+ gap: 2
39
+ },
40
+ children: [
41
+ /* @__PURE__ */ jsx(Box, { children: /* @__PURE__ */ jsx(Skeleton, { height: 60, width: 80 }) }),
42
+ /* @__PURE__ */ jsx(Box, { children: /* @__PURE__ */ jsx(Skeleton, { height: 60, width: 120 }) })
43
+ ]
44
+ }
45
+ )
46
+ ]
47
+ }
48
+ )
29
49
  ] }) });
30
50
  }
@@ -2,9 +2,29 @@ import { jsx, jsxs } from "react/jsx-runtime";
2
2
  import { Fade, Skeleton, Stack, Typography } from "@mui/material";
3
3
  export default function OverviewSkeleton() {
4
4
  return /* @__PURE__ */ jsx(Fade, { in: true, children: /* @__PURE__ */ jsxs(Stack, { direction: "column", children: [
5
- /* @__PURE__ */ jsx(Stack, { direction: "row", alignItems: "center", spacing: 2, children: /* @__PURE__ */ jsx(Skeleton, { variant: "text", sx: { fontSize: "1.75rem", width: "40%" } }) }),
5
+ /* @__PURE__ */ jsx(
6
+ Stack,
7
+ {
8
+ direction: "row",
9
+ spacing: 2,
10
+ sx: {
11
+ alignItems: "center"
12
+ },
13
+ children: /* @__PURE__ */ jsx(Skeleton, { variant: "text", sx: { fontSize: "1.75rem", width: "40%" } })
14
+ }
15
+ ),
6
16
  /* @__PURE__ */ jsx(Skeleton, { sx: { mt: 2 }, variant: "rounded", height: 100 }),
7
- /* @__PURE__ */ jsx(Typography, { mt: 2, component: "div", variant: "h4", children: /* @__PURE__ */ jsx(Skeleton, {}) }),
17
+ /* @__PURE__ */ jsx(
18
+ Typography,
19
+ {
20
+ component: "div",
21
+ variant: "h4",
22
+ sx: {
23
+ mt: 2
24
+ },
25
+ children: /* @__PURE__ */ jsx(Skeleton, {})
26
+ }
27
+ ),
8
28
  /* @__PURE__ */ jsx(Typography, { component: "div", variant: "h2", children: /* @__PURE__ */ jsx(Skeleton, {}) })
9
29
  ] }) });
10
30
  }
@@ -4,12 +4,40 @@ export default function PaymentSkeleton() {
4
4
  return /* @__PURE__ */ jsx(Fade, { in: true, children: /* @__PURE__ */ jsxs(Stack, { direction: "column", children: [
5
5
  /* @__PURE__ */ jsx(Skeleton, { variant: "text", sx: { fontSize: "1.75rem", width: "40%" } }),
6
6
  /* @__PURE__ */ jsx(Skeleton, { sx: { mt: 2 }, variant: "rounded", height: 68 }),
7
- /* @__PURE__ */ jsxs(Box, { mt: 1, children: [
8
- /* @__PURE__ */ jsx(Typography, { component: "div", variant: "h4", mb: -1, children: /* @__PURE__ */ jsx(Skeleton, {}) }),
9
- /* @__PURE__ */ jsx(Typography, { component: "div", children: /* @__PURE__ */ jsx(Skeleton, { height: 60 }) })
10
- ] }),
7
+ /* @__PURE__ */ jsxs(
8
+ Box,
9
+ {
10
+ sx: {
11
+ mt: 1
12
+ },
13
+ children: [
14
+ /* @__PURE__ */ jsx(
15
+ Typography,
16
+ {
17
+ component: "div",
18
+ variant: "h4",
19
+ sx: {
20
+ mb: -1
21
+ },
22
+ children: /* @__PURE__ */ jsx(Skeleton, {})
23
+ }
24
+ ),
25
+ /* @__PURE__ */ jsx(Typography, { component: "div", children: /* @__PURE__ */ jsx(Skeleton, { height: 60 }) })
26
+ ]
27
+ }
28
+ ),
11
29
  /* @__PURE__ */ jsxs(Box, { children: [
12
- /* @__PURE__ */ jsx(Typography, { component: "div", variant: "h4", mb: -1, children: /* @__PURE__ */ jsx(Skeleton, {}) }),
30
+ /* @__PURE__ */ jsx(
31
+ Typography,
32
+ {
33
+ component: "div",
34
+ variant: "h4",
35
+ sx: {
36
+ mb: -1
37
+ },
38
+ children: /* @__PURE__ */ jsx(Skeleton, {})
39
+ }
40
+ ),
13
41
  /* @__PURE__ */ jsx(Typography, { component: "div", children: /* @__PURE__ */ jsx(Skeleton, { height: 60 }) })
14
42
  ] }),
15
43
  /* @__PURE__ */ jsx(Box, { children: /* @__PURE__ */ jsx(Skeleton, { height: 60 }) })
@@ -7,12 +7,5 @@ type Props = {
7
7
  subscriptionId?: string;
8
8
  subscriptions?: any[];
9
9
  };
10
- declare function PaymentSuccess({ mode, message, action, payee, invoiceId, subscriptionId, subscriptions, }: Props): import("react").JSX.Element;
11
- declare namespace PaymentSuccess {
12
- var defaultProps: {
13
- invoiceId: string;
14
- subscriptionId: string;
15
- subscriptions: never[];
16
- };
17
- }
18
- export default PaymentSuccess;
10
+ export default function PaymentSuccess({ mode, message, action, payee, invoiceId, subscriptionId, subscriptions, }: Props): import("react").JSX.Element;
11
+ export {};