tek-wallet 0.0.158 → 0.0.161

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,27 @@ 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
- };
100
+ (0, react_1.useImperativeHandle)(ref, function () { return ({
101
+ clearData: function () {
102
+ setOtp("");
103
+ },
104
+ }); });
119
105
  var handleOtpChange = function (value) { return __awaiter(void 0, void 0, void 0, function () {
106
+ var err_1;
120
107
  var _a, _b;
121
108
  return __generator(this, function (_c) {
122
109
  switch (_c.label) {
123
110
  case 0:
111
+ _c.trys.push([0, 3, , 4]);
124
112
  setOtp(value);
125
113
  if (!(value.length === passcodeLength)) return [3 /*break*/, 2];
126
114
  (_a = loadingRef.current) === null || _a === void 0 ? void 0 : _a.startLoading();
@@ -129,15 +117,18 @@ var ConfirmByPasscode = (0, react_1.forwardRef)(function (props, ref) {
129
117
  _c.sent();
130
118
  onConfirmSuccess === null || onConfirmSuccess === void 0 ? void 0 : onConfirmSuccess(value);
131
119
  (_b = loadingRef.current) === null || _b === void 0 ? void 0 : _b.endLoading();
132
- if (ref && typeof ref !== "function" && ref.current) {
133
- ref.current.close();
134
- }
120
+ ref;
135
121
  _c.label = 2;
136
- case 2: return [2 /*return*/];
122
+ case 2: return [3 /*break*/, 4];
123
+ case 3:
124
+ err_1 = _c.sent();
125
+ console.error(err_1);
126
+ return [3 /*break*/, 4];
127
+ case 4: return [2 /*return*/];
137
128
  }
138
129
  });
139
130
  }); };
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 })] }) }) }) })));
131
+ return ((0, jsx_runtime_1.jsx)(ModalLayout_1.default, { title: "Confirm", 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)(LoadingLayout_1.default, { initLoading: false, ref: loadingRef, children: (0, jsx_runtime_1.jsx)(OTP_1.default, { value: otp, onChange: handleOtpChange, numInputs: passcodeLength, otpInputType: OTP_1.OtpInputType.PASSWORD }) })] }) }));
141
132
  });
142
133
  ConfirmByPasscode.displayName = "ConfirmByPasscode";
143
134
  exports.default = ConfirmByPasscode;
@@ -25,7 +25,7 @@ var DrawerComponent_1 = __importDefault(require("../DrawerComponent"));
25
25
  var react_1 = require("react");
26
26
  var ConfirmLayout = (0, react_1.forwardRef)(function (props, ref) {
27
27
  var theme = (0, material_1.useTheme)();
28
- return ((0, jsx_runtime_1.jsx)(DrawerComponent_1.default, { ref: ref, trigger: props.trigger, onOpen: props.onOpen, onClose: props.onClose, children: (0, jsx_runtime_1.jsx)(ModalLayout_1.default, { children: (0, jsx_runtime_1.jsxs)(material_1.Box, { sx: __assign(__assign({}, theme.mixins.column), { alignItems: "center", gap: theme.mixins.gaps.g16 }), children: [(0, jsx_runtime_1.jsxs)(material_1.Box, { sx: __assign(__assign({}, theme.mixins.column), { gap: theme.mixins.gaps.g12 }), children: [(0, jsx_runtime_1.jsx)(Icon_1.default, { width: 64, sx: {}, src: (0, getIcon_1.default)("wallet_logo") }), (0, jsx_runtime_1.jsx)(Text_1.default, { sx: __assign({}, theme.mixins.sessionDescription), children: "Confirm action" }), (0, jsx_runtime_1.jsx)(Text_1.default, { sx: __assign({}, theme.mixins.sessionTitle), children: props.action })] }), props.children] }) }) }));
28
+ return ((0, jsx_runtime_1.jsx)(DrawerComponent_1.default, { ref: ref, trigger: props.trigger, onOpen: props.onOpen, onClose: props.onClose, children: (0, jsx_runtime_1.jsx)(ModalLayout_1.default, { children: (0, jsx_runtime_1.jsxs)(material_1.Box, { sx: __assign(__assign({}, theme.mixins.column), { alignItems: "center", gap: theme.mixins.gaps.g16 }), children: [(0, jsx_runtime_1.jsxs)(material_1.Box, { sx: __assign(__assign({}, theme.mixins.column), { alignItems: "center", gap: theme.mixins.gaps.g12 }), children: [(0, jsx_runtime_1.jsx)(Icon_1.default, { width: 64, sx: {}, src: (0, getIcon_1.default)("wallet_logo") }), (0, jsx_runtime_1.jsx)(Text_1.default, { sx: __assign({}, theme.mixins.sessionDescription), children: "Confirm action" }), (0, jsx_runtime_1.jsx)(Text_1.default, { sx: __assign(__assign({}, theme.mixins.sessionTitle), { textTransform: "capitalize" }), children: props.action })] }), props.children] }) }) }));
29
29
  });
30
30
  ConfirmLayout.displayName = "ConfirmLayout";
31
31
  exports.default = ConfirmLayout;
@@ -1,5 +1,5 @@
1
1
  export declare enum ActionConfirm {
2
2
  WITHDRAW = "withdraw",
3
3
  TRANSFER = "transfer",
4
- LOCK = "lock"
4
+ LOCK = "lock token"
5
5
  }
@@ -5,5 +5,5 @@ var ActionConfirm;
5
5
  (function (ActionConfirm) {
6
6
  ActionConfirm["WITHDRAW"] = "withdraw";
7
7
  ActionConfirm["TRANSFER"] = "transfer";
8
- ActionConfirm["LOCK"] = "lock";
8
+ ActionConfirm["LOCK"] = "lock token";
9
9
  })(ActionConfirm || (exports.ActionConfirm = ActionConfirm = {}));
@@ -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)(material_1.Box, { sx: __assign(__assign({ position: "absolute", inset: 0 }, theme.mixins.whiteLoadingOverlay), { zIndex: 1000 }), children: (0, jsx_runtime_1.jsx)(Text_1.default, { sx: __assign({}, theme.mixins.center), children: loadingMessage }) }))] }));
34
34
  });
35
35
  LoadingLayout.displayName = "LoadingLayout";
36
36
  exports.default = LoadingLayout;
@@ -24,11 +24,20 @@ 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 confirmByPasscodeDrawerRef = (0, react_1.useRef)(null);
31
+ var confirmByPasscodeRef = (0, react_1.useRef)(null);
32
+ var handleClearConfirmData = function () {
33
+ var _a;
34
+ (_a = confirmByPasscodeRef.current) === null || _a === void 0 ? void 0 : _a.clearData();
35
+ };
29
36
  var handleLockToken = function () {
37
+ var _a;
38
+ (_a = confirmByPasscodeDrawerRef.current) === null || _a === void 0 ? void 0 : _a.close();
30
39
  console.warn("🚀 ~ handleLockToken ~ lockData:", props.lockData);
31
40
  };
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 }) })] }) }) }));
41
+ 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
42
  };
34
43
  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.158",
3
+ "version": "0.0.161",
4
4
  "description": "A custom React provider with TypeScript support",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",