tek-wallet 0.0.157 → 0.0.160

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.
@@ -1,9 +1,11 @@
1
1
  import { GeneralProps } from "../../../types/ui";
2
2
  import { ActionConfirm } from "../ConfirmLayout/type";
3
- import { DrawerComponentProps, DrawerComponentRef } from "../DrawerComponent";
4
- interface ConfirmByPasscodeProps extends GeneralProps, DrawerComponentProps {
3
+ interface ConfirmByPasscodeProps extends GeneralProps {
5
4
  onConfirmSuccess?: (value: string) => any;
6
5
  action: ActionConfirm;
7
6
  }
8
- declare const ConfirmByPasscode: import("react").ForwardRefExoticComponent<ConfirmByPasscodeProps & import("react").RefAttributes<DrawerComponentRef>>;
7
+ export interface ConfirmByPasscodeRef {
8
+ clearData: () => void;
9
+ }
10
+ declare const ConfirmByPasscode: import("react").ForwardRefExoticComponent<ConfirmByPasscodeProps & import("react").RefAttributes<ConfirmByPasscodeRef>>;
9
11
  export default ConfirmByPasscode;
@@ -80,17 +80,6 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
80
80
  if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
81
81
  }
82
82
  };
83
- var __rest = (this && this.__rest) || function (s, e) {
84
- var t = {};
85
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
86
- t[p] = s[p];
87
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
88
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
89
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
90
- t[p[i]] = s[p[i]];
91
- }
92
- return t;
93
- };
94
83
  var __importDefault = (this && this.__importDefault) || function (mod) {
95
84
  return (mod && mod.__esModule) ? mod : { "default": mod };
96
85
  };
@@ -99,28 +88,22 @@ var jsx_runtime_1 = require("react/jsx-runtime");
99
88
  var OTP_1 = __importStar(require("../../../components/ui/OTP"));
100
89
  var react_1 = require("react");
101
90
  var Text_1 = __importDefault(require("../../../components/ui/Text"));
102
- var DrawerComponent_1 = __importDefault(require("../DrawerComponent"));
103
91
  var ModalLayout_1 = __importDefault(require("../ModalLayout"));
104
92
  var material_1 = require("@mui/material");
105
93
  var LoadingLayout_1 = __importDefault(require("../LoadingLayout"));
106
94
  var passcodeLength = 6;
