@blocklet/payment-react 1.14.29 → 1.14.31

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 (43) hide show
  1. package/es/checkout/table.js +3 -2
  2. package/es/components/pricing-table.js +2 -1
  3. package/es/components/truncated-text.d.ts +15 -0
  4. package/es/components/truncated-text.js +27 -0
  5. package/es/history/invoice/list.js +14 -4
  6. package/es/index.d.ts +2 -1
  7. package/es/index.js +3 -1
  8. package/es/libs/util.d.ts +2 -0
  9. package/es/libs/util.js +33 -0
  10. package/es/locales/en.js +3 -1
  11. package/es/locales/zh.js +3 -1
  12. package/es/payment/form/index.js +89 -60
  13. package/es/payment/index.js +81 -15
  14. package/es/payment/summary.js +2 -18
  15. package/es/theme/index.js +5 -0
  16. package/lib/checkout/table.js +8 -2
  17. package/lib/components/pricing-table.js +6 -1
  18. package/lib/components/truncated-text.d.ts +15 -0
  19. package/lib/components/truncated-text.js +55 -0
  20. package/lib/history/invoice/list.js +8 -3
  21. package/lib/index.d.ts +2 -1
  22. package/lib/index.js +8 -0
  23. package/lib/libs/util.d.ts +2 -0
  24. package/lib/libs/util.js +35 -0
  25. package/lib/locales/en.js +3 -1
  26. package/lib/locales/zh.js +3 -1
  27. package/lib/payment/form/index.js +37 -11
  28. package/lib/payment/index.js +59 -4
  29. package/lib/payment/summary.js +2 -6
  30. package/lib/theme/index.js +5 -0
  31. package/package.json +8 -8
  32. package/src/checkout/table.tsx +3 -2
  33. package/src/components/pricing-table.tsx +2 -1
  34. package/src/components/truncated-text.tsx +41 -0
  35. package/src/history/invoice/list.tsx +9 -4
  36. package/src/index.ts +2 -0
  37. package/src/libs/util.ts +41 -0
  38. package/src/locales/en.tsx +3 -0
  39. package/src/locales/zh.tsx +2 -0
  40. package/src/payment/form/index.tsx +43 -15
  41. package/src/payment/index.tsx +70 -5
  42. package/src/payment/summary.tsx +2 -8
  43. package/src/theme/index.tsx +5 -0
