tek-wallet 0.0.165 → 0.0.168

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,12 +1,12 @@
1
1
  import { GeneralProps } from "../../../types/ui";
2
2
  import { ActionConfirm } from "../ConfirmLayout/type";
3
- interface ConfirmByPasscodeProps extends GeneralProps {
3
+ import { DrawerComponentProps, DrawerComponentRef } from "../DrawerComponent";
4
+ interface ConfirmByPasscodeProps extends Omit<GeneralProps, "onclick" | "sx" | "onClick">, DrawerComponentProps {
4
5
  onConfirmSuccess?: (value: string) => any;
5
6
  action: ActionConfirm;
6
- onClose?: () => void;
7
7
  }
8
- export interface ConfirmByPasscodeRef {
8
+ export interface ConfirmByPasscodeRef extends Omit<DrawerComponentRef, "trigger"> {
9
9
  clearData: () => void;
10
10
  }
11
- declare const ConfirmByPasscode: import("react").ForwardRefExoticComponent<ConfirmByPasscodeProps & import("react").RefAttributes<ConfirmByPasscodeRef>>;
11
+ declare const ConfirmByPasscode: import("react").ForwardRefExoticComponent<Omit<ConfirmByPasscodeProps, "ref"> & import("react").RefAttributes<ConfirmByPasscodeRef>>;
12
12
  export default ConfirmByPasscode;
@@ -91,44 +91,64 @@ var Text_1 = __importDefault(require("../../../components/ui/Text"));
91
91
  var ModalLayout_1 = __importDefault(require("../ModalLayout"));
92
92
  var material_1 = require("@mui/material");
93
93
  var LoadingLayout_1 = __importDefault(require("../LoadingLayout"));
94
+ var DrawerComponent_1 = __importDefault(require("../DrawerComponent"));
94
95
  var passcodeLength = 6;
95
96
  var ConfirmByPasscode = (0, react_1.forwardRef)(function (props, ref) {
96
97
  var action = props.action, onConfirmSuccess = props.onConfirmSuccess;
97
98
  var theme = (0, material_1.useTheme)();
98
99
  var _a = (0, react_1.useState)(""), otp = _a[0], setOtp = _a[1];
99
100
  var loadingRef = (0, react_1.useRef)(null);
101
+ var drawerRef = (0, react_1.useRef)(null);
100
102
  (0, react_1.useImperativeHandle)(ref, function () { return ({
101
103
  clearData: function () {
102
104
  setOtp("");
103
105
  },
106
+ open: function () {
107
+ var _a;
108
+ (_a = drawerRef.current) === null || _a === void 0 ? void 0 : _a.open();
109
+ },
110
+ close: function () {
111
+ var _a;
112
+ (_a = drawerRef.current) === null || _a === void 0 ? void 0 : _a.close();
113
+ },
114
+ lockStatus: function () {
115
+ var _a;
116
+ (_a = drawerRef.current) === null || _a === void 0 ? void 0 : _a.lockStatus();
117
+ },
118
+ unlockStatus: function () {
119
+ var _a;
120
+ (_a = drawerRef.current) === null || _a === void 0 ? void 0 : _a.unlockStatus();
121
+ },
104
122
  }); });
105
123
  var handleOtpChange = function (value) { return __awaiter(void 0, void 0, void 0, function () {
106
124
  var err_1;
107
- var _a, _b;
108
- return __generator(this, function (_c) {
109
- switch (_c.label) {
125
+ var _a, _b, _c, _d, _e;
126
+ return __generator(this, function (_f) {
127
+ switch (_f.label) {
110
128
  case 0:
111
- _c.trys.push([0, 3, , 4]);
129
+ _f.trys.push([0, 3, , 4]);
112
130
  setOtp(value);
113
131
  if (!(value.length === passcodeLength)) return [3 /*break*/, 2];
114
132
  (_a = loadingRef.current) === null || _a === void 0 ? void 0 : _a.startLoading();
133
+ (_b = drawerRef.current) === null || _b === void 0 ? void 0 : _b.lockStatus();
115
134
  return [4 /*yield*/, new Promise(function (resolve) { return setTimeout(resolve, 1000); })];
116
135
  case 1:
117
- _c.sent();
136
+ _f.sent();
137
+ (_c = drawerRef.current) === null || _c === void 0 ? void 0 : _c.unlockStatus();
138
+ (_d = loadingRef.current) === null || _d === void 0 ? void 0 : _d.endLoading();
139
+ (_e = drawerRef.current) === null || _e === void 0 ? void 0 : _e.close();
118
140
  onConfirmSuccess === null || onConfirmSuccess === void 0 ? void 0 : onConfirmSuccess(value);
119
- (_b = loadingRef.current) === null || _b === void 0 ? void 0 : _b.endLoading();
120
- ref;
121
- _c.label = 2;
141
+ _f.label = 2;
122
142
  case 2: return [3 /*break*/, 4];
123
143
  case 3:
124
- err_1 = _c.sent();
144
+ err_1 = _f.sent();
125
145
  console.error(err_1);
126
146
  return [3 /*break*/, 4];
127
147
  case 4: return [2 /*return*/];
128
148
  }
129
149
  });
130
150
  }); };
131
- return ((0, jsx_runtime_1.jsx)(ModalLayout_1.default, { title: "Authentication", onClose: props.onClose, 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 }) })] }) }));
151
+ return ((0, jsx_runtime_1.jsx)(DrawerComponent_1.default, { ref: drawerRef, trigger: props.children, onOpen: props.onOpen, onClose: props.onClose, children: (0, jsx_runtime_1.jsx)(LoadingLayout_1.default, { initLoading: false, ref: loadingRef, sx: { width: "100%" }, children: (0, jsx_runtime_1.jsx)(ModalLayout_1.default, { title: "Authentication", onClose: props.onClose, 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)("form", { autoComplete: "off", children: (0, jsx_runtime_1.jsx)(OTP_1.default, { value: otp, onChange: handleOtpChange, numInputs: passcodeLength, otpInputType: OTP_1.OtpInputType.PASSWORD }) })] }) }) }) }));
132
152
  });