107
95
  var ConfirmByPasscode = (0, react_1.forwardRef)(function (props, ref) {
108
- var action = props.action, onConfirmSuccess = props.onConfirmSuccess, onClose = props.onClose, rest = __rest(props, ["action", "onConfirmSuccess", "onClose"]);
96
+ var action = props.action, onConfirmSuccess = props.onConfirmSuccess;
109
97
  var theme = (0, material_1.useTheme)();
110
98
  var _a = (0, react_1.useState)(""), otp = _a[0], setOtp = _a[1];
111
99
  var loadingRef = (0, react_1.useRef)(null);
112
- var resetValue = function () {
113
- setOtp("");
114
- };
115
- var handleClose = function () {
116
- onClose === null || onClose === void 0 ? void 0 : onClose();
117
- resetValue();
118
- };
119
100
  var handleOtpChange = function (value) { return __awaiter(void 0, void 0, void 0, function () {
101
+ var err_1;
120
102
  var _a, _b;
121
103
  return __generator(this, function (_c) {
122
104
  switch (_c.label) {
123
105
  case 0:
106
+ _c.trys.push([0, 3, , 4]);
124
107
  setOtp(value);
125
108
  if (!(value.length === passcodeLength)) return [3 /*break*/, 2];
126
109
  (_a = loadingRef.current) === null || _a === void 0 ? void 0 : _a.startLoading();
@@ -129,15 +112,18 @@ var ConfirmByPasscode = (0, react_1.forwardRef)(function (props, ref) {
129
112
  _c.sent();
130
113
  onConfirmSuccess === null || onConfirmSuccess === void 0 ? void 0 : onConfirmSuccess(value);
131
114
  (_b = loadingRef.current) === null || _b === void 0 ? void 0 : _b.endLoading();
132
- if (ref && typeof ref !== "function" && ref.current) {
133
- ref.current.close();
134
- }
115
+ ref;
135
116
  _c.label = 2;
136
- case 2: return [2 /*return*/];
117
+ case 2: return [3 /*break*/, 4];
118
+ case 3:
119
+ err_1 = _c.sent();
120
+ console.error(err_1);
121
+ return [3 /*break*/, 4];
122
+ case 4: return [2 /*return*/];
137
123
  }
138
124
  });
139
125
  }); };
140
- return ((0, jsx_runtime_1.jsx)(DrawerComponent_1.default, __assign({ ref: ref }, rest, { onClose: handleClose, children: (0, jsx_runtime_1.jsx)(ModalLayout_1.default, { title: "Confirm", children: (0, jsx_runtime_1.jsx)(LoadingLayout_1.default, { initLoading: false, ref: loadingRef, children: (0, jsx_runtime_1.jsxs)(material_1.Box, { sx: __assign(__assign({}, theme.mixins.column), { justifyContent: "center", alignItems: "center", gap: "1rem", height: "100%" }), children: [(0, jsx_runtime_1.jsxs)(Text_1.default, { sx: __assign({}, theme.mixins.sessionTitle), children: ["Enter your passcode to confirm", " ", (0, jsx_runtime_1.jsx)(Text_1.default, { sx: { fontWeight: theme.typography.fontWeight600 }, children: action })] }), (0, jsx_runtime_1.jsx)(OTP_1.default, { value: otp, onChange: handleOtpChange, numInputs: passcodeLength, otpInputType: OTP_1.OtpInputType.PASSWORD })] }) }) }) })));
126
+ return ((0, jsx_runtime_1.jsx)(ModalLayout_1.default, { title: "Confirm", children: (0, jsx_runtime_1.jsx)(LoadingLayout_1.default, { initLoading: false, ref: loadingRef, children: (0, jsx_runtime_1.jsxs)(material_1.Box, { sx: __assign(__assign({}, theme.mixins.column), { justifyContent: "center", alignItems: "center", gap: "1rem", width: "100%" }), children: [(0, jsx_runtime_1.jsxs)(Text_1.default, { sx: __assign({}, theme.mixins.sessionTitle), children: ["Enter your passcode to confirm", " ", (0, jsx_runtime_1.jsx)(Text_1.default, { sx: { fontWeight: theme.typography.fontWeight600 }, children: action })] }), (0, jsx_runtime_1.jsx)(OTP_1.default, { value: otp, onChange: handleOtpChange, numInputs: passcodeLength, otpInputType: OTP_1.OtpInputType.PASSWORD })] }) }) }));
141
127
  });
142
128
  ConfirmByPasscode.displayName = "ConfirmByPasscode";
143
129
  exports.default = ConfirmByPasscode;
@@ -30,7 +30,7 @@ var LoadingLayout = (0, react_1.forwardRef)(function (props, ref) {
30
30
  setLoading(false);
31
31
  },
32
32
  }); });
33
- return ((0, jsx_runtime_1.jsxs)(material_1.Box, { sx: __assign({ position: "relative" }, sx), children: [children, loading && ((0, jsx_runtime_1.jsx)(Text_1.default, { sx: __assign(__assign({ position: "absolute", inset: 0, display: "flex", margin: "auto", color: "text.white" }, theme.mixins.whiteLoadingOverlay), { zIndex: 1000 }), children: loadingMessage }))] }));
33
+ return ((0, jsx_runtime_1.jsxs)(material_1.Box, { sx: __assign({ position: "relative", width: "100%", height: "fit-content" }, sx), children: [children, loading && ((0, jsx_runtime_1.jsx)(Text_1.default, { sx: __assign(__assign({ position: "absolute", inset: 0, display: "flex", margin: "auto", color: "text.white" }, theme.mixins.whiteLoadingOverlay), { zIndex: 1000 }), children: loadingMessage }))] }));
34
34
  });
35
35
  LoadingLayout.displayName = "LoadingLayout";
36
36
  exports.default = LoadingLayout;
