@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
package/lib/libs/util.js CHANGED
@@ -14,11 +14,14 @@ exports.formatDateTime = formatDateTime;
14
14
  exports.formatError = void 0;
15
15
  exports.formatLineItemPricing = formatLineItemPricing;
16
16
  exports.formatLocale = void 0;
17
+ exports.formatMeteredThen = formatMeteredThen;
17
18
  exports.formatNumber = formatNumber;
18
19
  exports.formatPriceAmount = exports.formatPrice = exports.formatPrettyMsLocale = void 0;
20
+ exports.formatPriceDisplay = formatPriceDisplay;
19
21
  exports.formatQuantityInventory = formatQuantityInventory;
20
22
  exports.formatRecurring = formatRecurring;
21
23
  exports.formatSubscriptionProduct = formatSubscriptionProduct;
24
+ exports.formatSubscriptionStatus = formatSubscriptionStatus;
22
25
  exports.formatTime = formatTime;
23
26
  exports.formatToDate = formatToDate;
24
27
  exports.formatToDatetime = formatToDatetime;
@@ -471,17 +474,48 @@ function formatUpsellSaving(items, currency) {
471
474
  const after = new _util.BN(to.total);
472
475
  return Number(before.sub(after).mul(new _util.BN(100)).div(before).toString()).toFixed(0);
473
476
  }