133
153
  ConfirmByPasscode.displayName = "ConfirmByPasscode";
134
154
  exports.default = ConfirmByPasscode;
@@ -1,8 +1,7 @@
1
- import { GeneralProps } from "../../../types/ui";
2
1
  import { DrawerComponentProps, DrawerComponentRef } from "../DrawerComponent";
3
2
  import { ActionConfirm } from "./type";
4
- export interface ConfirmLayoutProps extends GeneralProps, DrawerComponentProps {
3
+ export interface ConfirmLayoutProps extends DrawerComponentProps {
5
4
  action: ActionConfirm;
6
5
  }
7
- declare const ConfirmLayout: import("react").ForwardRefExoticComponent<ConfirmLayoutProps & import("react").RefAttributes<DrawerComponentRef>>;
6
+ declare const ConfirmLayout: import("react").ForwardRefExoticComponent<Omit<ConfirmLayoutProps, "ref"> & import("react").RefAttributes<DrawerComponentRef>>;
8
7
  export default ConfirmLayout;
@@ -1,9 +1,10 @@
1
1
  import { GeneralProps, UnknownFunction } from "../../../types/ui";
2
+ import { SwipeableDrawerProps } from "@mui/material";
2
3
  export declare enum DRAWER_DIRECTION {
3
4
  LEFT = "left",
4
5
  RIGHT = "right"
5
6
  }
6
- export interface DrawerComponentProps extends GeneralProps {
7
+ export interface DrawerComponentProps extends Omit<GeneralProps, "onClick" | "sx">, Omit<SwipeableDrawerProps, "onClose" | "onToggle" | "onOpen"> {
7
8
  onOpen?: UnknownFunction;
8
9
  onClose?: UnknownFunction;
9
10
  trigger?: React.ReactNode;
@@ -13,6 +14,8 @@ export interface DrawerComponentProps extends GeneralProps {
13
14
  export interface DrawerComponentRef {
14
15
  open: () => void;
15
16
  close: () => void;
17
+ lockStatus: () => void;
18
+ unlockStatus: () => void;
16
19
  }
17
- declare const DrawerComponent: import("react").ForwardRefExoticComponent<DrawerComponentProps & import("react").RefAttributes<DrawerComponentRef>>;
20
+ declare const DrawerComponent: import("react").ForwardRefExoticComponent<Omit<DrawerComponentProps, "ref"> & import("react").RefAttributes<DrawerComponentRef>>;
18
21
  export default DrawerComponent;
@@ -1,4 +1,26 @@
1
1
  "use strict";
2
+ var __assign = (this && this.__assign) || function () {
3
+ __assign = Object.assign || function(t) {
4
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
5
+ s = arguments[i];
6
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
+ t[p] = s[p];
8
+ }
9
+ return t;
10
+ };
11
+ return __assign.apply(this, arguments);
12
+ };
13
+ var __rest = (this && this.__rest) || function (s, e) {
14
+ var t = {};
15
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
16
+ t[p] = s[p];
17
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
18
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
19
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
20
+ t[p[i]] = s[p[i]];
21
+ }
22
+ return t;
23
+ };
2
24
  Object.defineProperty(exports, "__esModule", { value: true });
3
25
  exports.DRAWER_DIRECTION = void 0;
4
26
  var jsx_runtime_1 = require("react/jsx-runtime");
@@ -10,7 +32,10 @@ var DRAWER_DIRECTION;
10
32
  DRAWER_DIRECTION["RIGHT"] = "right";
11
33
  })(DRAWER_DIRECTION || (exports.DRAWER_DIRECTION = DRAWER_DIRECTION = {}));