@@ -1,7 +1,7 @@
1
1
  import { GeneralProps } from "../../../types/ui";
2
2
  import { ConfirmLayoutProps } from "../ConfirmLayout";
3
3
  import { LockData } from "./type";
4
- interface LockTokenProps extends GeneralProps, ConfirmLayoutProps {
4
+ interface LockTokenProps extends GeneralProps, Omit<ConfirmLayoutProps, "action"> {
5
5
  lockData: LockData;
6
6
  }
7
7
  declare const LockToken: (props: LockTokenProps) => import("react/jsx-runtime").JSX.Element;
@@ -24,11 +24,17 @@ var type_1 = require("../ConfirmLayout/type");
24
24
  var LineValue_1 = __importDefault(require("../LineValue"));
25
25
  var Formatter_1 = __importDefault(require("../Formatter"));
26
26
  var ConfirmByPasscode_1 = __importDefault(require("../ConfirmByPasscode"));
27
+ var react_1 = require("react");
27
28
  var LockToken = function (props) {
28
29
  var theme = (0, material_1.useTheme)();
30
+ var confirmByPasscodeRef = (0, react_1.useRef)(null);
31
+ var handleClearConfirmData = function () {
32
+ var _a;
33
+ (_a = confirmByPasscodeRef.current) === null || _a === void 0 ? void 0 : _a.clearData();
34
+ };
29
35
  var handleLockToken = function () {
30
36
  console.warn("🚀 ~ handleLockToken ~ lockData:", props.lockData);
31
37
  };
32
- return ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: (0, jsx_runtime_1.jsx)(ConfirmLayout_1.default, { action: type_1.ActionConfirm.LOCK, trigger: props.trigger, children: (0, jsx_runtime_1.jsxs)(material_1.Box, { sx: __assign(__assign({}, theme.mixins.column), { gap: theme.mixins.gaps.g16 }), children: [(0, jsx_runtime_1.jsx)(LineValue_1.default, { field: "Amount", value: (0, jsx_runtime_1.jsx)(Formatter_1.default, { value: props.lockData.amount, unit: props.lockData.tokenSlug }) }), (0, jsx_runtime_1.jsx)(DrawerComponent_1.default, { trigger: (0, jsx_runtime_1.jsx)(Button_1.default.Primary, { children: "Confirm" }), children: (0, jsx_runtime_1.jsx)(ConfirmByPasscode_1.default, { action: type_1.ActionConfirm.LOCK, onConfirmSuccess: handleLockToken }) })] }) }) }));
38
+ return ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: (0, jsx_runtime_1.jsx)(ConfirmLayout_1.default, { action: type_1.ActionConfirm.LOCK, trigger: props.trigger, children: (0, jsx_runtime_1.jsxs)(material_1.Box, { sx: __assign(__assign({}, theme.mixins.column), { gap: theme.mixins.gaps.g16 }), children: [(0, jsx_runtime_1.jsx)(LineValue_1.default, { field: "Amount", value: (0, jsx_runtime_1.jsx)(Formatter_1.default, { value: props.lockData.amount, unit: props.lockData.tokenSlug }) }), (0, jsx_runtime_1.jsx)(DrawerComponent_1.default, { trigger: (0, jsx_runtime_1.jsx)(Button_1.default.Primary, { sx: { width: "100%" }, children: "Confirm" }), onOpen: handleClearConfirmData, children: (0, jsx_runtime_1.jsx)(ConfirmByPasscode_1.default, { ref: confirmByPasscodeRef, action: type_1.ActionConfirm.LOCK, onConfirmSuccess: handleLockToken }) })] }) }) }));
33
39
  };
34
40
  exports.default = LockToken;
@@ -125,6 +125,7 @@ var theme = (0, styles_1.createTheme)({
125
125
  column: {
126
126
  display: "flex",
127
127
  flexDirection: "column",
128
+ width: "100%",
128
129
  },
129
130
  headerTitle: {
130
131
  color: "text.white",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tek-wallet",
3
- "version": "0.0.157",
3
+ "version": "0.0.160",
4
4
  "description": "A custom React provider with TypeScript support",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",