package/es/theme/index.js CHANGED
@@ -101,6 +101,11 @@ export function PaymentThemeProvider({
101
101
  defaultProps: {
102
102
  enterTouchDelay: 3e3,
103
103
  leaveTouchDelay: 100
104
+ },
105
+ styleOverrides: {
106
+ tooltip: {
107
+ fontSize: "0.875rem"
108
+ }
104
109
  }
105
110
  },
106
111
  MuiPopover: {
@@ -17,6 +17,7 @@ var _api = _interopRequireDefault(require("../libs/api"));
17
17
  var _util = require("../libs/util");
18
18
  var _form = _interopRequireDefault(require("./form"));
19
19
  var _theme = require("../theme");
20
+ var _truncatedText = _interopRequireDefault(require("../components/truncated-text"));
20
21
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
21
22
  const fetchData = async id => {
22
23
  const {
@@ -120,7 +121,8 @@ function CheckoutTableInner({
120
121
  sx: {
121
122
  display: "flex",
122
123
  marginBottom: "8px",
123
- width: "fit-content"
124
+ width: "fit-content",
125
+ ml: 0
124
126
  }
125
127
  }), /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Typography, {
126
128
  color: "text.primary",
@@ -129,7 +131,11 @@ function CheckoutTableInner({
129
131
  lineHeight: "32px",
130
132
  fontSize: "24px"
131
133
  },
132
- children: data.name
134
+ children: /* @__PURE__ */(0, _jsxRuntime.jsx)(_truncatedText.default, {
135
+ text: data.name,
136
+ maxLength: 60,
137
+ useWidth: true
138
+ })
133
139
  })]
134
140
  }), /* @__PURE__ */(0, _jsxRuntime.jsx)(_pricingTable.default, {
135
141
  table: data,
@@ -19,6 +19,7 @@ var _payment = require("../contexts/payment");
19
19
  var _util2 = require("../libs/util");
20
20
  var _amount = _interopRequireDefault(require("../payment/amount"));
21
21
  var _mobile = require("../hooks/mobile");
22
+ var _truncatedText = _interopRequireDefault(require("./truncated-text"));
22
23
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
23
24
  const sortOrder = {
24
25
  year: 1,
@@ -318,7 +319,11 @@ function PricingTable({
318
319
  fontSize: "18px !important",
319
320
  fontWeight: "600"
320
321
  },
321
- children: x.product.name
322
+ children: /* @__PURE__ */(0, _jsxRuntime.jsx)(_truncatedText.default, {
323
+ text: x.product.name,
324
+ maxLength: 26,
325
+ useWidth: true
326
+ })
322
327
  }), x.is_highlight && /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Chip, {
323
328
  label: x.highlight_text,
324
329
  color: "default",
@@ -0,0 +1,15 @@
1
+ /// <reference types="react" />
2
+ interface TruncatedTextProps {
3
+ text?: string;
4
+ maxLength?: number;
5
+ useWidth?: boolean;
6
+ }
7
+ declare function TruncatedText({ text, maxLength, useWidth }: TruncatedTextProps): import("react").JSX.Element | null;
8
+ declare namespace TruncatedText {
9
+ var defaultProps: {
10
+ useWidth: boolean;
11
+ text: string;
12
+ maxLength: number;
13
+ };
14
+ }
15
+ export default TruncatedText;
@@ -0,0 +1,55 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ module.exports = TruncatedText;
7
+ var _jsxRuntime = require("react/jsx-runtime");
8
+ var _material = require("@mui/material");
9
+ var _system = require("@mui/system");
10
+ var _util = require("../libs/util");
11
+ const CustomTooltip = (0, _system.styled)(({
12
+ className,
13
+ ...props
14
+ }) => /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Tooltip, {
15
+ ...props,
16
+ classes: {
17
+ popper: className
18
+ }
19
+ }))({
20
+ [`& .${_material.tooltipClasses.tooltip}`]: {
21
+ fontSize: 11,
22
+ maxHeight: 120,
23
+ maxWidth: 500,
24
+ overflowY: "auto"
25
+ }
26
+ });
27
+ function TruncatedText({
28
+ text = "",
29
+ maxLength = 100,
30
+ useWidth = false
31
+ }) {
32
+ if (!text) {
33
+ return null;
34
+ }
35
+ const truncatedText = (0, _util.truncateText)(text, maxLength, useWidth);
36
+ if (!truncatedText.endsWith("...")) {
37
+ return /* @__PURE__ */(0, _jsxRuntime.jsx)("span", {
38
+ children: truncatedText
39
+ });
40
+ }
41
+ return /* @__PURE__ */(0, _jsxRuntime.jsx)(CustomTooltip, {
42
+ title: text,
43
+ placement: "bottom",
44
+ enterTouchDelay: 0,
45
+ children: /* @__PURE__ */(0, _jsxRuntime.jsx)("span", {
46
+ title: text,
47
+ children: truncatedText
48
+ })
49
+ });
50
+ }
51
+ TruncatedText.defaultProps = {
52
+ useWidth: false,
53
+ text: "",
54
+ maxLength: 100
55
+ };
@@ -99,7 +99,7 @@ const InvoiceTable = _react.default.memo(props => {
99
99
  const columns = [{
100
100
  label: t("common.amount"),
101
101
  name: "total",
102
- width: 60,
102
+ width: 80,
103
103
  align: "right",
104
104
  options: {
105
105
  customBodyRenderLite: (_, index) => {
@@ -163,9 +163,8 @@ const InvoiceTable = _react.default.memo(props => {
163
163
  }
164
164
  }, {
165
165
  label: t("common.status"),
166
- name: "created_at",
166
+ name: "status",
167
167
  options: {
168
- sort: true,
169
168
  customBodyRenderLite: (val, index) => {
170
169
  const invoice = data?.list[index];
171
170
  const link = getInvoiceLink(invoice, action);
@@ -420,6 +419,9 @@ const InvoiceList = _react.default.memo(props => {
420
419
  color: "primary",
421
420
  size: "small",
422
421
  onClick: () => onPay(invoice.id),
422
+ sx: {
423
+ whiteSpace: "nowrap"
424
+ },
423
425
  children: t("payment.customer.invoice.pay")
424
426
  }) : /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Button, {
425
427
  component: "a",
@@ -427,6 +429,9 @@ const InvoiceList = _react.default.memo(props => {
427
429
  size: "small",
428
430
  href: link.url,
429
431
  target: link.external ? "_blank" : target,
432
+ sx: {
433
+ whiteSpace: "nowrap"
434
+ },
430
435
  rel: "noreferrer",
431
436
  children: t("payment.customer.invoice.pay")
432
437
  }) : /* @__PURE__ */(0, _jsxRuntime.jsx)(_status.default, {
package/lib/index.d.ts CHANGED
@@ -25,6 +25,7 @@ import ProductSkeleton from './payment/product-skeleton';
25
25
  import PaymentSummary from './payment/summary';
26
26
  import PricingItem from './components/pricing-item';
27
27
  import CountrySelect from './components/country-select';
28
+ import TruncatedText from './components/truncated-text';
28
29
  export { PaymentThemeProvider } from './theme';
29
30
  export * from './libs/util';
30
31
  export * from './libs/connect';
@@ -33,4 +34,4 @@ export * from './hooks/subscription';
33
34
  export * from './hooks/mobile';
34
35
  export * from './hooks/table';
35
36
  export { translations, createTranslator } from './locales';
36
- export { api, dayjs, FormInput, PhoneInput, AddressForm, StripeForm, Status, Livemode, Switch, ConfirmDialog, CheckoutForm, CheckoutTable, CheckoutDonate, CurrencySelector, Payment, PaymentSummary, PricingTable, ProductSkeleton, Amount, CustomerInvoiceList, CustomerPaymentList, TxLink, TxGas, SafeGuard, PricingItem, CountrySelect, Table, };
37
+ export { api, dayjs, FormInput, PhoneInput, AddressForm, StripeForm, Status, Livemode, Switch, ConfirmDialog, CheckoutForm, CheckoutTable, CheckoutDonate, CurrencySelector, Payment, PaymentSummary, PricingTable, ProductSkeleton, Amount, CustomerInvoiceList, CustomerPaymentList, TxLink, TxGas, SafeGuard, PricingItem, CountrySelect, Table, TruncatedText, };
package/lib/index.js CHANGED
@@ -31,6 +31,7 @@ var _exportNames = {
31
31
  PaymentSummary: true,
32
32
  PricingItem: true,
33
33
  CountrySelect: true,
34
+ TruncatedText: true,
34
35
  PaymentThemeProvider: true,
35
36
  translations: true,
36
37
  createTranslator: true
@@ -179,6 +180,12 @@ Object.defineProperty(exports, "Table", {
179
180
  return _table2.default;
180
181
  }
181
182
  });
183
+ Object.defineProperty(exports, "TruncatedText", {
184
+ enumerable: true,
185
+ get: function () {
186
+ return _truncatedText.default;
187
+ }
188
+ });
182
189
  Object.defineProperty(exports, "TxGas", {
183
190
  enumerable: true,
184
191
  get: function () {
@@ -242,6 +249,7 @@ var _productSkeleton = _interopRequireDefault(require("./payment/product-skeleto
242
249
  var _summary = _interopRequireDefault(require("./payment/summary"));
243
250
  var _pricingItem = _interopRequireDefault(require("./components/pricing-item"));
244
251
  var _countrySelect = _interopRequireDefault(require("./components/country-select"));
252
+ var _truncatedText = _interopRequireDefault(require("./components/truncated-text"));
245
253
  var _theme = require("./theme");
246
254
  var _util = require("./libs/util");
247
255
  Object.keys(_util).forEach(function (key) {
@@ -105,3 +105,5 @@ export declare function formatQuantityInventory(price: TPrice, quantity: string
105
105
  export declare function formatSubscriptionStatus(status: string): string;
106
106
  export declare function formatAmountPrecisionLimit(amount: string, locale?: string, precision?: number): string;
107
107
  export declare function getWordBreakStyle(value: any): 'break-word' | 'break-all';
108
+ export declare function isMobileSafari(): boolean;
109
+ export declare function truncateText(text: string, maxLength: number, useWidth?: boolean): string;
package/lib/libs/util.js CHANGED
@@ -44,16 +44,19 @@ exports.getSubscriptionStatusColor = getSubscriptionStatusColor;
44
44
  exports.getTxLink = exports.getSubscriptionTimeSummary = void 0;
45
45
  exports.getWebhookStatusColor = getWebhookStatusColor;
46
46
  exports.getWordBreakStyle = getWordBreakStyle;
47
+ exports.isMobileSafari = isMobileSafari;
47
48
  exports.isPaymentKitMounted = void 0;
48
49
  exports.isValidCountry = isValidCountry;
49
50
  exports.lazyLoad = lazyLoad;
50
51
  exports.mergeExtraParams = void 0;
51
52
  exports.sleep = sleep;
52
53
  exports.stopEvent = stopEvent;
54
+ exports.truncateText = truncateText;
53
55
  var _util = require("@ocap/util");
54
56
  var _omit = _interopRequireDefault(require("lodash/omit"));
55
57
  var _trimEnd = _interopRequireDefault(require("lodash/trimEnd"));
56
58
  var _numbro = _interopRequireDefault(require("numbro"));
59
+ var _stringWidth = _interopRequireDefault(require("string-width"));
57
60
  var _reactInternationalPhone = require("react-international-phone");
58
61
  var _ufo = require("ufo");
59
62
  var _locales = require("../locales");
@@ -974,4 +977,36 @@ function getWordBreakStyle(value) {
974
977
  return "break-word";
975
978
  }
976
979
  return "break-all";
980
+ }
981
+ function isMobileSafari() {
982
+ const ua = navigator.userAgent.toLowerCase();
983
+ const isSafari = ua.indexOf("safari") > -1 && ua.indexOf("chrome") === -1;
984
+ const isMobile = ua.indexOf("mobile") > -1 || /iphone|ipad|ipod/.test(ua);
985
+ const isIOS = /iphone|ipad|ipod/.test(ua);
986
+ return isSafari && isMobile && isIOS;
987
+ }
988
+ function truncateText(text, maxLength, useWidth = false) {
989
+ if (!text || !maxLength) {
990
+ return text;
991
+ }
992
+ if (!useWidth) {
993
+ if (text.length <= maxLength) {
994
+ return text;
995
+ }
996
+ return `${text.substring(0, maxLength)}...`;
997
+ }
998
+ let width = 0;
999
+ let truncated = "";
1000
+ for (let i = 0; i < text.length; i++) {
1001
+ const charWidth = (0, _stringWidth.default)(text.charAt(i));
1002
+ if (width + charWidth > maxLength) {
1003
+ break;
1004
+ }
1005
+ truncated += text.charAt(i);
1006
+ width += charWidth;
1007
+ }
1008
+ if (truncated === text) {
1009
+ return truncated;
1010
+ }
1011
+ return `${truncated}...`;
977
1012
  }
package/lib/locales/en.js CHANGED
@@ -209,6 +209,7 @@ module.exports = (0, _flat.default)({
209
209
  title: "Cancel your subscription",
210
210
  comment: "Any additional feedback?",
211
211
  description: "Your subscription will be canceled, but it is still available until the end of your current billing period on {date}",
212
+ trialDescription: "Free trial subscriptions will be canceled immediately and no longer available, confirm to continue",
212
213
  feedback: {
213
214
  tip: "We would love your feedback, it will help us improve our service",
214
215
  too_expensive: "The service is too expensive",
@@ -310,7 +311,8 @@ module.exports = (0, _flat.default)({
310
311
  threshold: "Metered usage billing",
311
312
  cancel: "Subscription cancel",
312
313
  manual: "Manual invoice",
313
- upcoming: "Upcoming invoice"
314
+ upcoming: "Upcoming invoice",
315
+ slashStake: "Slash stake"
314
316
  }
315
317
  }
316
318
  },
package/lib/locales/zh.js CHANGED
@@ -209,6 +209,7 @@ module.exports = (0, _flat.default)({
209
209
  title: "\u53D6\u6D88\u60A8\u7684\u8BA2\u9605",
210
210
  comment: "\u4F60\u8FD8\u6709\u5176\u4ED6\u53CD\u9988\u4E48\uFF1F",
211
211
  description: "\u60A8\u7684\u8BA2\u9605\u5C06\u88AB\u53D6\u6D88\uFF0C\u4F46\u4ECD\u7136\u53EF\u7528\u76F4\u5230\u60A8\u5F53\u524D\u8BA1\u8D39\u5468\u671F\u7ED3\u675F\u4E8E{date}",
212
+ trialDescription: "\u514D\u8D39\u8BD5\u7528\u7684\u8BA2\u9605\u5C06\u88AB\u7ACB\u5373\u53D6\u6D88\uFF0C\u4E0D\u518D\u53EF\u7528\uFF0C\u786E\u8BA4\u662F\u5426\u7EE7\u7EED",
212
213
  feedback: {
213
214
  tip: "\u6211\u4EEC\u5E0C\u671B\u542C\u5230\u60A8\u7684\u53CD\u9988\uFF0C\u8FD9\u5C06\u5E2E\u52A9\u6211\u4EEC\u6539\u8FDB\u6211\u4EEC\u7684\u670D\u52A1",
214
215
  too_expensive: "\u670D\u52A1\u8D39\u7528\u592A\u9AD8",
@@ -310,7 +311,8 @@ module.exports = (0, _flat.default)({
310
311
  threshold: "\u7528\u91CF\u8D26\u5355",
311
312
  cancel: "\u8BA2\u9605\u53D6\u6D88",
312
313
  manual: "\u4EBA\u5DE5\u8D26\u5355",
313
- upcoming: "\u672A\u6765\u8D26\u5355"
314
+ upcoming: "\u672A\u6765\u8D26\u5355",
315
+ slashStake: "\u7F5A\u6CA1\u8D28\u62BC"
314
316
  }
315
317
  }
316
318
  },
@@ -18,6 +18,7 @@ var _reactHookForm = require("react-hook-form");
18
18
  var _ufo = require("ufo");
19
19
  var _useBus = require("use-bus");
20
20
  var _isEmail = _interopRequireDefault(require("validator/es/lib/isEmail"));
21
+ var _lodash = require("lodash");
21
22
  var _confirm = _interopRequireDefault(require("../../components/confirm"));
22
23
  var _input = _interopRequireDefault(require("../../components/input"));
23
24
  var _payment = require("../../contexts/payment");
@@ -28,6 +29,7 @@ var _address = _interopRequireDefault(require("./address"));
28
29
  var _currency = _interopRequireDefault(require("./currency"));
29
30
  var _phone = _interopRequireDefault(require("./phone"));
30
31
  var _stripe = _interopRequireDefault(require("./stripe"));
32
+ var _mobile = require("../../hooks/mobile");
31
33
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
32
34
  const phoneUtil = _googleLibphonenumber.PhoneNumberUtil.getInstance();
33
35
  const waitForCheckoutComplete = async sessionId => {
@@ -66,6 +68,9 @@ function PaymentForm({
66
68
  const {
67
69
  t
68
70
  } = (0, _context.useLocaleContext)();
71
+ const {
72
+ isMobile
73
+ } = (0, _mobile.useMobile)();
69
74
  const {
70
75
  session,
71
76
  connect,
@@ -76,8 +81,12 @@ function PaymentForm({
76
81
  control,
77
82
  getValues,
78
83
  setValue,
79
- handleSubmit
84
+ handleSubmit,
85
+ formState: {
86
+ errors
87
+ }
80
88
  } = (0, _reactHookForm.useFormContext)();
89
+ const errorRef = (0, _react.useRef)(null);
81
90
  const quantityInventoryStatus = (0, _react.useMemo)(() => {
82
91
  let status = true;
83
92
  for (const item of checkoutSession.line_items) {
@@ -190,6 +199,13 @@ function PaymentForm({
190
199
  });
191
200
  }
192
201
  };
202
+ (0, _react.useEffect)(() => {
203
+ if (errorRef.current && !(0, _lodash.isEmpty)(errors) && isMobile) {
204
+ errorRef.current.scrollIntoView({
205
+ behavior: "smooth"
206
+ });
207
+ }
208
+ }, [errors, isMobile]);
193
209
  const onUserLoggedIn = async () => {
194
210
  const {
195
211
  data: profile
@@ -318,6 +334,11 @@ function PaymentForm({
318
334
  });
319
335
  };
320
336
  const onAction = () => {
337
+ if (errorRef.current && !(0, _lodash.isEmpty)(errors) && isMobile) {
338
+ errorRef.current.scrollIntoView({
339
+ behavior: "smooth"
340
+ });
341
+ }
321
342
  if (session?.user) {
322
343
  if (hasDidWallet(session.user)) {
323
344
  handleSubmit(onFormSubmit, onFormError)();
@@ -412,7 +433,9 @@ function PaymentForm({
412
433
  }), /* @__PURE__ */(0, _jsxRuntime.jsxs)(_material.Stack, {
413
434
  direction: "column",
414
435
  className: "cko-payment-form",
436
+ id: "cko-payment-form",
415
437
  spacing: 0,
438
+ ref: !(0, _lodash.isEmpty)(errors) ? errorRef : void 0,
416
439
  sx: {
417
440
  flex: 1,
418
441
  overflow: "auto"
@@ -477,16 +500,19 @@ function PaymentForm({
477
500
  in: true,
478
501
  children: /* @__PURE__ */(0, _jsxRuntime.jsxs)(_material.Stack, {
479
502
  className: "cko-payment-submit",
480
- children: [/* @__PURE__ */(0, _jsxRuntime.jsx)(_lab.LoadingButton, {
481
- variant: "contained",
482
- color: "primary",
483
- size: "large",
484
- className: "cko-submit-button",
485
- onClick: onAction,
486
- fullWidth: true,
487
- disabled: state.submitting || state.paying || state.stripePaying || !quantityInventoryStatus || !payable,
488
- loading: state.submitting || state.paying,
489
- children: state.submitting || state.paying ? t("payment.checkout.processing") : buttonText
503
+ children: [/* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Box, {
504
+ className: "cko-payment-submit-btn",
505
+ children: /* @__PURE__ */(0, _jsxRuntime.jsx)(_lab.LoadingButton, {
506
+ variant: "contained",
507
+ color: "primary",
508
+ size: "large",
509
+ className: "cko-submit-button",
510
+ onClick: onAction,
511
+ fullWidth: true,
512
+ disabled: state.submitting || state.paying || state.stripePaying || !quantityInventoryStatus || !payable,
513
+ loading: state.submitting || state.paying,
514
+ children: state.submitting || state.paying ? t("payment.checkout.processing") : buttonText
515
+ })
490
516
  }), ["subscription", "setup"].includes(checkoutSession.mode) && /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Typography, {
491
517
  sx: {
492
518
  mt: 2.5,
@@ -81,6 +81,24 @@ function PaymentInner({
81
81
  })
82
82
  }
83
83
  });
84
+ (0, _react.useEffect)(() => {
85
+ if (!(0, _util2.isMobileSafari)()) {
86
+ return () => {};
87
+ }
88
+ let scrollTop = 0;
89
+ const focusinHandler = () => {
90
+ scrollTop = window.scrollY;
91
+ };
92
+ const focusoutHandler = () => {
93
+ window.scrollTo(0, scrollTop);
94
+ };
95
+ document.body.addEventListener("focusin", focusinHandler);
96
+ document.body.addEventListener("focusout", focusoutHandler);
97
+ return () => {
98
+ document.body.removeEventListener("focusin", focusinHandler);
99
+ document.body.removeEventListener("focusout", focusoutHandler);
100
+ };
101
+ }, []);
84
102
  const currencyId = (0, _reactHookForm.useWatch)({
85
103
  control: methods.control,
86
104
  name: "payment_currency",
@@ -280,7 +298,11 @@ function Payment({
280
298
  setLivemode
281
299
  } = (0, _payment.usePaymentContext)();
282
300
  const [delay, setDelay] = (0, _react.useState)(false);
301
+ const {
302
+ isMobile
303
+ } = (0, _mobile.useMobile)();
283
304
  const hideSummaryCard = mode.endsWith("-minimal") || !showCheckoutSummary;
305
+ const isMobileSafariEnv = (0, _util2.isMobileSafari)();
284
306
  (0, _react.useEffect)(() => {
285
307
  setTimeout(() => {
286
308
  setDelay(true);
@@ -359,7 +381,7 @@ function Payment({
359
381
  flexDirection: "column",
360
382
  sx: {
361
383
  height: mode === "standalone" ? "100vh" : "auto",
362
- overflow: "hidden"
384
+ overflow: isMobileSafariEnv ? "visible" : "hidden"
363
385
  },
364
386
  children: [mode === "standalone" ? /* @__PURE__ */(0, _jsxRuntime.jsx)(_Header.default, {
365
387
  meta: void 0,
@@ -375,7 +397,39 @@ function Payment({
375
397
  }) : null, /* @__PURE__ */(0, _jsxRuntime.jsxs)(Root, {
376
398
  mode,
377
399
  sx: {
378
- flex: 1
400
+ flex: 1,
401
+ overflow: {
402
+ xs: isMobileSafariEnv ? "visible" : "auto",
403
+ md: "hidden"
404
+ },
405
+ ...(isMobile && mode === "standalone" ? {
406
+ ".cko-payment-submit-btn": {
407
+ position: "fixed",
408
+ bottom: 20,
409
+ left: 0,
410
+ right: 0,
411
+ zIndex: 999,
412
+ background: "#fff",
413
+ padding: "10px",
414
+ textAlign: "center",
415
+ button: {
416
+ color: "#fff",
417
+ maxWidth: 542
418
+ }
419
+ },
420
+ ".cko-footer": {
421
+ position: "fixed",
422
+ bottom: 0,
423
+ left: 0,
424
+ right: 0,
425
+ zIndex: 999,
426
+ background: "#fff",
427
+ marginBottom: 0
428
+ },
429
+ ".cko-payment": {
430
+ paddingBottom: "100px"
431
+ }
432
+ } : {})
379
433
  },
380
434
  children: [goBack && /* @__PURE__ */(0, _jsxRuntime.jsx)(_iconsMaterial.ArrowBackOutlined, {
381
435
  sx: {
@@ -541,7 +595,6 @@ const Root = exports.Root = (0, _system.styled)(_material.Box)`
541
595
  @media (max-width: ${({
542
596
  theme
543
597
  }) => theme.breakpoints.values.md}px) {
544
- background: ${props => props.mode === "standalone" ? "var(--backgrounds-bg-subtle, #F9FAFB)" : "transparent"};
545
598
  padding-top: 0;
546
599
  overflow: auto;
547
600
  &:before {
@@ -550,7 +603,8 @@ const Root = exports.Root = (0, _system.styled)(_material.Box)`
550
603
  .cko-container {
551
604
  flex-direction: column;
552
605
  align-items: center;
553
- gap: 32px;
606
+ justify-content: flex-start;
607
+ gap: 0;
554
608
  overflow: visible;
555
609
  min-width: 200px;
556
610
  }
@@ -563,6 +617,7 @@ const Root = exports.Root = (0, _system.styled)(_material.Box)`
563
617
  width: 100%;
564
618
  height: fit-content;
565
619
  flex: none;
620
+ border-top: 1px solid var(--stroke-border-base, #eff1f5);
566
621
  &:before {
567
622
  display: none;
568
623
  }
@@ -342,9 +342,7 @@ function PaymentSummary({
342
342
  },
343
343
  children: t("payment.checkout.paymentRequired")
344
344
  }), /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Tooltip, {
345
- title: /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Typography, {
346
- children: t("payment.checkout.stakingConfirm")
347
- }),
345
+ title: t("payment.checkout.stakingConfirm"),
348
346
  placement: "top",
349
347
  sx: {
350
348
  maxWidth: "150px"
@@ -374,9 +372,7 @@ function PaymentSummary({
374
372
  },
375
373
  children: t("payment.checkout.staking.title")
376
374
  }), /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Tooltip, {
377
- title: /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Typography, {
378
- children: t("payment.checkout.staking.tooltip")
379
- }),
375
+ title: t("payment.checkout.staking.tooltip"),
380
376
  placement: "top",
381
377
  sx: {
382
378
  maxWidth: "150px"
@@ -115,6 +115,11 @@ function PaymentThemeProvider({
115
115
  defaultProps: {
116
116
  enterTouchDelay: 3e3,
117
117
  leaveTouchDelay: 100
118
+ },
119
+ styleOverrides: {
120
+ tooltip: {
121
+ fontSize: "0.875rem"
122
+ }
118
123
  }
119
124
  },
120
125
  MuiPopover: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blocklet/payment-react",
3
- "version": "1.14.29",
3
+ "version": "1.14.31",
4
4
  "description": "Reusable react components for payment kit v2",
5
5
  "keywords": [
6
6
  "react",
@@ -53,16 +53,16 @@
53
53
  }
54
54
  },
55
55
  "dependencies": {
56
- "@arcblock/did-connect": "^2.10.16",
57
- "@arcblock/ux": "^2.10.16",
58
- "@arcblock/ws": "^1.18.128",
59
- "@blocklet/ui-react": "^2.10.16",
56
+ "@arcblock/did-connect": "^2.10.23",
57
+ "@arcblock/ux": "^2.10.23",
58
+ "@arcblock/ws": "^1.18.132",
59
+ "@blocklet/ui-react": "^2.10.23",
60
60
  "@mui/icons-material": "^5.16.6",
61
61
  "@mui/lab": "^5.0.0-alpha.173",
62
62
  "@mui/material": "^5.16.6",
63
63
  "@mui/styles": "^5.16.6",
64
64
  "@mui/system": "^5.16.6",
65
- "@ocap/util": "^1.18.128",
65
+ "@ocap/util": "^1.18.132",
66
66
  "@stripe/react-stripe-js": "^2.7.3",
67
67
  "@stripe/stripe-js": "^2.4.0",
68
68
  "@vitejs/plugin-legacy": "^5.4.1",
@@ -93,7 +93,7 @@
93
93
  "@babel/core": "^7.25.2",
94
94
  "@babel/preset-env": "^7.25.2",
95
95
  "@babel/preset-react": "^7.24.7",
96
- "@blocklet/payment-types": "1.14.29",
96
+ "@blocklet/payment-types": "1.14.31",
97
97
  "@storybook/addon-essentials": "^7.6.20",
98
98
  "@storybook/addon-interactions": "^7.6.20",
99
99
  "@storybook/addon-links": "^7.6.20",
@@ -123,5 +123,5 @@
123
123
  "vite-plugin-babel": "^1.2.0",
124
124
  "vite-plugin-node-polyfills": "^0.21.0"
125
125
  },
126
- "gitHead": "104f4189d9ef96c1e332ffa90824ebd3063c989d"
126
+ "gitHead": "bd36f69fcd955be6b1353b520879bbb3c1e3266f"
127
127
  }
@@ -13,6 +13,7 @@ import { mergeExtraParams } from '../libs/util';
13
13
  import { CheckoutProps } from '../types';
14
14
  import CheckoutForm from './form';
15
15
  import { PaymentThemeProvider } from '../theme';
16
+ import TruncatedText from '../components/truncated-text';
16
17
 
17
18
  const fetchData = async (id: string): Promise<TPricingTableExpanded> => {
18
19
  const { data } = await api.get(`/api/pricing-tables/${id}`);
@@ -100,7 +101,7 @@ function CheckoutTableInner({ id, mode, onPaid, onError, onChange, extraParams,
100
101
  },
101
102
  textAlign: 'center',
102
103
  }}>
103
- {!data.livemode && <Livemode sx={{ display: 'flex', marginBottom: '8px', width: 'fit-content' }} />}
104
+ {!data.livemode && <Livemode sx={{ display: 'flex', marginBottom: '8px', width: 'fit-content', ml: 0 }} />}
104
105
  <Typography
105
106
  color="text.primary"
106
107
  fontWeight={600}
@@ -108,7 +109,7 @@ function CheckoutTableInner({ id, mode, onPaid, onError, onChange, extraParams,
108
109
  lineHeight: '32px',
109
110
  fontSize: '24px',
110
111
  }}>
111
- {data.name}
112
+ <TruncatedText text={data.name} maxLength={60} useWidth />
112
113
  </Typography>
113
114
  </Box>
114
115
  <PricingTable table={data} onSelect={handleSelect} />
@@ -34,6 +34,7 @@ import {
34
34
  } from '../libs/util';
35
35
  import Amount from '../payment/amount';
36
36
  import { useMobile } from '../hooks/mobile';
37
+ import TruncatedText from './truncated-text';
37
38
 
38
39
  type SortOrder = { [key: string]: number };
39
40
 
@@ -330,7 +331,7 @@ export default function PricingTable({ table, alignItems, interval, mode, onSele
330
331
  fontSize: '18px !important',
331
332
  fontWeight: '600',
332
333
  }}>
333
- {x.product.name}
334
+ <TruncatedText text={x.product.name} maxLength={26} useWidth />
334
335
  </Typography>
335
336
  {x.is_highlight && (
336
337
  <Chip