@blocklet/payment-react 1.14.37 → 1.14.39

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.
@@ -23,7 +23,7 @@ import uniqBy from "lodash/unionBy";
23
23
  import { useEffect, useState } from "react";
24
24
  import TxLink from "../components/blockchain/tx.js";
25
25
  import api from "../libs/api.js";
26
- import { formatAmount, formatBNStr, formatDateTime, formatError, lazyLoad } from "../libs/util.js";
26
+ import { formatAmount, formatBNStr, formatDateTime, formatError, getCustomerAvatar, lazyLoad } from "../libs/util.js";
27
27
  import CheckoutForm from "./form.js";
28
28
  import { PaymentThemeProvider } from "../theme/index.js";
29
29
  const donationCache = {};
@@ -81,7 +81,7 @@ function SupporterAvatar({ supporters = [], totalAmount = "0", currency, method
81
81
  Avatar,
82
82
  {
83
83
  title: x.customer?.name,
84
- src: `/.well-known/service/user/avatar/${x.customer?.did}?imageFilter=resize&w=48&h=48`,
84
+ src: getCustomerAvatar(x.customer?.did, x?.updated_at ? new Date(x.updated_at).toISOString() : "", 48),
85
85
  variant: "circular",
86
86
  sx: { width: 32, height: 32 }
87
87
  },
@@ -119,7 +119,11 @@ function SupporterTable({ supporters = [], totalAmount = "0", currency, method }
119
119
  /* @__PURE__ */ jsx(
120
120
  Avatar,
121
121
  {
122
- src: `/.well-known/service/user/avatar/${x.customer?.did}?imageFilter=resize&w=48&h=48`,
122
+ src: getCustomerAvatar(
123
+ x.customer?.did,
124
+ x?.updated_at ? new Date(x.updated_at).toISOString() : "",
125
+ 48
126
+ ),
123
127
  variant: "circular",
124
128
  sx: { width: 24, height: 24 }
125
129
  },
@@ -163,7 +167,7 @@ function SupporterSimple({ supporters = [], totalAmount = "0", currency, method
163
167
  Avatar,
164
168
  {
165
169
  title: x.customer?.name,
166
- src: `/.well-known/service/user/avatar/${x.customer?.did}?imageFilter=resize&w=48&h=48`,
170
+ src: getCustomerAvatar(x.customer?.did, x?.updated_at ? new Date(x.updated_at).toISOString() : "", 48),
167
171
  variant: "circular",
168
172
  sx: { width: 24, height: 24 }
169
173
  },
@@ -51,7 +51,7 @@ const Table = React.memo(
51
51
  }
52
52
  );
53
53
  const Wrapped = styled(Datatable)`
54
- ${(props) => props.hasRowLink ? `.MuiTableCell-root {
54
+ ${(props) => props?.hasRowLink ? `.MuiTableCell-root {
55
55
  font-size: 1rem !important;
56
56
  }` : ""}
57
57
  .MuiPaper-root {
package/es/libs/util.d.ts CHANGED
@@ -107,3 +107,4 @@ export declare function formatAmountPrecisionLimit(amount: string, locale?: stri
107
107
  export declare function getWordBreakStyle(value: any): 'break-word' | 'break-all';
108
108
  export declare function isMobileSafari(): boolean;
109
109
  export declare function truncateText(text: string, maxLength: number, useWidth?: boolean): string;
110
+ export declare function getCustomerAvatar(did: string | undefined, updated_at: string | number | undefined, imageSize?: number): string;
package/es/libs/util.js CHANGED
@@ -838,3 +838,6 @@ export function truncateText(text, maxLength, useWidth = false) {
838
838
  }
839
839
  return `${truncated}...`;
840
840
  }
841
+ export function getCustomerAvatar(did, updated_at, imageSize = 48) {
842
+ return `/.well-known/service/user/avatar/${did}?imageFilter=resize&w=${imageSize}&h=${imageSize}&updateAt=${updated_at || dayjs().unix()}`;
843
+ }
@@ -331,7 +331,7 @@ export default function PaymentForm({
331
331
  children: t("payment.checkout.paymentDetails")
332
332
  }
333
333
  ),
334
- /* @__PURE__ */ jsx(Fade, { in: true, children: /* @__PURE__ */ jsxs(Stack, { direction: "column", alignItems: "flex-start", className: "cko-payment-methods", sx: { mb: 1 }, children: [
334
+ /* @__PURE__ */ jsx(Fade, { in: true, children: /* @__PURE__ */ jsxs(Stack, { direction: "column", alignItems: "flex-start", className: "cko-payment-methods", children: [
335
335
  /* @__PURE__ */ jsx(Stack, { direction: "row", sx: { width: "100%" }, children: /* @__PURE__ */ jsx(
336
336
  Controller,
337
337
  {
@@ -368,7 +368,7 @@ export default function PaymentForm({
368
368
  id: "cko-payment-form",
369
369
  spacing: 0,
370
370
  ref: !isEmpty(errors) ? errorRef : void 0,
371
- sx: { flex: 1, overflow: "auto" },
371
+ sx: { flex: 1, overflow: "auto", py: 1 },
372
372
  children: [
373
373
  /* @__PURE__ */ jsx(FormLabel, { className: "base-label", children: t("payment.checkout.customer.name") }),
374
374
  /* @__PURE__ */ jsx(
@@ -89,7 +89,7 @@ function SupporterAvatar({
89
89
  max: 20,
90
90
  children: customers.map(x => /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Avatar, {
91
91
  title: x.customer?.name,
92
- src: `/.well-known/service/user/avatar/${x.customer?.did}?imageFilter=resize&w=48&h=48`,
92
+ src: (0, _util.getCustomerAvatar)(x.customer?.did, x?.updated_at ? new Date(x.updated_at).toISOString() : "", 48),
93
93
  variant: "circular",
94
94
  sx: {
95
95
  width: 32,
@@ -153,7 +153,7 @@ function SupporterTable({
153
153
  alignItems: "center",
154
154
  spacing: 0.5,
155
155
  children: [/* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Avatar, {
156
- src: `/.well-known/service/user/avatar/${x.customer?.did}?imageFilter=resize&w=48&h=48`,
156
+ src: (0, _util.getCustomerAvatar)(x.customer?.did, x?.updated_at ? new Date(x.updated_at).toISOString() : "", 48),
157
157
  variant: "circular",
158
158
  sx: {
159
159
  width: 24,
@@ -239,7 +239,7 @@ function SupporterSimple({
239
239
  max: 10,
240
240
  children: customers.map(x => /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Avatar, {
241
241
  title: x.customer?.name,
242
- src: `/.well-known/service/user/avatar/${x.customer?.did}?imageFilter=resize&w=48&h=48`,
242
+ src: (0, _util.getCustomerAvatar)(x.customer?.did, x?.updated_at ? new Date(x.updated_at).toISOString() : "", 48),
243
243
  variant: "circular",
244
244
  sx: {
245
245
  width: 24,
@@ -71,7 +71,7 @@ const Table = _react.default.memo(({
71
71
  });
72
72
  });
73
73
  const Wrapped = (0, _system.styled)(_Datatable.default)`
74
- ${props => props.hasRowLink ? `.MuiTableCell-root {
74
+ ${props => props?.hasRowLink ? `.MuiTableCell-root {
75
75
  font-size: 1rem !important;
76
76
  }` : ""}
77
77
  .MuiPaper-root {
@@ -107,3 +107,4 @@ export declare function formatAmountPrecisionLimit(amount: string, locale?: stri
107
107
  export declare function getWordBreakStyle(value: any): 'break-word' | 'break-all';
108
108
  export declare function isMobileSafari(): boolean;
109
109
  export declare function truncateText(text: string, maxLength: number, useWidth?: boolean): string;
110
+ export declare function getCustomerAvatar(did: string | undefined, updated_at: string | number | undefined, imageSize?: number): string;
package/lib/libs/util.js CHANGED
@@ -28,6 +28,7 @@ exports.formatToDatetime = formatToDatetime;
28
28
  exports.formatTotalPrice = formatTotalPrice;
29
29
  exports.formatUpsellSaving = formatUpsellSaving;
30
30
  exports.getCheckoutAmount = getCheckoutAmount;
31
+ exports.getCustomerAvatar = getCustomerAvatar;
31
32
  exports.getFreeTrialTime = getFreeTrialTime;
32
33
  exports.getInvoiceStatusColor = getInvoiceStatusColor;
33
34
  exports.getPaymentIntentStatusColor = getPaymentIntentStatusColor;
@@ -1009,4 +1010,7 @@ function truncateText(text, maxLength, useWidth = false) {
1009
1010
  return truncated;
1010
1011
  }
1011
1012
  return `${truncated}...`;
1013
+ }
1014
+ function getCustomerAvatar(did, updated_at, imageSize = 48) {
1015
+ return `/.well-known/service/user/avatar/${did}?imageFilter=resize&w=${imageSize}&h=${imageSize}&updateAt=${updated_at || (0, _dayjs.default)().unix()}`;
1012
1016
  }
@@ -399,9 +399,6 @@ function PaymentForm({
399
399
  direction: "column",
400
400
  alignItems: "flex-start",
401
401
  className: "cko-payment-methods",
402
- sx: {
403
- mb: 1
404
- },
405
402
  children: [/* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Stack, {
406
403
  direction: "row",
407
404
  sx: {
@@ -434,7 +431,8 @@ function PaymentForm({
434
431
  ref: !(0, _lodash.isEmpty)(errors) ? errorRef : void 0,
435
432
  sx: {
436
433
  flex: 1,
437
- overflow: "auto"
434
+ overflow: "auto",
435
+ py: 1
438
436
  },
439
437
  children: [/* @__PURE__ */(0, _jsxRuntime.jsx)(_material.FormLabel, {
440
438
  className: "base-label",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blocklet/payment-react",
3
- "version": "1.14.37",
3
+ "version": "1.14.39",
4
4
  "description": "Reusable react components for payment kit v2",
5
5
  "keywords": [
6
6
  "react",
@@ -53,21 +53,21 @@
53
53
  }
54
54
  },
55
55
  "dependencies": {
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",
56
+ "@arcblock/did-connect": "^2.10.25",
57
+ "@arcblock/ux": "2.10.24",
58
+ "@arcblock/ws": "^1.18.135",
59
+ "@blocklet/ui-react": "^2.10.25",
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.132",
65
+ "@ocap/util": "^1.18.135",
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",
69
69
  "ahooks": "^3.8.0",
70
- "axios": "^1.7.2",
70
+ "axios": "^1.7.5",
71
71
  "dayjs": "^1.11.12",
72
72
  "flat": "^5.0.2",
73
73
  "google-libphonenumber": "^3.2.38",
@@ -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.37",
96
+ "@blocklet/payment-types": "1.14.39",
97
97
  "@storybook/addon-essentials": "^7.6.20",
98
98
  "@storybook/addon-interactions": "^7.6.20",
99
99
  "@storybook/addon-links": "^7.6.20",
@@ -116,12 +116,12 @@
116
116
  "react-dom": "18.2.0",
117
117
  "rollup-plugin-node-builtins": "^2.1.2",
118
118
  "storybook": "^7.6.20",
119
- "ts-jest": "^29.2.3",
119
+ "ts-jest": "^29.2.5",
120
120
  "type-fest": "^4.23.0",
121
121
  "typescript": "^4.9.5",
122
122
  "unbuild": "^2.0.0",
123
123
  "vite-plugin-babel": "^1.2.0",
124
124
  "vite-plugin-node-polyfills": "^0.21.0"
125
125
  },
126
- "gitHead": "645ae0bdbab463eec878af0521eb982b51499639"
126
+ "gitHead": "a0f45877c7288ccd7a7f73b3fedc464c19cc0163"
127
127
  }
@@ -34,7 +34,7 @@ import { useEffect, useState } from 'react';
34
34
 
35
35
  import TxLink from '../components/blockchain/tx';
36
36
  import api from '../libs/api';
37
- import { formatAmount, formatBNStr, formatDateTime, formatError, lazyLoad } from '../libs/util';
37
+ import { formatAmount, formatBNStr, formatDateTime, formatError, getCustomerAvatar, lazyLoad } from '../libs/util';
38
38
  import { CheckoutProps, PaymentThemeOptions } from '../types';
39
39
  import CheckoutForm from './form';
40
40
  import { PaymentThemeProvider } from '../theme';
@@ -136,7 +136,7 @@ function SupporterAvatar({ supporters = [], totalAmount = '0', currency, method
136
136
  <Avatar
137
137
  key={x.id}
138
138
  title={x.customer?.name}
139
- src={`/.well-known/service/user/avatar/${x.customer?.did}?imageFilter=resize&w=48&h=48`}
139
+ src={getCustomerAvatar(x.customer?.did, x?.updated_at ? new Date(x.updated_at).toISOString() : '', 48)}
140
140
  variant="circular"
141
141
  sx={{ width: 32, height: 32 }}
142
142
  />
@@ -183,7 +183,11 @@ function SupporterTable({ supporters = [], totalAmount = '0', currency, method }
183
183
  <Stack direction="row" alignItems="center" spacing={0.5}>
184
184
  <Avatar
185
185
  key={x.id}
186
- src={`/.well-known/service/user/avatar/${x.customer?.did}?imageFilter=resize&w=48&h=48`}
186
+ src={getCustomerAvatar(
187
+ x.customer?.did,
188
+ x?.updated_at ? new Date(x.updated_at).toISOString() : '',
189
+ 48
190
+ )}
187
191
  variant="circular"
188
192
  sx={{ width: 24, height: 24 }}
189
193
  />
@@ -247,7 +251,7 @@ function SupporterSimple({ supporters = [], totalAmount = '0', currency, method
247
251
  <Avatar
248
252
  key={x.id}
249
253
  title={x.customer?.name}
250
- src={`/.well-known/service/user/avatar/${x.customer?.did}?imageFilter=resize&w=48&h=48`}
254
+ src={getCustomerAvatar(x.customer?.did, x?.updated_at ? new Date(x.updated_at).toISOString() : '', 48)}
251
255
  variant="circular"
252
256
  sx={{ width: 24, height: 24 }}
253
257
  />
@@ -57,9 +57,19 @@ const Table = React.memo(
57
57
  }
58
58
  );
59
59
 
60
+ interface TableProps {
61
+ options: any;
62
+ columns: any;
63
+ toolbar?: boolean;
64
+ footer?: boolean;
65
+ hasRowLink?: boolean;
66
+ emptyNodeText?: string;
67
+ mobileTDFlexDirection?: string;
68
+ }
69
+
60
70
  const Wrapped = styled(Datatable)`
61
- ${(props) =>
62
- props.hasRowLink
71
+ ${(props: any) =>
72
+ props?.hasRowLink
63
73
  ? `.MuiTableCell-root {
64
74
  font-size: 1rem !important;
65
75
  }`
@@ -176,7 +186,7 @@ const Wrapped = styled(Datatable)`
176
186
  align-items: center;
177
187
  padding: 0;
178
188
  flex-wrap: wrap;
179
- flex-direction: ${({ mobileTDFlexDirection = 'column' }) => mobileTDFlexDirection || 'row'};
189
+ flex-direction: ${({ mobileTDFlexDirection = 'column' }: TableProps) => mobileTDFlexDirection || 'row'};
180
190
  align-items: ${({ mobileTDFlexDirection = 'column' }) =>
181
191
  mobileTDFlexDirection === 'column' ? 'flex-start' : 'center'};
182
192
  justify-content: ${({ mobileTDFlexDirection = 'column' }) =>
package/src/libs/util.ts CHANGED
@@ -1083,3 +1083,11 @@ export function truncateText(text: string, maxLength: number, useWidth: boolean
1083
1083
 
1084
1084
  return `${truncated}...`;
1085
1085
  }
1086
+
1087
+ export function getCustomerAvatar(
1088
+ did: string | undefined,
1089
+ updated_at: string | number | undefined,
1090
+ imageSize: number = 48
1091
+ ): string {
1092
+ return `/.well-known/service/user/avatar/${did}?imageFilter=resize&w=${imageSize}&h=${imageSize}&updateAt=${updated_at || dayjs().unix()}`;
1093
+ }
@@ -416,7 +416,7 @@ export default function PaymentForm({
416
416
  {t('payment.checkout.paymentDetails')}
417
417
  </Typography>
418
418
  <Fade in>
419
- <Stack direction="column" alignItems="flex-start" className="cko-payment-methods" sx={{ mb: 1 }}>
419
+ <Stack direction="column" alignItems="flex-start" className="cko-payment-methods">
420
420
  <Stack direction="row" sx={{ width: '100%' }}>
421
421
  <Controller
422
422
  name="payment_currency"
@@ -449,7 +449,7 @@ export default function PaymentForm({
449
449
  id="cko-payment-form"
450
450
  spacing={0}
451
451
  ref={!isEmpty(errors) ? (errorRef as any) : undefined}
452
- sx={{ flex: 1, overflow: 'auto' }}>
452
+ sx={{ flex: 1, overflow: 'auto', py: 1 }}>
453
453
  <FormLabel className="base-label">{t('payment.checkout.customer.name')}</FormLabel>
454
454
  <FormInput
455
455
  name="customer_name"