@blocklet/payment-react 1.19.0 → 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 (73) hide show
  1. package/es/components/blockchain/tx.d.ts +1 -1
  2. package/es/components/blockchain/tx.js +9 -11
  3. package/es/components/country-select.d.ts +1 -1
  4. package/es/components/date-range-picker.d.ts +13 -0
  5. package/es/components/date-range-picker.js +279 -0
  6. package/es/components/input.d.ts +5 -2
  7. package/es/components/input.js +6 -2
  8. package/es/components/label.d.ts +7 -0
  9. package/es/components/label.js +49 -0
  10. package/es/components/loading-button.d.ts +1 -1
  11. package/es/history/credit/grants-list.d.ts +14 -0
  12. package/es/history/credit/grants-list.js +215 -0
  13. package/es/history/credit/transactions-list.d.ts +13 -0
  14. package/es/history/credit/transactions-list.js +255 -0
  15. package/es/history/invoice/list.js +21 -1
  16. package/es/index.d.ts +5 -1
  17. package/es/index.js +10 -1
  18. package/es/libs/util.d.ts +2 -0
  19. package/es/libs/util.js +12 -0
  20. package/es/locales/en.js +20 -2
  21. package/es/locales/zh.js +20 -2
  22. package/es/payment/form/index.js +44 -6
  23. package/es/payment/index.js +18 -3
  24. package/es/payment/product-item.d.ts +8 -1
  25. package/es/payment/product-item.js +137 -5
  26. package/es/payment/summary.d.ts +3 -1
  27. package/es/payment/summary.js +9 -0
  28. package/lib/components/blockchain/tx.d.ts +1 -1
  29. package/lib/components/blockchain/tx.js +9 -8
  30. package/lib/components/country-select.d.ts +1 -1
  31. package/lib/components/date-range-picker.d.ts +13 -0
  32. package/lib/components/date-range-picker.js +329 -0
  33. package/lib/components/input.d.ts +5 -2
  34. package/lib/components/input.js +8 -4
  35. package/lib/components/label.d.ts +7 -0
  36. package/lib/components/label.js +60 -0
  37. package/lib/components/loading-button.d.ts +1 -1
  38. package/lib/history/credit/grants-list.d.ts +14 -0
  39. package/lib/history/credit/grants-list.js +277 -0
  40. package/lib/history/credit/transactions-list.d.ts +13 -0
  41. package/lib/history/credit/transactions-list.js +301 -0
  42. package/lib/history/invoice/list.js +24 -0
  43. package/lib/index.d.ts +5 -1
  44. package/lib/index.js +39 -0
  45. package/lib/libs/util.d.ts +2 -0
  46. package/lib/libs/util.js +14 -0
  47. package/lib/locales/en.js +20 -2
  48. package/lib/locales/zh.js +20 -2
  49. package/lib/payment/form/index.js +45 -6
  50. package/lib/payment/index.js +20 -2
  51. package/lib/payment/product-item.d.ts +8 -1
  52. package/lib/payment/product-item.js +144 -4
  53. package/lib/payment/summary.d.ts +3 -1
  54. package/lib/payment/summary.js +9 -0
  55. package/package.json +3 -3
  56. package/src/components/blockchain/tx.tsx +9 -15
  57. package/src/components/country-select.tsx +2 -2
  58. package/src/components/date-range-picker.tsx +310 -0
  59. package/src/components/input.tsx +14 -3
  60. package/src/components/label.tsx +58 -0
  61. package/src/components/loading-button.tsx +1 -1
  62. package/src/history/credit/grants-list.tsx +276 -0
  63. package/src/history/credit/transactions-list.tsx +317 -0
  64. package/src/history/invoice/list.tsx +18 -1
  65. package/src/index.ts +9 -0
  66. package/src/libs/util.ts +14 -0
  67. package/src/locales/en.tsx +20 -0
  68. package/src/locales/zh.tsx +19 -0
  69. package/src/payment/form/address.tsx +2 -2
  70. package/src/payment/form/index.tsx +110 -52
  71. package/src/payment/index.tsx +17 -1
  72. package/src/payment/product-item.tsx +152 -4
  73. package/src/payment/summary.tsx +13 -2