477
+ function formatMeteredThen(subscription, recurring, hasMetered, locale = "en") {
478
+ if (hasMetered) {
479
+ return (0, _locales.t)("payment.checkout.meteredThen", locale, {
480
+ subscription,
481
+ recurring
482
+ });
483
+ }
484
+ return (0, _locales.t)("payment.checkout.then", locale, {
485
+ subscription,
486
+ recurring
487
+ });
488
+ }
489
+ function formatPriceDisplay({
490
+ amount,
491
+ then,
492
+ actualAmount,
493
+ showThen
494
+ }, recurring, hasMetered, locale = "en") {
495
+ if (Number(actualAmount) === 0 && hasMetered) {
496
+ return (0, _locales.t)("payment.checkout.metered", locale, {
497
+ recurring
498
+ });
499
+ }
500
+ if (showThen) {
501
+ return [amount, then].filter(Boolean).join(", ");
502
+ }
503
+ return [amount, then].filter(Boolean).join(" ");
504
+ }
474
505
  function formatCheckoutHeadlines(items, currency, trialInDays, locale = "en") {
475
506
  const brand = getStatementDescriptor(items);
476
507
  const {
477
508
  total
478
509
  } = getCheckoutAmount(items, currency, trialInDays > 0);
510
+ const actualAmount = (0, _util.fromUnitToToken)(total, currency.decimal);
479
511
  const amount = `${(0, _util.fromUnitToToken)(total, currency.decimal)} ${currency.symbol}`;
480
512
  if (items.length === 0) {
481
513
  return {
482
514
  action: (0, _locales.t)("payment.checkout.empty", locale),
483
515
  amount: "0",
484
- then: ""
516
+ then: "",
517
+ actualAmount: "0",
518
+ priceDisplay: "0"
485
519
  };
486
520
  }
487
521
  const {
@@ -496,19 +530,23 @@ function formatCheckoutHeadlines(items, currency, trialInDays, locale = "en") {
496
530
  if (items.length > 1) {
497
531
  return {
498
532
  action,
499
- amount
533
+ amount,
534
+ actualAmount,
535
+ priceDisplay: amount
500
536
  };
501
537
  }
502
538
  return {
503
539
  action,
504
540
  amount,
505
- then: ""
541
+ then: "",
542
+ actualAmount,
543
+ priceDisplay: amount
506
544
  };
507
545
  }
508
546
  const item = items.find(x => x.price.type === "recurring");
509
547
  const recurring = formatRecurring((item?.upsell_price || item?.price)?.recurring, false, "per", locale);
548
+ const hasMetered = items.some(x => x.price.type === "recurring" && x.price.recurring?.usage_type === "metered");
510
549
  if (items.every(x => x.price.type === "recurring")) {
511
- const hasMetered = items.some(x => x.price.type === "recurring" && x.price.recurring?.usage_type === "metered");
512
550
  const subscription2 = [hasMetered ? (0, _locales.t)("payment.checkout.least", locale) : "", (0, _util.fromUnitToToken)(items.reduce((acc, x) => {
513
551
  if (x.price.recurring?.usage_type === "metered") {
514
552
  return acc;
@@ -517,7 +555,7 @@ function formatCheckoutHeadlines(items, currency, trialInDays, locale = "en") {
517
555
  }, new _util.BN(0)), currency.decimal), currency.symbol].filter(Boolean).join(" ");
518
556
  if (items.length > 1) {
519
557
  if (trialInDays > 0) {
520
- return {
558
+ const result4 = {
521
559
  action: (0, _locales.t)("payment.checkout.try2", locale, {
522
560
  name,
523
561
  count: items.length - 1
@@ -525,41 +563,63 @@ function formatCheckoutHeadlines(items, currency, trialInDays, locale = "en") {
525
563
  amount: (0, _locales.t)("payment.checkout.free", locale, {
526
564
  count: trialInDays
527
565
  }),
528
- then: (0, _locales.t)("payment.checkout.then", locale, {
529
- subscription: subscription2,
530
- recurring
531
- })
566
+ then: formatMeteredThen(subscription2, recurring, hasMetered && Number(subscription2) === 0, locale),
567
+ showThen: true,
568
+ actualAmount: "0"
569
+ };
570
+ return {
571
+ ...result4,
572
+ priceDisplay: formatPriceDisplay(result4, recurring, hasMetered, locale)
532
573
  };
533
574
  }
534
- return {
575
+ const result3 = {
535
576
  action: (0, _locales.t)("payment.checkout.sub2", locale, {
536
577
  name,
537
578
  count: items.length - 1
538
579
  }),
539
580
  amount,
540
- then: recurring
581
+ then: hasMetered ? (0, _locales.t)("payment.checkout.meteredThen", locale, {
582
+ recurring
583
+ }) : recurring,
584
+ showThen: hasMetered,
585
+ actualAmount
586
+ };
587
+ return {
588
+ ...result3,
589
+ priceDisplay: formatPriceDisplay(result3, recurring, hasMetered, locale)
541
590
  };
542
591
  }
543
592
  if (trialInDays > 0) {
544
- return {
593
+ const result3 = {
545
594
  action: (0, _locales.t)("payment.checkout.try1", locale, {
546
595
  name
547
596
  }),
548
597
  amount: (0, _locales.t)("payment.checkout.free", locale, {
549
598
  count: trialInDays
550
599
  }),
551
- then: (0, _locales.t)("payment.checkout.then", locale, {
552
- subscription: subscription2,
553
- recurring
554
- })
600
+ then: formatMeteredThen(subscription2, recurring, hasMetered && Number(subscription2) === 0, locale),
601
+ showThen: true,
602
+ actualAmount: "0"
603
+ };
604
+ return {
605
+ ...result3,
606
+ priceDisplay: formatPriceDisplay(result3, recurring, hasMetered, locale)
555
607
  };
556
608
  }
557
- return {
609
+ const result2 = {
558
610
  action: (0, _locales.t)("payment.checkout.sub1", locale, {
559
611
  name
560
612
  }),
561
613
  amount,
562
- then: recurring
614
+ then: hasMetered ? (0, _locales.t)("payment.checkout.meteredThen", locale, {
615
+ recurring
616
+ }) : recurring,
617
+ showThen: hasMetered,
618
+ actualAmount
619
+ };
620
+ return {
621
+ ...result2,
622
+ priceDisplay: formatPriceDisplay(result2, recurring, hasMetered, locale)
563
623
  };
564
624
  }
565
625
  const subscription = (0, _util.fromUnitToToken)(items.filter(x => x.price.type === "recurring").reduce((acc, x) => {
@@ -568,15 +628,18 @@ function formatCheckoutHeadlines(items, currency, trialInDays, locale = "en") {
568
628
  }
569
629
  return acc.add(new _util.BN(getPriceUintAmountByCurrency(x.price, currency)).mul(new _util.BN(x.quantity)));
570
630
  }, new _util.BN(0)), currency.decimal);
571
- return {
631
+ const result = {
572
632
  action: (0, _locales.t)("payment.checkout.pay", locale, {
573
633
  payee: brand
574
634
  }),
575
635
  amount,
576
- then: (0, _locales.t)("payment.checkout.then", locale, {
577
- subscription: `${subscription} ${currency.symbol}`,
578
- recurring
579
- })
636
+ then: formatMeteredThen(`${subscription} ${currency.symbol}`, recurring, hasMetered && Number(subscription) === 0, locale),
637
+ showThen: true,
638
+ actualAmount
639
+ };
640
+ return {
641
+ ...result,
642
+ priceDisplay: formatPriceDisplay(result, recurring, hasMetered, locale)
580
643
  };
581
644
  }
582
645
  function formatAmount(amount, decimals) {
@@ -615,24 +678,29 @@ function formatSubscriptionProduct(items, maxLength = 2) {
615
678
  return names.slice(0, maxLength).join(", ") + (names.length > maxLength ? ` and ${names.length - maxLength} more` : "");
616
679
  }
617
680
  const getSubscriptionTimeSummary = subscription => {
618
- const lines = [`Started on ${formatToDate(subscription.start_date * 1e3)}`];
681
+ const lines = [`Start on ${formatToDate(subscription.start_date * 1e3, "en", "YYYY-MM-DD")}`];
682
+ const getLineTimeMessage = time => {
683
+ const curDay = (0, _dayjs.default)().isSame((0, _dayjs.default)(time), "day");
684
+ const timeFormat = curDay ? "HH:mm:ss" : "YYYY-MM-DD";
685
+ return `${curDay ? "in" : "on"} ${formatToDate(time, "en", timeFormat)}`;
686
+ };
619
687
  if (subscription.status === "active" || subscription.status === "trialing") {
620
688
  if (subscription.cancel_at) {
621
- lines.push(`will cancel on ${formatToDate(subscription.cancel_at * 1e3)}`);
689
+ lines.push(`Ended ${getLineTimeMessage(subscription.cancel_at * 1e3)}`);
622
690
  } else if (subscription.cancel_at_period_end) {
623
- lines.push(`will cancel on ${formatToDate(subscription.current_period_end * 1e3)}`);
691
+ lines.push(`Ended ${getLineTimeMessage(subscription.current_period_end * 1e3)}`);
624
692
  } else {
625
- lines.push(`will renew on ${formatToDate(subscription.current_period_end * 1e3)}`);
693
+ lines.push(`Renew ${getLineTimeMessage(subscription.current_period_end * 1e3)}`);
626
694
  }
627
695
  } else if (subscription.status === "past_due") {
628
- lines.push(`will cancel on ${formatToDate((subscription.cancel_at || subscription.current_period_end) * 1e3)}`);
696
+ lines.push(`Ended ${getLineTimeMessage((subscription.cancel_at || subscription.current_period_end) * 1e3)}`);
629
697
  } else if (subscription.status === "canceled") {
630
- lines.push(`canceled on ${formatToDate(subscription.canceled_at * 1e3)}`);
698
+ lines.push(`Ended ${getLineTimeMessage(subscription.canceled_at * 1e3)}`);
631
699
  }
632
- return lines.join(", ");
700
+ return lines.join(",");
633
701
  };
634
702
  exports.getSubscriptionTimeSummary = getSubscriptionTimeSummary;
635
- const getSubscriptionAction = subscription => {
703
+ const getSubscriptionAction = (subscription, actionProps) => {
636
704
  if (subscription.status === "active" || subscription.status === "trialing") {
637
705
  if (subscription.cancel_at_period_end) {
638
706
  if (subscription.cancelation_details?.reason === "payment_failed") {
@@ -642,7 +710,8 @@ const getSubscriptionAction = subscription => {
642
710
  action: "recover",
643
711
  variant: "contained",
644
712
  color: "primary",
645
- canRenew: false
713
+ canRenew: false,
714
+ ...actionProps?.recover
646
715
  };
647
716
  }
648
717
  if (subscription.cancel_at && subscription.cancel_at !== subscription.current_period_end) {
@@ -652,7 +721,8 @@ const getSubscriptionAction = subscription => {
652
721
  action: "cancel",
653
722
  variant: "outlined",
654
723
  color: "inherit",
655
- canRenew: false
724
+ canRenew: false,
725
+ ...actionProps?.cancel
656
726
  };
657
727
  }
658
728
  if (subscription.status === "past_due") {
@@ -661,7 +731,8 @@ const getSubscriptionAction = subscription => {
661
731
  action: "pastDue",
662
732
  variant: "contained",
663
733
  color: "primary",
664
- canRenew
734
+ canRenew,
735
+ ...actionProps?.pastDue
665
736
  };
666
737
  }
667
738
  if (subscription.status !== "canceled" && subscription.cancel_at_period_end) {
@@ -669,7 +740,8 @@ const getSubscriptionAction = subscription => {
669
740
  action: "recover",
670
741
  variant: "contained",
671
742
  color: "primary",
672
- canRenew: false
743
+ canRenew: false,
744
+ ...actionProps?.recover
673
745
  };
674
746
  }
675
747
  return null;
@@ -789,8 +861,8 @@ function formatTotalPrice({
789
861
  }
790
862
  const unitValue = new _util.BN(price.custom_unit_amount || price.unit_amount);
791
863
  const currency = price?.currency ?? {};
792
- const total = `${(0, _util.fromUnitToToken)(unitValue.mul(new _util.BN(quantity)), currency.decimal)} ${currency.symbol}`;
793
- const unit = `${(0, _util.fromUnitToToken)(unitValue, currency.decimal)} ${currency.symbol}`;
864
+ const total = `${(0, _util.fromUnitToToken)(unitValue.mul(new _util.BN(quantity)), currency.decimal)} ${currency.symbol} `;
865
+ const unit = `${(0, _util.fromUnitToToken)(unitValue, currency.decimal)} ${currency.symbol} `;
794
866
  const appendUnit = (v, alt) => {
795
867
  if (product.unit_label) {
796
868
  return `${v}/${price.product.unit_label}`;
@@ -826,6 +898,12 @@ function formatQuantityInventory(price, quantity, locale = "en") {
826
898
  }
827
899
  return "";
828
900
  }
901
+ function formatSubscriptionStatus(status) {
902
+ if (status === "canceled") {
903
+ return "Ended";
904
+ }
905
+ return status;
906
+ }
829
907
  function formatAmountPrecisionLimit(amount, locale = "en", precision = 6) {
830
908
  if (!amount) {
831
909
  return "";
package/lib/locales/en.js CHANGED
@@ -67,7 +67,7 @@ module.exports = (0, _flat.default)({
67
67
  continue: "Continue",
68
68
  qty: "Qty {count}",
69
69
  each: "{unit} each",
70
- trial: "Free for {count} days",
70
+ trial: "Free for {count} day{count > 1 ? 's' : ''}",
71
71
  billed: "billed {rule}",
72
72
  metered: "based on usage",
73
73
  hour: "hour",
@@ -90,6 +90,7 @@ module.exports = (0, _flat.default)({
90
90
  years: "years",
91
91
  type: "type",
92
92
  donation: "Donation",
93
+ recoverFrom: "Recovered From",
93
94
  quantityLimitPerCheckout: "Exceed purchase limit",
94
95
  quantityNotEnough: "Exceed inventory",
95
96
  amountPrecisionLimit: "Amount decimal places must be less than or equal to {precision}"
@@ -115,10 +116,12 @@ module.exports = (0, _flat.default)({
115
116
  subscription: "View subscription",
116
117
  invoice: "View invoice"
117
118
  },
119
+ paymentRequired: "Payment Required",
118
120
  staking: {
119
121
  title: "Staking Required",
120
122
  tooltip: "Staking is used to ensure that future invoices can be paid normally. Revoking the staking from DID Wallet means canceling the subscription."
121
123
  },
124
+ stakingConfirm: "In this payment, the staked amount is separate from the product cost.",
122
125
  donation: {
123
126
  between: "Please enter an amount between {min} and {max}.",
124
127
  custom: "Custom Amount",
@@ -135,7 +138,9 @@ module.exports = (0, _flat.default)({
135
138
  sub1: "Subscribe to {name}",
136
139
  sub2: "Subscribe to {name} and {count} more",
137
140
  then: "Then {subscription} {recurring}",
138
- free: "{count} days free",
141
+ meteredThen: "Then {recurring} based on usage",
142
+ metered: "{recurring} based on usage",
143
+ free: "{count} day{count > 1 ? 's' : ''} free",
139
144
  least: "continue with at least",
140
145
  completed: {
141
146
  payment: "Thanks for your purchase",
@@ -144,7 +149,7 @@ module.exports = (0, _flat.default)({
144
149
  donate: "Thanks for your support",
145
150
  tip: "A payment to {payee} has been completed. You can view the details of this payment in your account."
146
151
  },
147
- confirm: "By confirming your subscription, you allow {payee} to charge your account or slashing your staking for this and future payments in accordance with their terms. You can always cancel your subscription, or revoking your staking from DID Wallet.",
152
+ confirm: "Confirming allows {payee} to charge or reduce your staking. You can cancel or revoke staking anytime.",
148
153
  required: "Required",
149
154
  invalid: "Invalid",
150
155
  billing: {
@@ -184,13 +189,17 @@ module.exports = (0, _flat.default)({
184
189
  emptyItems: {
185
190
  title: "Nothing to show here",
186
191
  description: "Seems this checkoutSession is not configured properly"
187
- }
192
+ },
193
+ orderSummary: "Order Summary",
194
+ paymentDetails: "Payment Details",
195
+ productListTotal: "Includes {total} items"
188
196
  },
189
197
  customer: {
190
198
  payments: "Payment History",
191
199
  invoices: "Invoice History",
192
200
  details: "Details",
193
201
  summary: "Summary",
202
+ specifics: "Specifics",
194
203
  update: "Update Information",
195
204
  empty: "Seems you do not have any subscriptions or payments here",
196
205
  cancel: {
@@ -265,13 +274,17 @@ module.exports = (0, _flat.default)({
265
274
  renewSuccess: "You have successfully renewed the subscription",
266
275
  renewError: "Failed to renew the subscription",
267
276
  empty: "There are no invoices",
268
- next: "No invoices yet, next invoice will be generated on {date}"
277
+ next: "No invoices yet, next invoice will be generated on {date}",
278
+ invoiceNumber: "Invoice Number",
279
+ emptyList: "No Invoice"
269
280
  },
270
281
  payment: {
271
- empty: "There are no payments"
282
+ empty: "There are no payments",
283
+ emptyList: "No Payment"
272
284
  },
273
285
  refund: {
274
- empty: "There are no refunds"
286
+ empty: "There are no refunds",
287
+ emptyList: "No Refund"
275
288
  },
276
289
  subscriptions: {
277
290
  plan: "Plan",
@@ -304,5 +317,8 @@ module.exports = (0, _flat.default)({
304
317
  [_constant.RefundType.refund]: "Refund",
305
318
  [_constant.RefundType.stakeReturn]: "Stake Return"
306
319
  }
320
+ },
321
+ empty: {
322
+ records: "No matching records found"
307
323
  }
308
324
  });
@@ -2,7 +2,6 @@ export declare const translations: {
2
2
  zh: any;
3
3
  en: any;
4
4
  };
5
- export declare const replace: (template: string, data?: Record<string, any>) => string;
6
5
  export declare const createTranslator: ({ fallbackLocale }: {
7
6
  fallbackLocale?: string | undefined;
8
7
  }, langs?: any) => (key: string, locale?: string, data?: Record<string, any>) => string;
@@ -3,7 +3,8 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.translations = exports.translate = exports.t = exports.replace = exports.createTranslator = void 0;
6
+ exports.translations = exports.translate = exports.t = exports.createTranslator = void 0;
7
+ var _lodash = require("lodash");
7
8
  var _en = _interopRequireDefault(require("./en"));
8
9
  var _zh = _interopRequireDefault(require("./zh"));
9
10
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
@@ -11,8 +12,18 @@ const translations = exports.translations = {
11
12
  zh: _zh.default,
12
13
  en: _en.default
13
14
  };
14
- const replace = (template, data = {}) => template.replace(/{(\w*)}/g, (_, key) => data.hasOwnProperty(key) ? data[key] : "");
15
- exports.replace = replace;
15
+ const replace = (t2, data = {}) => {
16
+ try {
17
+ const compiled = (0, _lodash.template)(t2, {
18
+ interpolate: /{([\s\S]+?)}/g,
19
+ escape: /{([\s\S]+?)}/g
20
+ });
21
+ return compiled(data);
22
+ } catch (e) {
23
+ console.error(`Error evaluating template: ${t2}`, e);
24
+ return "";
25
+ }
26
+ };
16
27
  const createTranslator = ({
17
28
  fallbackLocale = "en"
18
29
  }, langs = translations) => {
package/lib/locales/zh.js CHANGED
@@ -90,6 +90,7 @@ module.exports = (0, _flat.default)({
90
90
  years: "\u5E74",
91
91
  type: "\u7C7B\u578B",
92
92
  donation: "\u6253\u8D4F",
93
+ recoverFrom: "\u6062\u590D\u81EA",
93
94
  quantityLimitPerCheckout: "\u8D85\u51FA\u8D2D\u4E70\u9650\u5236",
94
95
  quantityNotEnough: "\u5E93\u5B58\u4E0D\u8DB3",
95
96
  amountPrecisionLimit: "\u91D1\u989D\u5C0F\u6570\u4F4D\u6570\u5FC5\u987B\u5728 {precision} \u4F4D\u4EE5\u5185"
@@ -115,10 +116,12 @@ module.exports = (0, _flat.default)({
115
116
  subscription: "\u67E5\u770B\u8BA2\u9605",
116
117
  invoice: "\u67E5\u770B\u8D26\u5355"
117
118
  },
119
+ paymentRequired: "\u652F\u4ED8\u6570\u91CF",
118
120
  staking: {
119
121
  title: "\u8D28\u62BC\u6570\u91CF",
120
122
  tooltip: "\u8D28\u62BC\u76F8\u5F53\u4E8E\u4FDD\u8BC1\u91D1\uFF0C\u7528\u4E8E\u786E\u4FDD\u672A\u6765\u7684\u8D26\u5355\u80FD\u591F\u6B63\u5E38\u6263\u6B3E\uFF0C\u5982\u679C\u4F60\u4ECE DID Wallet \u64A4\u9500\u8D28\u62BC\uFF0C\u8BA2\u9605\u4E5F\u4F1A\u88AB\u53D6\u6D88\u3002"
121
123
  },
124
+ stakingConfirm: "\u5728\u6B64\u652F\u4ED8\u4E2D\uFF0C\u8D28\u62BC\u91D1\u989D\u4E0E\u4EA7\u54C1\u8D39\u7528\u5206\u5F00",
122
125
  donation: {
123
126
  between: "\u91D1\u989D\u5FC5\u987B\u5927\u4E8E {min} \u4E14\u5C0F\u4E8E {max}",
124
127
  custom: "\u8F93\u5165\u91D1\u989D",
@@ -135,7 +138,9 @@ module.exports = (0, _flat.default)({
135
138
  sub1: "\u8BA2\u9605 {name}",
136
139
  sub2: "\u8BA2\u9605 {name} \u7B49{count}\u4E2A\u4EA7\u54C1",
137
140
  then: "\u7136\u540E {subscription} {recurring}",
138
- free: "{count} \u5929",
141
+ meteredThen: "\u7136\u540E{recurring}\u6309\u7528\u91CF\u8BA1\u8D39",
142
+ metered: "{recurring}\u6309\u7528\u91CF\u8BA1\u8D39",
143
+ free: "\u514D\u8D39\u8BD5\u7528 {count} \u5929",
139
144
  least: "\u81F3\u5C11",
140
145
  completed: {
141
146
  payment: "\u611F\u8C22\u60A8\u7684\u8D2D\u4E70",
@@ -144,7 +149,7 @@ module.exports = (0, _flat.default)({
144
149
  donate: "\u611F\u8C22\u60A8\u7684\u652F\u6301",
145
150
  tip: "\u5411{payee}\u7684\u4ED8\u6B3E\u5DF2\u5B8C\u6210\u3002\u60A8\u53EF\u4EE5\u5728\u60A8\u7684\u8D26\u6237\u4E2D\u67E5\u770B\u6B64\u4ED8\u6B3E\u7684\u8BE6\u7EC6\u4FE1\u606F\u3002"
146
151
  },
147
- confirm: "\u901A\u8FC7\u786E\u8BA4\u60A8\u7684\u8BA2\u9605\uFF0C\u60A8\u5141\u8BB8{payee}\u6309\u7167\u5176\u6761\u6B3E\u5BF9\u60A8\u7684\u8D26\u6237\u8FDB\u884C\u4ED8\u6B3E\u6216\u8005\u7F5A\u6CA1\u60A8\u7684\u8D28\u62BC\u3002\u60A8\u968F\u65F6\u53EF\u4EE5\u53D6\u6D88\u60A8\u7684\u8BA2\u9605\uFF0C\u6216\u8005\u64A4\u9500\u8D28\u62BC\u3002",
152
+ confirm: "\u786E\u8BA4\u5141\u8BB8{payee}\u5BF9\u60A8\u7684\u8D26\u6237\u8FDB\u884C\u4ED8\u6B3E\u6216\u8005\u7F5A\u6CA1\u60A8\u7684\u8D28\u62BC\u3002\u60A8\u968F\u65F6\u53EF\u4EE5\u53D6\u6D88\u60A8\u7684\u8BA2\u9605\uFF0C\u6216\u8005\u64A4\u9500\u8D28\u62BC\u3002",
148
153
  required: "\u5FC5\u586B\u9879",
149
154
  invalid: "\u65E0\u6548",
150
155
  billing: {
@@ -184,13 +189,17 @@ module.exports = (0, _flat.default)({
184
189
  emptyItems: {
185
190
  title: "\u6CA1\u6709\u4EFB\u4F55\u8D2D\u4E70\u9879\u76EE",
186
191
  description: "\u53EF\u80FD\u8FD9\u4E2A\u4ED8\u6B3E\u94FE\u63A5\u6CA1\u6709\u6B63\u786E\u914D\u7F6E"
187
- }
192
+ },
193
+ orderSummary: "\u8BA2\u5355\u6982\u89C8",
194
+ paymentDetails: "\u652F\u4ED8\u4FE1\u606F",
195
+ productListTotal: "\u5305\u62EC {total} \u9879"
188
196
  },
189
197
  customer: {
190
198
  payments: "\u652F\u4ED8\u5386\u53F2",
191
199
  invoices: "\u8D26\u5355\u5386\u53F2",
192
200
  details: "\u8D26\u6237\u8BE6\u60C5",
193
201
  summary: "\u8BA1\u8D39\u6458\u8981",
202
+ specifics: "\u5177\u4F53\u4FE1\u606F",
194
203
  update: "\u66F4\u65B0\u5BA2\u6237\u4FE1\u606F",
195
204
  empty: "\u770B\u8D77\u6765\u60A8\u5728\u8FD9\u91CC\u6CA1\u6709\u4EFB\u4F55\u8BA2\u9605\u6216\u652F\u4ED8",
196
205
  cancel: {
@@ -265,13 +274,17 @@ module.exports = (0, _flat.default)({
265
274
  renewSuccess: "\u8BA2\u9605\u6062\u590D\u6210\u529F",
266
275
  renewError: "\u8BA2\u9605\u6062\u590D\u5931\u8D25",
267
276
  empty: "\u6CA1\u6709\u4EFB\u4F55\u8D26\u5355",
268
- next: "\u8FD8\u6CA1\u6709\u8D26\u5355\uFF0C\u4E0B\u6B21\u8D26\u5355\u5C06\u5728 {date} \u751F\u6210"
277
+ next: "\u8FD8\u6CA1\u6709\u8D26\u5355\uFF0C\u4E0B\u6B21\u8D26\u5355\u5C06\u5728 {date} \u751F\u6210",
278
+ invoiceNumber: "\u8D26\u5355\u7F16\u53F7",
279
+ emptyList: "\u6CA1\u6709\u8D26\u5355"
269
280
  },
270
281
  payment: {
271
- empty: "\u6CA1\u6709\u652F\u4ED8\u8BB0\u5F55"
282
+ empty: "\u6CA1\u6709\u652F\u4ED8\u8BB0\u5F55",
283
+ emptyList: "\u6CA1\u6709\u652F\u4ED8\u8BB0\u5F55"
272
284
  },
273
285
  refund: {
274
- empty: "\u6CA1\u6709\u9000\u6B3E\u8BB0\u5F55"
286
+ empty: "\u6CA1\u6709\u9000\u6B3E\u8BB0\u5F55",
287
+ emptyList: "\u6CA1\u6709\u9000\u6B3E\u8BB0\u5F55"
275
288
  },
276
289
  subscriptions: {
277
290
  plan: "\u8BA2\u9605",
@@ -304,5 +317,8 @@ module.exports = (0, _flat.default)({
304
317
  [_constant.RefundType.refund]: "\u9000\u6B3E",
305
318
  [_constant.RefundType.stakeReturn]: "\u9000\u62BC\u91D1"
306
319
  }
320
+ },
321
+ empty: {
322
+ records: "\u6CA1\u6709\u627E\u5230\u5339\u914D\u7684\u8BB0\u5F55"
307
323
  }
308
324
  });
@@ -10,7 +10,8 @@ function getHeightStyle(mode) {
10
10
  switch (mode) {
11
11
  case "standalone":
12
12
  return {
13
- height: "100vh"
13
+ height: "100vh",
14
+ maxHeight: "100%"
14
15
  };
15
16
  default:
16
17
  return {
@@ -53,6 +54,9 @@ function PaymentError({
53
54
  }), /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Button, {
54
55
  variant: "text",
55
56
  size: "small",
57
+ sx: {
58
+ color: "text.link"
59
+ },
56
60
  component: _material.Link,
57
61
  href: window.blocklet?.appUrl,
58
62
  children: button
@@ -10,7 +10,7 @@ function CheckoutFooter({
10
10
  ...props
11
11
  }) {
12
12
  return /* @__PURE__ */(0, _jsxRuntime.jsxs)(_material.Typography, {
13
- color: "text.secondary",
13
+ color: "text.lighter",
14
14
  fontSize: 12,
15
15
  ...props,
16
16
  children: ["Powered by", " ", /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Typography, {
@@ -1,7 +1,14 @@
1
1
  /// <reference types="react" />
2
+ import { SxProps } from '@mui/material';
2
3
  type Props = {
3
4
  mode: string;
4
5
  stripe: boolean;
6
+ sx?: SxProps;
5
7
  };
6
- export default function AddressForm({ mode, stripe }: Props): import("react").JSX.Element | null;
7
- export {};
8
+ declare function AddressForm({ mode, stripe, sx }: Props): import("react").JSX.Element | null;
9
+ declare namespace AddressForm {
10
+ var defaultProps: {
11
+ sx: {};
12
+ };
13
+ }
14
+ export default AddressForm;