12
34
  var DrawerComponent = (0, react_1.forwardRef)(function (props, ref) {
13
- var _a = (0, react_1.useState)(false), isShowDrawerComponent = _a[0], setIsShowDrawerComponent = _a[1];
35
+ var _a;
36
+ var onOpen = props.onOpen, onClose = props.onClose, onToggle = props.onToggle, sx = props.sx, trigger = props.trigger, direction = props.direction, children = props.children, rest = __rest(props, ["onOpen", "onClose", "onToggle", "sx", "trigger", "direction", "children"]);
37
+ var _b = (0, react_1.useState)(false), isShowDrawerComponent = _b[0], setIsShowDrawerComponent = _b[1];
38
+ var isOpen = (0, react_1.useRef)(undefined);
14
39
  var handleOpen = function () {
15
40
  setIsShowDrawerComponent(true);
16
41
  };
@@ -18,31 +43,34 @@ var DrawerComponent = (0, react_1.forwardRef)(function (props, ref) {
18
43
  setIsShowDrawerComponent(false);
19
44
  };
20
45
  var toggle = function () {
21
- var _a;
22
46
  setIsShowDrawerComponent(!isShowDrawerComponent);
23
- (_a = props.onToggle) === null || _a === void 0 ? void 0 : _a.call(props, !isShowDrawerComponent);
47
+ onToggle === null || onToggle === void 0 ? void 0 : onToggle(!isShowDrawerComponent);
24
48
  };
25
49
  (0, react_1.useImperativeHandle)(ref, function () { return ({
26
50
  open: handleOpen,
27
51
  close: handleClose,
52
+ lockStatus: function () {
53
+ isOpen.current = isShowDrawerComponent;
54
+ },
55
+ unlockStatus: function () {
56
+ isOpen.current = undefined;
57
+ },
28
58
  }); });
29
- var onClose = function (e) {
30
- var _a;
59
+ var onDrawerClose = function (e) {
31
60
  setIsShowDrawerComponent(false);
32
- (_a = props.onClose) === null || _a === void 0 ? void 0 : _a.call(props, e);
61
+ onClose === null || onClose === void 0 ? void 0 : onClose(e);
33
62
  };
34
- var onOpen = function (e) {
35
- var _a;
63
+ var onDrawerOpen = function (e) {
36
64
  setIsShowDrawerComponent(true);
37
- (_a = props.onOpen) === null || _a === void 0 ? void 0 : _a.call(props, e);
65
+ onOpen === null || onOpen === void 0 ? void 0 : onOpen(e);
38
66
  };
39
- return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(material_1.Box, { sx: props.sx, onClick: toggle, children: props.trigger }), (0, jsx_runtime_1.jsx)(material_1.SwipeableDrawer, { sx: {
67
+ return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(material_1.Box, { sx: sx, onClick: toggle, children: trigger }), (0, jsx_runtime_1.jsx)(material_1.SwipeableDrawer, __assign({}, rest, { sx: {
40
68
  "& .MuiDrawer-paper": {
41
69
  backgroundColor: "transparent",
42
70
  overflow: "hidden",
43
71
  boxShadow: "none",
44
72
  },
45
- }, onOpen: onOpen, anchor: props.direction || "bottom", open: isShowDrawerComponent, onClose: onClose, children: props.children })] }));
73
+ }, onOpen: onDrawerOpen, anchor: direction || "bottom", open: (_a = isOpen.current) !== null && _a !== void 0 ? _a : isShowDrawerComponent, onClose: onDrawerClose, children: children }))] }));
46
74
  });
47
75
  DrawerComponent.displayName = "DrawerComponent";
48
76
  exports.default = DrawerComponent;