@@ -0,0 +1,329 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ module.exports = DateRangePicker;
7
+ var _jsxRuntime = require("react/jsx-runtime");
8
+ var _react = require("react");
9
+ var _material = require("@mui/material");
10
+ var _iconsMaterial = require("@mui/icons-material");
11
+ var _context = require("@arcblock/ux/lib/Locale/context");
12
+ var _label = _interopRequireDefault(require("./label"));
13
+ var _util = require("../libs/util");
14
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
15
+ function DatePickerContent({
16
+ tempValue,
17
+ setTempValue,
18
+ handleCancel,
19
+ handleApply,
20
+ handleClear
21
+ }) {
22
+ const {
23
+ t
24
+ } = (0, _context.useLocaleContext)();
25
+ return /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Box, {
26
+ sx: {
27
+ p: 2,
28
+ minWidth: 320
29
+ },
30
+ children: /* @__PURE__ */(0, _jsxRuntime.jsxs)(_material.Stack, {
31
+ spacing: 2,
32
+ children: [/* @__PURE__ */(0, _jsxRuntime.jsxs)(_material.Box, {
33
+ children: [/* @__PURE__ */(0, _jsxRuntime.jsx)(_label.default, {
34
+ children: t("common.startDate")
35
+ }), /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.TextField, {
36
+ type: "date",
37
+ value: tempValue.startDate,
38
+ onChange: e => setTempValue(prev => ({
39
+ ...prev,
40
+ startDate: e.target.value
41
+ })),
42
+ size: "small",
43
+ fullWidth: true,
44
+ slotProps: {
45
+ inputLabel: {
46
+ shrink: true
47
+ }
48
+ }
49
+ })]
50
+ }), /* @__PURE__ */(0, _jsxRuntime.jsxs)(_material.Box, {
51
+ children: [/* @__PURE__ */(0, _jsxRuntime.jsx)(_label.default, {
52
+ children: t("common.endDate")
53
+ }), /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.TextField, {
54
+ type: "date",
55
+ value: tempValue.endDate,
56
+ onChange: e => setTempValue(prev => ({
57
+ ...prev,
58
+ endDate: e.target.value
59
+ })),
60
+ size: "small",
61
+ fullWidth: true,
62
+ slotProps: {
63
+ inputLabel: {
64
+ shrink: true
65
+ }
66
+ }
67
+ })]
68
+ }), /* @__PURE__ */(0, _jsxRuntime.jsxs)(_material.Stack, {
69
+ direction: "row",
70
+ spacing: 1,
71
+ sx: {
72
+ justifyContent: "space-between"
73
+ },
74
+ children: [/* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Button, {
75
+ variant: "text",
76
+ onClick: handleClear,
77
+ size: "small",
78
+ color: "secondary",
79
+ sx: {
80
+ px: 0.5,
81
+ minWidth: 0
82
+ },
83
+ children: t("common.clear")
84
+ }), /* @__PURE__ */(0, _jsxRuntime.jsxs)(_material.Stack, {
85
+ direction: "row",
86
+ spacing: 1,
87
+ children: [/* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Button, {
88
+ variant: "outlined",
89
+ onClick: handleCancel,
90
+ size: "small",
91
+ children: t("common.cancel")
92
+ }), /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Button, {
93
+ variant: "contained",
94
+ onClick: handleApply,
95
+ size: "small",
96
+ children: t("common.confirm")
97
+ })]
98
+ })]
99
+ })]
100
+ })
101
+ });
102
+ }
103
+ const DateFormat = "YYYY-MM-DD";
104
+ function DateRangePicker({
105
+ value,
106
+ onChange,
107
+ label = "",
108
+ size = "small",
109
+ fullWidth = false,
110
+ disabled = false
111
+ }) {
112
+ const theme = (0, _material.useTheme)();
113
+ const isMobile = (0, _material.useMediaQuery)(theme.breakpoints.down("sm"));
114
+ const [open, setOpen] = (0, _react.useState)(false);
115
+ const {
116
+ t,
117
+ locale
118
+ } = (0, _context.useLocaleContext)();
119
+ const [tempValue, setTempValue] = (0, _react.useState)({
120
+ startDate: value.start ? (0, _util.formatToDate)(value.start * 1e3, locale, DateFormat) : "",
121
+ endDate: value.end ? (0, _util.formatToDate)(value.end * 1e3, locale, DateFormat) : ""
122
+ });
123
+ const anchorRef = (0, _react.useRef)(null);
124
+ const formatDisplayValue = (startUnix, endUnix) => {
125
+ if (!startUnix || !endUnix) return t("common.selectTimeRange");
126
+ const start = (0, _util.formatToDate)(startUnix * 1e3, locale, DateFormat);
127
+ const end = (0, _util.formatToDate)(endUnix * 1e3, locale, DateFormat);
128
+ return `${start} ~ ${end}`;
129
+ };
130
+ const handleOpen = () => {
131
+ if (disabled) return;
132
+ setTempValue({
133
+ startDate: value.start ? (0, _util.formatToDate)(value.start * 1e3, locale, DateFormat) : "",
134
+ endDate: value.end ? (0, _util.formatToDate)(value.end * 1e3, locale, DateFormat) : ""
135
+ });
136
+ setOpen(true);
137
+ };
138
+ const handleClose = () => {
139
+ setOpen(false);
140
+ };
141
+ const handleApply = () => {
142
+ const unixValue = {
143
+ start: tempValue.startDate ? Math.floor((/* @__PURE__ */new Date(`${tempValue.startDate}T00:00:00`)).getTime() / 1e3) : 0,
144
+ end: tempValue.endDate ? Math.floor((/* @__PURE__ */new Date(`${tempValue.endDate}T23:59:59`)).getTime() / 1e3) : 0
145
+ };
146
+ onChange(unixValue);
147
+ setOpen(false);
148
+ };
149
+ const handleCancel = () => {
150
+ setTempValue({
151
+ startDate: value.start ? (0, _util.formatToDate)(value.start * 1e3, locale, DateFormat) : "",
152
+ endDate: value.end ? (0, _util.formatToDate)(value.end * 1e3, locale, DateFormat) : ""
153
+ });
154
+ setOpen(false);
155
+ };
156
+ const handleClear = () => {
157
+ const emptyValue = {
158
+ start: void 0,
159
+ end: void 0
160
+ };
161
+ onChange(emptyValue);
162
+ setTempValue({
163
+ startDate: "",
164
+ endDate: ""
165
+ });
166
+ setOpen(false);
167
+ };
168
+ const hasValue = !!value.start && !!value.end;
169
+ return /* @__PURE__ */(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
170
+ children: [/* @__PURE__ */(0, _jsxRuntime.jsx)(_material.TextField, {
171
+ ref: anchorRef,
172
+ label,
173
+ value: formatDisplayValue(value.start, value.end),
174
+ size,
175
+ fullWidth,
176
+ disabled,
177
+ sx: {
178
+ "& .MuiInputBase-input": {
179
+ cursor: disabled ? "default" : "pointer"
180
+ }
181
+ },
182
+ onClick: handleOpen,
183
+ placeholder: t("common.selectTimeRange"),
184
+ slotProps: {
185
+ input: {
186
+ readOnly: true,
187
+ startAdornment: /* @__PURE__ */(0, _jsxRuntime.jsx)(_iconsMaterial.DateRange, {
188
+ fontSize: "small",
189
+ sx: {
190
+ mr: 1,
191
+ color: "text.secondary"
192
+ }
193
+ }),
194
+ endAdornment: hasValue && !disabled && /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.IconButton, {
195
+ size: "small",
196
+ onClick: e => {
197
+ e.stopPropagation();
198
+ handleClear();
199
+ },
200
+ sx: {
201
+ color: "text.secondary",
202
+ "&:hover": {
203
+ color: "text.primary"
204
+ }
205
+ },
206
+ children: /* @__PURE__ */(0, _jsxRuntime.jsx)(_iconsMaterial.Clear, {
207
+ fontSize: "small"
208
+ })
209
+ })
210
+ },
211
+ inputLabel: {
212
+ shrink: true
213
+ }
214
+ }
215
+ }), !isMobile && /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Popover, {
216
+ open,
217
+ anchorEl: anchorRef.current,
218
+ onClose: handleClose,
219
+ anchorOrigin: {
220
+ vertical: "bottom",
221
+ horizontal: "left"
222
+ },
223
+ transformOrigin: {
224
+ vertical: "top",
225
+ horizontal: "left"
226
+ },
227
+ sx: {
228
+ "& .MuiPaper-root": {
229
+ boxShadow: theme.shadows[8],
230
+ border: `1px solid ${theme.palette.divider}`
231
+ }
232
+ },
233
+ children: /* @__PURE__ */(0, _jsxRuntime.jsx)(DatePickerContent, {
234
+ tempValue,
235
+ setTempValue,
236
+ handleCancel,
237
+ handleApply,
238
+ handleClear
239
+ })
240
+ }), isMobile && /* @__PURE__ */(0, _jsxRuntime.jsxs)(_material.Dialog, {
241
+ open,
242
+ onClose: handleClose,
243
+ fullWidth: true,
244
+ maxWidth: "sm",
245
+ PaperProps: {
246
+ sx: {
247
+ m: 1,
248
+ maxHeight: "calc(100% - 64px)"
249
+ }
250
+ },
251
+ children: [/* @__PURE__ */(0, _jsxRuntime.jsxs)(_material.DialogTitle, {
252
+ sx: {
253
+ display: "flex",
254
+ justifyContent: "space-between",
255
+ alignItems: "center",
256
+ pb: 1
257
+ },
258
+ children: [/* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Typography, {
259
+ variant: "h6",
260
+ children: t("common.selectTimeRange")
261
+ }), /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.IconButton, {
262
+ edge: "end",
263
+ color: "inherit",
264
+ onClick: handleClose,
265
+ "aria-label": "close",
266
+ size: "small",
267
+ children: /* @__PURE__ */(0, _jsxRuntime.jsx)(_iconsMaterial.Close, {})
268
+ })]
269
+ }), /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.DialogContent, {
270
+ sx: {
271
+ pb: 1
272
+ },
273
+ children: /* @__PURE__ */(0, _jsxRuntime.jsxs)(_material.Stack, {
274
+ spacing: 2,
275
+ sx: {
276
+ mt: 1
277
+ },
278
+ children: [/* @__PURE__ */(0, _jsxRuntime.jsx)(_label.default, {
279
+ children: t("common.startDate")
280
+ }), /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.TextField, {
281
+ type: "date",
282
+ value: tempValue.startDate,
283
+ onChange: e => setTempValue(prev => ({
284
+ ...prev,
285
+ startDate: e.target.value
286
+ })),
287
+ size: "small",
288
+ fullWidth: true,
289
+ slotProps: {
290
+ inputLabel: {
291
+ shrink: true
292
+ }
293
+ }
294
+ }), /* @__PURE__ */(0, _jsxRuntime.jsx)(_label.default, {
295
+ children: t("common.endDate")
296
+ }), /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.TextField, {
297
+ type: "date",
298
+ value: tempValue.endDate,
299
+ onChange: e => setTempValue(prev => ({
300
+ ...prev,
301
+ endDate: e.target.value
302
+ })),
303
+ size: "small",
304
+ fullWidth: true,
305
+ slotProps: {
306
+ inputLabel: {
307
+ shrink: true
308
+ }
309
+ }
310
+ })]
311
+ })
312
+ }), /* @__PURE__ */(0, _jsxRuntime.jsxs)(_material.DialogActions, {
313
+ sx: {
314
+ px: 3,
315
+ pb: 2
316
+ },
317
+ children: [/* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Button, {
318
+ onClick: handleCancel,
319
+ color: "inherit",
320
+ children: t("common.cancel")
321
+ }), /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Button, {
322
+ onClick: handleApply,
323
+ variant: "contained",
324
+ children: t("common.confirm")
325
+ })]
326
+ })]
327
+ })]
328
+ });
329
+ }
@@ -8,9 +8,12 @@ type InputProps = TextFieldProps & {
8
8
  errorPosition?: 'right' | 'bottom';
9
9
  rules?: RegisterOptions;
10
10
  wrapperStyle?: React.CSSProperties;
11
+ required?: boolean;
12
+ tooltip?: ReactNode | string;
13
+ description?: ReactNode | string;
11
14
  };
12
- export default function FormInput({ ref, name, label, placeholder, rules, errorPosition, wrapperStyle, inputProps, ...rest }: InputProps & {
13
- ref?: React.RefObject<HTMLInputElement>;
15
+ export default function FormInput({ ref, name, label, placeholder, rules, errorPosition, wrapperStyle, inputProps, required, tooltip, description, ...rest }: InputProps & {
16
+ ref?: React.RefObject<HTMLInputElement | null>;
14
17
  inputProps?: TextFieldProps['inputProps'];
15
18
  }): JSX.Element;
16
19
  export {};
@@ -9,6 +9,7 @@ var _react = require("react");
9
9
  var _material = require("@mui/material");
10
10
  var _get = _interopRequireDefault(require("lodash/get"));
11
11
  var _reactHookForm = require("react-hook-form");
12
+ var _label = _interopRequireDefault(require("./label"));
12
13
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
13
14
  function FormInputError({
14
15
  error
@@ -31,6 +32,9 @@ function FormInput({
31
32
  errorPosition = "bottom",
32
33
  wrapperStyle = {},
33
34
  inputProps = {},
35
+ required = false,
36
+ tooltip = "",
37
+ description = "",
34
38
  ...rest
35
39
  }) {
36
40
  const {
@@ -53,10 +57,10 @@ function FormInput({
53
57
  width: "100%",
54
58
  ...wrapperStyle
55
59
  },
56
- children: [!!label && /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.FormLabel, {
57
- sx: {
58
- color: "text.primary"
59
- },
60
+ children: [!!label && /* @__PURE__ */(0, _jsxRuntime.jsx)(_label.default, {
61
+ required,
62
+ tooltip,
63
+ description,
60
64
  children: label
61
65
  }), /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.TextField, {
62
66
  fullWidth: true,
@@ -0,0 +1,7 @@
1
+ import type { FormLabelProps } from '@mui/material';
2
+ import type { ReactNode } from 'react';
3
+ export default function CustomFormLabel({ children, required, tooltip, description, ...props }: FormLabelProps & {
4
+ required?: boolean;
5
+ tooltip?: ReactNode | string;
6
+ description?: ReactNode | string;
7
+ }): import("react").JSX.Element;
@@ -0,0 +1,60 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ module.exports = CustomFormLabel;
7
+ var _jsxRuntime = require("react/jsx-runtime");
8
+ var _iconsMaterial = require("@mui/icons-material");
9
+ var _material = require("@mui/material");
10
+ function CustomFormLabel({
11
+ children,
12
+ required = false,
13
+ tooltip = "",
14
+ description = "",
15
+ ...props
16
+ }) {
17
+ return /* @__PURE__ */(0, _jsxRuntime.jsxs)(_material.Box, {
18
+ sx: {
19
+ mb: 1,
20
+ width: "100%"
21
+ },
22
+ children: [/* @__PURE__ */(0, _jsxRuntime.jsxs)(_material.FormLabel, {
23
+ ...props,
24
+ sx: {
25
+ display: "flex",
26
+ alignItems: "center",
27
+ gap: 0.5,
28
+ fontWeight: 500,
29
+ color: "text.primary",
30
+ "&.MuiFormLabel-root": {
31
+ display: "flex",
32
+ alignItems: "center",
33
+ gap: 0.5,
34
+ fontWeight: 500,
35
+ color: "text.primary"
36
+ },
37
+ ...(props.sx || {})
38
+ },
39
+ children: [children, required && /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Typography, {
40
+ component: "span",
41
+ color: "error",
42
+ children: "*"
43
+ }), tooltip && (typeof tooltip === "string" ? /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Tooltip, {
44
+ title: tooltip,
45
+ children: /* @__PURE__ */(0, _jsxRuntime.jsx)(_iconsMaterial.InfoOutlined, {
46
+ fontSize: "small",
47
+ sx: {
48
+ opacity: 0.7
49
+ }
50
+ })
51
+ }) : tooltip)]
52
+ }), description && /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Typography, {
53
+ variant: "caption",
54
+ sx: {
55
+ color: "text.secondary"
56
+ },
57
+ children: description
58
+ })]
59
+ });
60
+ }
@@ -7,7 +7,7 @@ export interface LoadingButtonProps extends ButtonProps {
7
7
  loadingOnly?: boolean;
8
8
  }
9
9
  declare function LoadingButton({ ref, children, loading, loadingPosition, loadingIndicator, loadingProps, loadingOnly, onClick, sx, ...props }: LoadingButtonProps & {
10
- ref?: React.RefObject<HTMLButtonElement>;
10
+ ref?: React.RefObject<HTMLButtonElement | null>;
11
11
  }): import("react").JSX.Element;
12
12
  declare namespace LoadingButton {
13
13
  var displayName: string;
@@ -0,0 +1,14 @@
1
+ type Props = {
2
+ customer_id?: string;
3
+ subscription_id?: string;
4
+ status?: string;
5
+ pageSize?: number;
6
+ onTableDataChange?: Function;
7
+ mode?: 'dashboard' | 'portal';
8
+ };
9
+ export declare function StatusChip({ status, label }: {
10
+ status: string;
11
+ label?: string;
12
+ }): JSX.Element;
13
+ export default function CreditGrantsList(rawProps: Props): JSX.Element;
14
+ export {};