tek-wallet 0.0.740 → 0.0.741

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.
@@ -300,7 +300,7 @@ exports.ReceiveFunction = (0, react_1.forwardRef)(function (_a, ref) {
300
300
  setSelectedNetwork(network);
301
301
  gotoStep(ReceiveStep.SHOW_QR_CODE);
302
302
  };
303
- var validateAmount = function (amount) {
303
+ var validateAmount = (0, react_1.useCallback)(function (amount) {
304
304
  var _a, _b;
305
305
  if (amount < ((_a = selectedToken === null || selectedToken === void 0 ? void 0 : selectedToken.min_value) !== null && _a !== void 0 ? _a : 0)) {
306
306
  setAmountError((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: ["Min ", (0, jsx_runtime_1.jsx)(Formatter_1.default, { value: selectedToken === null || selectedToken === void 0 ? void 0 : selectedToken.min_value, unit: " ".concat(selectedToken === null || selectedToken === void 0 ? void 0 : selectedToken.name) })] }));
@@ -312,17 +312,25 @@ exports.ReceiveFunction = (0, react_1.forwardRef)(function (_a, ref) {
312
312
  }
313
313
  setAmountError("");
314
314
  return true;
315
- };
315
+ }, [selectedToken]);
316
316
  var handleAmountModalOpen = function () {
317
317
  var _a;
318
+ setInputAmount(amount);
318
319
  (_a = amountInputRef.current) === null || _a === void 0 ? void 0 : _a.focus();
319
320
  };
321
+ var onCloseAmountModal = (0, react_1.useCallback)(function () {
322
+ setAmountError("");
323
+ setInputAmount("");
324
+ }, []);
325
+ var closeAmountModal = (0, react_1.useCallback)(function () {
326
+ var _a;
327
+ (_a = amountDrawerRef.current) === null || _a === void 0 ? void 0 : _a.close();
328
+ }, []);
320
329
  var handleClickMaxAmount = function () {
321
330
  if (!selectedToken)
322
331
  return;
323
332
  var balance = +(selectedToken === null || selectedToken === void 0 ? void 0 : selectedToken.max_value);
324
333
  var amountNumber = balance || "";
325
- setAmount(amountNumber);
326
334
  setInputAmount(amountNumber);
327
335
  };
328
336
  var handleChangeAmount = function (value) {
@@ -331,18 +339,19 @@ exports.ReceiveFunction = (0, react_1.forwardRef)(function (_a, ref) {
331
339
  return;
332
340
  }
333
341
  setInputAmount(value);
334
- validateAmount(amountNumber);
335
342
  };
343
+ (0, react_1.useEffect)(function () {
344
+ if (!inputAmount)
345
+ return;
346
+ validateAmount(+inputAmount);
347
+ }, [inputAmount, validateAmount]);
336
348
  var handleContinue = function () {
337
- var _a;
338
349
  setAmount(inputAmount);
339
- (_a = amountDrawerRef.current) === null || _a === void 0 ? void 0 : _a.close();
350
+ closeAmountModal();
340
351
  };
341
352
  var handleUnset = function () {
342
- var _a;
343
353
  setAmount("");
344
- setInputAmount("");
345
- (_a = amountDrawerRef.current) === null || _a === void 0 ? void 0 : _a.close();
354
+ closeAmountModal();
346
355
  };
347
356
  var handleOnClose = function () {
348
357
  var _a;
@@ -516,14 +525,14 @@ exports.ReceiveFunction = (0, react_1.forwardRef)(function (_a, ref) {
516
525
  width: "100%",
517
526
  display: "flex",
518
527
  justifyContent: "center",
519
- }, onOpen: handleAmountModalOpen, trigger: (0, jsx_runtime_1.jsx)(xhub_keyboard_1.Label, { htmlFor: keyboardId, children: (0, jsx_runtime_1.jsxs)(Button_1.default.Text, { sx: {
528
+ }, onOpen: handleAmountModalOpen, onClose: onCloseAmountModal, trigger: (0, jsx_runtime_1.jsx)(xhub_keyboard_1.Label, { htmlFor: keyboardId, children: (0, jsx_runtime_1.jsxs)(Button_1.default.Text, { sx: {
520
529
  fontSize: theme.typography.fontSize14,
521
530
  textTransform: "none",
522
531
  fontWeight: theme.typography.fontWeight500,
523
532
  display: "flex",
524
533
  alignItems: "center",
525
534
  gap: theme.mixins.gaps.g4,
526
- }, children: [(0, jsx_runtime_1.jsx)(material_1.SvgIcon, { sx: { width: 20, height: 20 }, children: amount ? SvgPath_1.IC_EDIT : SvgPath_1.IC_SET }), amount ? "Edit" : "Set", " amount"] }) }), children: (0, jsx_runtime_1.jsx)(xhub_keyboard_1.Keyboard, { id: keyboardId, onChange: handleChangeAmount, keyboardType: xhub_keyboard_1.KeyboardType.Double, value: inputAmount === null || inputAmount === void 0 ? void 0 : inputAmount.toString(), keyboardId: "amount-keyboard-id", children: (0, jsx_runtime_1.jsx)(ModalLayout_1.default, { onClose: function () { var _a; return (_a = amountDrawerRef.current) === null || _a === void 0 ? void 0 : _a.close(); }, title: (0, jsx_runtime_1.jsxs)(Text_1.default, { sx: __assign({}, theme.mixins.fieldTitle), children: [amount ? "Edit" : "Set", " ", selectedToken === null || selectedToken === void 0 ? void 0 : selectedToken.name, " amount"] }), 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)(xhub_keyboard_1.Label, { htmlFor: keyboardId, children: (0, jsx_runtime_1.jsx)(xhub_keyboard_1.Input, { ref: amountInputRef, elementsAcceptIds: ["amount-keyboard-id"], value: inputAmount === null || inputAmount === void 0 ? void 0 : inputAmount.toString(), displayType: xhub_keyboard_1.DisplayType.Double, rightElement: (0, jsx_runtime_1.jsx)(Button_1.default.Secondary, { onClick: handleClickMaxAmount, sx: __assign({}, theme.mixins.smallButton), children: "Max" }) }) }), amountError && ((0, jsx_runtime_1.jsx)(Text_1.default, { sx: __assign({}, theme.mixins.validationError), children: amountError })), (0, jsx_runtime_1.jsxs)(material_1.Box, { sx: __assign(__assign({}, theme.mixins.row), { width: "100%", mt: theme.mixins.customMargin.m8, gap: theme.mixins.gaps.g12 }), children: [!!amount && ((0, jsx_runtime_1.jsx)(Button_1.default.Text, { onClick: handleUnset, children: "Unset" })), (0, jsx_runtime_1.jsx)(Button_1.default.Primary, { sx: { flex: 1 }, onClick: handleContinue, status: !!amountError
535
+ }, children: [(0, jsx_runtime_1.jsx)(material_1.SvgIcon, { sx: { width: 20, height: 20 }, children: amount ? SvgPath_1.IC_EDIT : SvgPath_1.IC_SET }), amount ? "Edit" : "Set", " amount"] }) }), children: (0, jsx_runtime_1.jsx)(xhub_keyboard_1.Keyboard, { id: keyboardId, onChange: handleChangeAmount, keyboardType: xhub_keyboard_1.KeyboardType.Double, value: inputAmount === null || inputAmount === void 0 ? void 0 : inputAmount.toString(), keyboardId: "amount-keyboard-id", children: (0, jsx_runtime_1.jsx)(ModalLayout_1.default, { onClose: closeAmountModal, title: (0, jsx_runtime_1.jsxs)(Text_1.default, { sx: __assign({}, theme.mixins.fieldTitle), children: [amount ? "Edit" : "Set", " ", selectedToken === null || selectedToken === void 0 ? void 0 : selectedToken.name, " amount"] }), 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)(xhub_keyboard_1.Label, { htmlFor: keyboardId, children: (0, jsx_runtime_1.jsx)(xhub_keyboard_1.Input, { ref: amountInputRef, elementsAcceptIds: ["amount-keyboard-id"], value: inputAmount === null || inputAmount === void 0 ? void 0 : inputAmount.toString(), displayType: xhub_keyboard_1.DisplayType.Double, rightElement: (0, jsx_runtime_1.jsx)(Button_1.default.Secondary, { onClick: handleClickMaxAmount, sx: __assign({}, theme.mixins.smallButton), children: "Max" }) }) }), amountError && ((0, jsx_runtime_1.jsx)(Text_1.default, { sx: __assign({}, theme.mixins.validationError), children: amountError })), (0, jsx_runtime_1.jsxs)(material_1.Box, { sx: __assign(__assign({}, theme.mixins.row), { width: "100%", mt: theme.mixins.customMargin.m8, gap: theme.mixins.gaps.g12 }), children: [!!amount && ((0, jsx_runtime_1.jsx)(Button_1.default.Text, { onClick: handleUnset, children: "Unset" })), (0, jsx_runtime_1.jsx)(Button_1.default.Primary, { sx: { flex: 1 }, onClick: handleContinue, status: !!amountError || !inputAmount
527
536
  ? Button_1.BUTTON_STATUS.DISABLED
528
537
  : Button_1.BUTTON_STATUS.ENABLED, children: "Continue" })] })] }) }) }) }))] }) }, "slide_step_".concat(ReceiveStep.SHOW_QR_CODE))] })] }) }) }) }) }) }));
529
538
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tek-wallet",
3
- "version": "0.0.740",
3
+ "version": "0.0.741",
4
4
  "description": "A custom React provider with TypeScript support",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",