@@ -1,7 +1,6 @@
1
- import { GeneralProps } from "../../../types/ui";
2
1
  import { ConfirmLayoutProps } from "../ConfirmLayout";
3
2
  import { LockData } from "./type";
4
- interface LockTokenProps extends GeneralProps, Omit<ConfirmLayoutProps, "action"> {
3
+ interface LockTokenProps extends Omit<ConfirmLayoutProps, "action"> {
5
4
  lockData: LockData;
6
5
  }
7
6
  declare const LockToken: (props: LockTokenProps) => import("react/jsx-runtime").JSX.Element;
@@ -18,7 +18,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
18
18
  var jsx_runtime_1 = require("react/jsx-runtime");
19
19
  var material_1 = require("@mui/material");
20
20
  var Button_1 = __importDefault(require("../../ui/Button"));
21
- var DrawerComponent_1 = __importDefault(require("../DrawerComponent"));
22
21
  var ConfirmLayout_1 = __importDefault(require("../ConfirmLayout"));
23
22
  var type_1 = require("../ConfirmLayout/type");
24
23
  var LineValue_1 = __importDefault(require("../LineValue"));
@@ -28,21 +27,11 @@ var react_1 = require("react");
28
27
  var LockToken = function (props) {
29
28
  var theme = (0, material_1.useTheme)();
30
29
  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
- };
36
- var closeAuthModal = function () {
37
- var _a, _b;
38
- (_a = confirmByPasscodeDrawerRef.current) === null || _a === void 0 ? void 0 : _a.close();
39
- (_b = confirmByPasscodeRef.current) === null || _b === void 0 ? void 0 : _b.clearData();
40
- };
41
- var handleLockToken = function () {
30
+ var handleLockToken = function (passcode) {
42
31
  var _a;
43
32
  (_a = confirmByPasscodeDrawerRef.current) === null || _a === void 0 ? void 0 : _a.close();
44
- console.warn("🚀 ~ handleLockToken ~ lockData:", props.lockData);
33
+ console.warn("🚀 ~ handleLockToken ~ lockData:", props.lockData, passcode);
45
34
  };
46
- 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, { ref: confirmByPasscodeDrawerRef, trigger: (0, jsx_runtime_1.jsx)(Button_1.default.Primary, { sx: { width: "100%" }, children: "Confirm" }), onOpen: handleClearConfirmData, onClose: handleClearConfirmData, children: (0, jsx_runtime_1.jsx)(ConfirmByPasscode_1.default, { ref: confirmByPasscodeRef, action: type_1.ActionConfirm.LOCK, onConfirmSuccess: handleLockToken, onClose: closeAuthModal }) })] }) }) }));
35
+ 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)(ConfirmByPasscode_1.default, { action: type_1.ActionConfirm.LOCK, onConfirmSuccess: handleLockToken, children: (0, jsx_runtime_1.jsx)(Button_1.default.Primary, { sx: { width: "100%" }, children: "Confirm" }) })] }) }) }));
47
36
  };
48
37
  exports.default = LockToken;
@@ -46,9 +46,9 @@ var CustomOtpInput = function (props) {
46
46
  outline: "none",
47
47
  color: "#ffffff",
48
48
  backgroundColor: "#ffffff29",
49
- }, renderInput: function (props) { return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("input", __assign({}, props, { inputMode: "decimal", autoComplete: "off", type: "text" })), (0, jsx_runtime_1.jsx)("style", { children: "input::selection {\n background-color: transparent; \n color: white; \n }" })] })); } })));
49
+ }, renderInput: function (props) { return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("input", __assign({}, props, { inputMode: "decimal" })), (0, jsx_runtime_1.jsx)("style", { children: "input::selection {\n background-color: transparent; \n color: white; \n }" })] })); } })));
50
50
  default:
51
- return ((0, jsx_runtime_1.jsx)(react_otp_input_1.default, __assign({}, rest, { renderInput: function (props) { return ((0, jsx_runtime_1.jsx)("input", __assign({}, props, { inputMode: "text", autoComplete: "off", type: "text" }))); } })));
51
+ return ((0, jsx_runtime_1.jsx)(react_otp_input_1.default, __assign({}, rest, { renderInput: function (props) { return ((0, jsx_runtime_1.jsx)("input", __assign({}, props, { inputMode: "text", type: "text" }))); } })));
52
52
  }
53
53
  };
54
54
  exports.default = CustomOtpInput;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tek-wallet",
3
- "version": "0.0.165",
3
+ "version": "0.0.168",
4
4
  "description": "A custom React provider with TypeScript support",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",