@matchain/matchid-sdk-react 0.1.17 → 0.1.18
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.
- package/dist/index.css +194 -63
- package/dist/index.d.mts +41 -16
- package/dist/index.d.ts +41 -16
- package/dist/index.js +527 -208
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +513 -194
- package/dist/index.mjs.map +1 -1
- package/example/src/components/Login/index.tsx +14 -19
- package/example/src/config/index.ts +9 -0
- package/example/src/pages/User.tsx +29 -22
- package/package.json +2 -1
package/dist/index.mjs
CHANGED
|
@@ -152,7 +152,7 @@ import { jsx as jsx8, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
|
152
152
|
function EmailIcon({
|
|
153
153
|
size = 40
|
|
154
154
|
}) {
|
|
155
|
-
return /* @__PURE__ */ jsxs5("svg", { xmlns: "http://www.w3.org/2000/svg", width:
|
|
155
|
+
return /* @__PURE__ */ jsxs5("svg", { xmlns: "http://www.w3.org/2000/svg", width: size, height: size, viewBox: "0 0 40 40", fill: "none", children: [
|
|
156
156
|
/* @__PURE__ */ jsx8("rect", { width: "40", height: "40", rx: "8", fill: "url(#paint0_linear_124_10994)" }),
|
|
157
157
|
/* @__PURE__ */ jsx8(
|
|
158
158
|
"path",
|
|
@@ -357,23 +357,144 @@ function DeleteRoundIcon({ height = 21, width = 20, color = "var(--matchid-error
|
|
|
357
357
|
] });
|
|
358
358
|
}
|
|
359
359
|
|
|
360
|
+
// src/assets/icon/FacebookIcon.tsx
|
|
361
|
+
import { jsx as jsx20, jsxs as jsxs12 } from "react/jsx-runtime";
|
|
362
|
+
|
|
363
|
+
// src/assets/icon/GithubIcon.tsx
|
|
364
|
+
import { jsx as jsx21, jsxs as jsxs13 } from "react/jsx-runtime";
|
|
365
|
+
function GithubIcon({
|
|
366
|
+
size = 40
|
|
367
|
+
}) {
|
|
368
|
+
return /* @__PURE__ */ jsxs13("svg", { width: size, height: size, viewBox: "0 0 40 40", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: [
|
|
369
|
+
/* @__PURE__ */ jsx21("rect", { width: "40", height: "40", rx: "8", fill: "black" }),
|
|
370
|
+
/* @__PURE__ */ jsx21(
|
|
371
|
+
"path",
|
|
372
|
+
{
|
|
373
|
+
"fill-rule": "evenodd",
|
|
374
|
+
"clip-rule": "evenodd",
|
|
375
|
+
d: "M19.6836 7C16.434 7.00169 13.2909 8.15263 10.8165 10.247C8.34197 12.3414 6.69741 15.2427 6.17684 18.4321C5.65627 21.6215 6.29363 24.8911 7.97496 27.6561C9.6563 30.4211 12.272 32.5013 15.3542 33.5248C16.0343 33.651 16.2904 33.2295 16.2904 32.8712C16.2904 32.5128 16.2768 31.4738 16.2723 30.3379C12.4642 31.1606 11.6596 28.731 11.6596 28.731C11.0385 27.1533 10.1409 26.7386 10.1409 26.7386C8.89876 25.8957 10.2338 25.9115 10.2338 25.9115C11.6097 26.0084 12.3328 27.3156 12.3328 27.3156C13.5523 29.3958 15.5356 28.7941 16.3153 28.4425C16.4377 27.5613 16.7936 26.9618 17.1857 26.6214C14.1438 26.2789 10.9478 25.1114 10.9478 19.8961C10.929 18.5436 11.4338 17.2356 12.3577 16.2428C12.2172 15.9002 11.748 14.5164 12.4914 12.6367C12.4914 12.6367 13.6407 12.2716 16.2564 14.0318C18.5 13.4217 20.8672 13.4217 23.1108 14.0318C25.7243 12.2716 26.8712 12.6367 26.8712 12.6367C27.617 14.5119 27.1478 15.8957 27.0072 16.2428C27.9341 17.2358 28.4399 18.546 28.4194 19.9007C28.4194 25.1272 25.2166 26.2789 22.1701 26.6147C22.6597 27.0384 23.0972 27.8655 23.0972 29.1367C23.0972 30.9577 23.0814 32.4227 23.0814 32.8712C23.0814 33.234 23.3284 33.6577 24.022 33.5248C27.1047 32.5012 29.7206 30.4206 31.4019 27.6551C33.0832 24.8896 33.7202 21.6196 33.1991 18.4299C32.6779 15.2402 31.0325 12.3389 28.5572 10.2449C26.0819 8.15081 22.9381 7.00062 19.6881 7H19.6836Z",
|
|
376
|
+
fill: "white"
|
|
377
|
+
}
|
|
378
|
+
),
|
|
379
|
+
/* @__PURE__ */ jsx21(
|
|
380
|
+
"path",
|
|
381
|
+
{
|
|
382
|
+
d: "M11.1789 26.543C11.1495 26.6106 11.0407 26.6309 10.9523 26.5836C10.8639 26.5362 10.7982 26.4483 10.8299 26.3785C10.8616 26.3086 10.9682 26.2906 11.0566 26.3379C11.145 26.3852 11.2129 26.4754 11.1789 26.543Z",
|
|
383
|
+
fill: "white"
|
|
384
|
+
}
|
|
385
|
+
),
|
|
386
|
+
/* @__PURE__ */ jsx21(
|
|
387
|
+
"path",
|
|
388
|
+
{
|
|
389
|
+
d: "M11.7339 27.1582C11.687 27.1817 11.6333 27.1883 11.582 27.1768C11.5308 27.1652 11.4851 27.1364 11.4529 27.0951C11.3645 27.0004 11.3463 26.8697 11.4143 26.8111C11.4823 26.7525 11.6048 26.7796 11.6932 26.8742C11.7816 26.9689 11.8019 27.0996 11.7339 27.1582Z",
|
|
390
|
+
fill: "white"
|
|
391
|
+
}
|
|
392
|
+
),
|
|
393
|
+
/* @__PURE__ */ jsx21(
|
|
394
|
+
"path",
|
|
395
|
+
{
|
|
396
|
+
d: "M12.2738 27.9394C12.1899 27.998 12.0471 27.9394 11.9678 27.8222C11.9459 27.8012 11.9284 27.776 11.9165 27.7481C11.9046 27.7202 11.8984 27.6902 11.8984 27.6599C11.8984 27.6296 11.9046 27.5996 11.9165 27.5718C11.9284 27.5439 11.9459 27.5187 11.9678 27.4976C12.0517 27.4413 12.1945 27.4976 12.2738 27.6126C12.3531 27.7275 12.3554 27.8808 12.2738 27.9394Z",
|
|
397
|
+
fill: "white"
|
|
398
|
+
}
|
|
399
|
+
),
|
|
400
|
+
/* @__PURE__ */ jsx21(
|
|
401
|
+
"path",
|
|
402
|
+
{
|
|
403
|
+
d: "M13.0055 28.6975C12.9307 28.7809 12.7789 28.7584 12.6542 28.6457C12.5295 28.533 12.5001 28.3797 12.5749 28.2986C12.6497 28.2175 12.8015 28.24 12.9307 28.3505C13.0599 28.4609 13.0849 28.6164 13.0055 28.6975Z",
|
|
404
|
+
fill: "white"
|
|
405
|
+
}
|
|
406
|
+
),
|
|
407
|
+
/* @__PURE__ */ jsx21(
|
|
408
|
+
"path",
|
|
409
|
+
{
|
|
410
|
+
d: "M14.0325 29.1386C13.9985 29.2445 13.8444 29.2919 13.6902 29.2468C13.5361 29.2017 13.4341 29.0755 13.4636 28.9673C13.493 28.8591 13.6494 28.8095 13.8058 28.8591C13.9622 28.9087 14.062 29.0282 14.0325 29.1386Z",
|
|
411
|
+
fill: "white"
|
|
412
|
+
}
|
|
413
|
+
),
|
|
414
|
+
/* @__PURE__ */ jsx21(
|
|
415
|
+
"path",
|
|
416
|
+
{
|
|
417
|
+
d: "M15.1525 29.216C15.1525 29.3264 15.0256 29.421 14.8624 29.4233C14.6992 29.4256 14.5654 29.3354 14.5654 29.225C14.5654 29.1145 14.6924 29.0199 14.8556 29.0176C15.0188 29.0154 15.1525 29.1033 15.1525 29.216Z",
|
|
418
|
+
fill: "white"
|
|
419
|
+
}
|
|
420
|
+
),
|
|
421
|
+
/* @__PURE__ */ jsx21(
|
|
422
|
+
"path",
|
|
423
|
+
{
|
|
424
|
+
d: "M16.1947 29.0423C16.2151 29.1527 16.1018 29.2677 15.9386 29.2947C15.7754 29.3218 15.6326 29.2564 15.6122 29.1482C15.5918 29.0401 15.7096 28.9229 15.8683 28.8936C16.027 28.8643 16.1743 28.9319 16.1947 29.0423Z",
|
|
425
|
+
fill: "white"
|
|
426
|
+
}
|
|
427
|
+
)
|
|
428
|
+
] });
|
|
429
|
+
}
|
|
430
|
+
|
|
431
|
+
// src/assets/icon/DiscordIcon.tsx
|
|
432
|
+
import { jsx as jsx22, jsxs as jsxs14 } from "react/jsx-runtime";
|
|
433
|
+
function DiscordIcon({
|
|
434
|
+
size = 40
|
|
435
|
+
}) {
|
|
436
|
+
return /* @__PURE__ */ jsxs14("svg", { width: size, height: size, viewBox: "0 0 40 40", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: [
|
|
437
|
+
/* @__PURE__ */ jsx22("rect", { width: "40", height: "40", rx: "8", fill: "#5865F2" }),
|
|
438
|
+
/* @__PURE__ */ jsx22(
|
|
439
|
+
"path",
|
|
440
|
+
{
|
|
441
|
+
d: "M29.7032 10.8237C27.9186 9.97958 26.0048 9.35768 24.0039 9.00149C23.9674 8.99462 23.931 9.0118 23.9123 9.04616C23.6661 9.4974 23.3935 10.0861 23.2026 10.5488C21.0505 10.2167 18.9094 10.2167 16.8014 10.5488C16.6104 10.0758 16.3279 9.4974 16.0807 9.04616C16.0619 9.01295 16.0255 8.99577 15.9891 9.00149C13.9892 9.35654 12.0755 9.97844 10.2898 10.8237C10.2743 10.8306 10.261 10.842 10.2523 10.8569C6.62229 16.4471 5.62789 21.9 6.11571 27.2852C6.11792 27.3116 6.13226 27.3368 6.15213 27.3528C8.54708 29.1658 10.867 30.2664 13.1438 30.996C13.1803 31.0075 13.2189 30.9937 13.2421 30.9628C13.7806 30.2046 14.2607 29.4052 14.6724 28.5645C14.6967 28.5153 14.6735 28.4569 14.6238 28.4374C13.8623 28.1396 13.1372 27.7765 12.4397 27.3642C12.3845 27.331 12.3801 27.2497 12.4309 27.2107C12.5776 27.0974 12.7245 26.9794 12.8646 26.8603C12.89 26.8385 12.9253 26.8339 12.9551 26.8477C17.5375 29.0043 22.4985 29.0043 27.0268 26.8477C27.0566 26.8328 27.0919 26.8374 27.1184 26.8591C27.2586 26.9783 27.4054 27.0974 27.5533 27.2107C27.604 27.2497 27.6007 27.331 27.5455 27.3642C26.848 27.7845 26.1229 28.1396 25.3603 28.4362C25.3106 28.4557 25.2885 28.5153 25.3128 28.5645C25.7333 29.404 26.2134 30.2034 26.742 30.9616C26.7641 30.9937 26.8038 31.0075 26.8403 30.996C29.1282 30.2664 31.4481 29.1658 33.843 27.3528C33.864 27.3368 33.8772 27.3127 33.8794 27.2864C34.4633 21.0604 32.9016 15.6523 29.7396 10.858C29.7319 10.842 29.7186 10.8306 29.7032 10.8237ZM15.3567 24.0062C13.9771 24.0062 12.8403 22.7005 12.8403 21.0971C12.8403 19.4937 13.955 18.188 15.3567 18.188C16.7694 18.188 17.8951 19.5051 17.873 21.0971C17.873 22.7005 16.7583 24.0062 15.3567 24.0062ZM24.6605 24.0062C23.281 24.0062 22.1442 22.7005 22.1442 21.0971C22.1442 19.4937 23.2589 18.188 24.6605 18.188C26.0732 18.188 27.199 19.5051 27.1769 21.0971C27.1769 22.7005 26.0732 24.0062 24.6605 24.0062Z",
|
|
442
|
+
fill: "white"
|
|
443
|
+
}
|
|
444
|
+
)
|
|
445
|
+
] });
|
|
446
|
+
}
|
|
447
|
+
|
|
448
|
+
// src/assets/icon/CheckIcon.tsx
|
|
449
|
+
import { jsx as jsx23 } from "react/jsx-runtime";
|
|
450
|
+
function CheckIcon({
|
|
451
|
+
size = 20,
|
|
452
|
+
color = "black",
|
|
453
|
+
...props
|
|
454
|
+
}) {
|
|
455
|
+
return /* @__PURE__ */ jsx23("svg", { width: size, height: size, viewBox: "0 0 20 20", fill: "none", xmlns: "http://www.w3.org/2000/svg", ...props, children: /* @__PURE__ */ jsx23(
|
|
456
|
+
"path",
|
|
457
|
+
{
|
|
458
|
+
d: "M5 9.99996L8.33333 13.3333L15 6.66663",
|
|
459
|
+
stroke: color,
|
|
460
|
+
strokeWidth: "1.5",
|
|
461
|
+
strokeLinecap: "round",
|
|
462
|
+
strokeLinejoin: "round"
|
|
463
|
+
}
|
|
464
|
+
) });
|
|
465
|
+
}
|
|
466
|
+
|
|
467
|
+
// src/assets/icon/CopyIcon.tsx
|
|
468
|
+
import { jsx as jsx24 } from "react/jsx-runtime";
|
|
469
|
+
function CopyIcon({ size = 20, color = "black", ...props }) {
|
|
470
|
+
return /* @__PURE__ */ jsx24("svg", { width: size, height: size, viewBox: "0 0 20 20", fill: "none", xmlns: "http://www.w3.org/2000/svg", ...props, children: /* @__PURE__ */ jsx24(
|
|
471
|
+
"path",
|
|
472
|
+
{
|
|
473
|
+
d: "M4.16673 12.5009C3.24625 12.5009 2.50006 11.7547 2.50006 10.8342V4.16752C2.50006 3.24705 3.24625 2.50085 4.16673 2.50085H10.8334C11.7539 2.50085 12.5001 3.24705 12.5001 4.16752M9.16673 17.5009H15.8334C16.7539 17.5009 17.5001 16.7547 17.5001 15.8342V9.16752C17.5001 8.24705 16.7539 7.50086 15.8334 7.50086H9.16673C8.24625 7.50086 7.50006 8.24705 7.50006 9.16752V15.8342C7.50006 16.7547 8.24625 17.5009 9.16673 17.5009Z",
|
|
474
|
+
stroke: color,
|
|
475
|
+
strokeWidth: "1.5",
|
|
476
|
+
strokeLinecap: "round"
|
|
477
|
+
}
|
|
478
|
+
) });
|
|
479
|
+
}
|
|
480
|
+
|
|
360
481
|
// src/components/Modal/index.tsx
|
|
361
|
-
import { Fragment, jsx as
|
|
482
|
+
import { Fragment, jsx as jsx25, jsxs as jsxs15 } from "react/jsx-runtime";
|
|
362
483
|
function Modal({
|
|
363
484
|
children,
|
|
364
485
|
isOpen,
|
|
365
486
|
width = 480,
|
|
366
487
|
className = ""
|
|
367
488
|
}) {
|
|
368
|
-
return isOpen ? /* @__PURE__ */
|
|
489
|
+
return isOpen ? /* @__PURE__ */ jsx25(
|
|
369
490
|
"div",
|
|
370
491
|
{
|
|
371
492
|
className: "matchid-overlay",
|
|
372
|
-
children: /* @__PURE__ */
|
|
493
|
+
children: /* @__PURE__ */ jsx25("div", { className: `matchid-modal ${className}`, style: {
|
|
373
494
|
width
|
|
374
495
|
}, children })
|
|
375
496
|
}
|
|
376
|
-
) : /* @__PURE__ */
|
|
497
|
+
) : /* @__PURE__ */ jsx25(Fragment, {});
|
|
377
498
|
}
|
|
378
499
|
function ModalWithHeader({
|
|
379
500
|
children,
|
|
@@ -384,24 +505,24 @@ function ModalWithHeader({
|
|
|
384
505
|
showClose = true,
|
|
385
506
|
...props
|
|
386
507
|
}) {
|
|
387
|
-
return /* @__PURE__ */
|
|
388
|
-
/* @__PURE__ */
|
|
389
|
-
/* @__PURE__ */
|
|
390
|
-
onBack && /* @__PURE__ */
|
|
391
|
-
/* @__PURE__ */
|
|
508
|
+
return /* @__PURE__ */ jsxs15(Modal, { ...props, children: [
|
|
509
|
+
/* @__PURE__ */ jsxs15("div", { className: `matchid-modal-header ${showBorder ? "matchid-modal-header-border" : ""}`, children: [
|
|
510
|
+
/* @__PURE__ */ jsxs15("div", { className: "matchid-modal-header-content", children: [
|
|
511
|
+
onBack && /* @__PURE__ */ jsx25(ArrowLeftIcon, { className: "matchid-modal-header-back", onClick: onBack }),
|
|
512
|
+
/* @__PURE__ */ jsx25("span", { className: "matchid-modal-header-title", children: title })
|
|
392
513
|
] }),
|
|
393
|
-
onClose && /* @__PURE__ */
|
|
514
|
+
onClose && /* @__PURE__ */ jsx25(CloseRoundIcon, { className: "matchid-modal-header-close", onClick: onClose })
|
|
394
515
|
] }),
|
|
395
516
|
children
|
|
396
517
|
] });
|
|
397
518
|
}
|
|
398
519
|
|
|
399
520
|
// src/components/PasswordModal/index.tsx
|
|
400
|
-
import { useEffect as
|
|
521
|
+
import { useEffect as useEffect3, useMemo as useMemo2, useState as useState3 } from "react";
|
|
401
522
|
|
|
402
523
|
// src/components/Input/index.tsx
|
|
403
524
|
import { useState } from "react";
|
|
404
|
-
import { jsx as
|
|
525
|
+
import { jsx as jsx26, jsxs as jsxs16 } from "react/jsx-runtime";
|
|
405
526
|
function Input({
|
|
406
527
|
onChange,
|
|
407
528
|
type,
|
|
@@ -410,22 +531,22 @@ function Input({
|
|
|
410
531
|
...props
|
|
411
532
|
}) {
|
|
412
533
|
const [inputType, setInputType] = useState(type);
|
|
413
|
-
return /* @__PURE__ */
|
|
414
|
-
/* @__PURE__ */
|
|
415
|
-
props.value.length > 0 && /* @__PURE__ */
|
|
534
|
+
return /* @__PURE__ */ jsxs16("div", { className: `matchid-input-box ${props.value.length > 0 ? "matchid-input-has-content" : ""} ${className}`, children: [
|
|
535
|
+
/* @__PURE__ */ jsx26("input", { type: inputType, onChange, ...props, className: "matchid-input-field" }),
|
|
536
|
+
props.value.length > 0 && /* @__PURE__ */ jsx26(DeleteRoundIcon, { onClick: (e) => {
|
|
416
537
|
if (onChange) {
|
|
417
538
|
onChange({ target: { value: "" } });
|
|
418
539
|
}
|
|
419
540
|
}, className: "matchid-input-delete-icon", color: "var(--matchid-input-delete-icon-color)" }),
|
|
420
|
-
type === "password" && /* @__PURE__ */
|
|
541
|
+
type === "password" && /* @__PURE__ */ jsx26("div", { className: "matchid-input-eye-icon", onClick: () => {
|
|
421
542
|
setInputType(inputType === "password" ? "text" : "password");
|
|
422
|
-
}, children: inputType === "password" ? /* @__PURE__ */
|
|
543
|
+
}, children: inputType === "password" ? /* @__PURE__ */ jsx26(CloseEyeIcon, {}) : /* @__PURE__ */ jsx26(OpenEyeIcon, {}) }),
|
|
423
544
|
after
|
|
424
545
|
] });
|
|
425
546
|
}
|
|
426
547
|
|
|
427
548
|
// src/components/Field/index.tsx
|
|
428
|
-
import { jsx as
|
|
549
|
+
import { jsx as jsx27, jsxs as jsxs17 } from "react/jsx-runtime";
|
|
429
550
|
function Field({
|
|
430
551
|
label,
|
|
431
552
|
children,
|
|
@@ -433,18 +554,18 @@ function Field({
|
|
|
433
554
|
required,
|
|
434
555
|
className = ""
|
|
435
556
|
}) {
|
|
436
|
-
return /* @__PURE__ */
|
|
437
|
-
/* @__PURE__ */
|
|
438
|
-
required && /* @__PURE__ */
|
|
557
|
+
return /* @__PURE__ */ jsxs17("div", { className: `matchid-field-box ${className}`, children: [
|
|
558
|
+
/* @__PURE__ */ jsxs17("div", { className: "matchid-field-label", children: [
|
|
559
|
+
required && /* @__PURE__ */ jsx27("span", { className: "matchid-field-required", children: "*" }),
|
|
439
560
|
label
|
|
440
561
|
] }),
|
|
441
562
|
children,
|
|
442
|
-
error && /* @__PURE__ */
|
|
563
|
+
error && /* @__PURE__ */ jsx27("div", { className: "matchid-field-error", children: error })
|
|
443
564
|
] });
|
|
444
565
|
}
|
|
445
566
|
|
|
446
567
|
// src/components/Button/index.tsx
|
|
447
|
-
import { jsx as
|
|
568
|
+
import { jsx as jsx28 } from "react/jsx-runtime";
|
|
448
569
|
function Button({
|
|
449
570
|
size = "df",
|
|
450
571
|
disabled = false,
|
|
@@ -463,7 +584,7 @@ function Button({
|
|
|
463
584
|
onClick && onClick();
|
|
464
585
|
}
|
|
465
586
|
};
|
|
466
|
-
return /* @__PURE__ */
|
|
587
|
+
return /* @__PURE__ */ jsx28(
|
|
467
588
|
"button",
|
|
468
589
|
{
|
|
469
590
|
type,
|
|
@@ -473,7 +594,7 @@ function Button({
|
|
|
473
594
|
...style
|
|
474
595
|
},
|
|
475
596
|
onClick: onAction,
|
|
476
|
-
children: loading ? /* @__PURE__ */
|
|
597
|
+
children: loading ? /* @__PURE__ */ jsx28(LoadingIcon_default, { className: "matchid-btn-loading-icon", color: "var(--matchid-btn-loading-color)" }) : children
|
|
477
598
|
}
|
|
478
599
|
);
|
|
479
600
|
}
|
|
@@ -481,6 +602,7 @@ function Button({
|
|
|
481
602
|
// src/hooks/index.tsx
|
|
482
603
|
var hooks_exports = {};
|
|
483
604
|
__export(hooks_exports, {
|
|
605
|
+
useCopyClipboard: () => useCopyClipboard,
|
|
484
606
|
useMatchEvents: () => useMatchEvents,
|
|
485
607
|
useUserInfo: () => useUserInfo,
|
|
486
608
|
useWallet: () => useWallet
|
|
@@ -830,10 +952,10 @@ function useUserInfo() {
|
|
|
830
952
|
events && events.onLogout && events.onLogout();
|
|
831
953
|
eventManager_default.emit("onLogout");
|
|
832
954
|
};
|
|
833
|
-
const loginByMethod = (method) => {
|
|
955
|
+
const loginByMethod = async (method) => {
|
|
834
956
|
const link = `${endpoints.back}api/v1/auth/${method}?appid=${appid}&provider=${method}&redirect=${encodeURIComponent(endpoints.auth + "login/" + method)}&authorization=${(/* @__PURE__ */ new Date()).getTime()}`;
|
|
835
957
|
matchlog_default.log("link", link);
|
|
836
|
-
|
|
958
|
+
return window.open(
|
|
837
959
|
link,
|
|
838
960
|
// Replace with the actual authorization URL
|
|
839
961
|
"authWindow",
|
|
@@ -841,10 +963,42 @@ function useUserInfo() {
|
|
|
841
963
|
);
|
|
842
964
|
};
|
|
843
965
|
const loginByTwitter = () => {
|
|
844
|
-
loginByMethod("twitter");
|
|
966
|
+
return loginByMethod("twitter");
|
|
845
967
|
};
|
|
846
968
|
const loginByGoogle = () => {
|
|
847
|
-
loginByMethod("google");
|
|
969
|
+
return loginByMethod("google");
|
|
970
|
+
};
|
|
971
|
+
const loginByWallet = async () => {
|
|
972
|
+
return window.open(
|
|
973
|
+
`${endpoints.auth}login/wallet?appid=${appid}`,
|
|
974
|
+
// Replace with the actual authorization URL
|
|
975
|
+
"_blank"
|
|
976
|
+
// 'width=800,height=600'
|
|
977
|
+
);
|
|
978
|
+
};
|
|
979
|
+
const loginByTelegram = async () => {
|
|
980
|
+
return window.open(
|
|
981
|
+
`${endpoints.auth}login/telegram?appid=${appid}`,
|
|
982
|
+
// Replace with the actual authorization URL
|
|
983
|
+
"authWindow",
|
|
984
|
+
"width=800,height=600"
|
|
985
|
+
);
|
|
986
|
+
};
|
|
987
|
+
const loginMethod = async (method) => {
|
|
988
|
+
switch (method) {
|
|
989
|
+
case "wallet":
|
|
990
|
+
return await loginByWallet();
|
|
991
|
+
case "telegram":
|
|
992
|
+
return await loginByTelegram();
|
|
993
|
+
case "twitter":
|
|
994
|
+
case "google":
|
|
995
|
+
case "discord":
|
|
996
|
+
case "github":
|
|
997
|
+
case "linkedin":
|
|
998
|
+
return await loginByMethod(method);
|
|
999
|
+
default:
|
|
1000
|
+
throw new Error("unsupported method");
|
|
1001
|
+
}
|
|
848
1002
|
};
|
|
849
1003
|
const getLoginEmailCode = async (email) => {
|
|
850
1004
|
const res = await getEmailCodeApi(email);
|
|
@@ -880,22 +1034,6 @@ function useUserInfo() {
|
|
|
880
1034
|
}
|
|
881
1035
|
return false;
|
|
882
1036
|
};
|
|
883
|
-
const loginByWallet = () => {
|
|
884
|
-
const authWindow = window.open(
|
|
885
|
-
`${endpoints.auth}login/wallet?appid=${appid}`,
|
|
886
|
-
// Replace with the actual authorization URL
|
|
887
|
-
"_blank"
|
|
888
|
-
// 'width=800,height=600'
|
|
889
|
-
);
|
|
890
|
-
};
|
|
891
|
-
const loginByTelegram = () => {
|
|
892
|
-
const authWindow = window.open(
|
|
893
|
-
`${endpoints.auth}login/telegram?appid=${appid}`,
|
|
894
|
-
// Replace with the actual authorization URL
|
|
895
|
-
"authWindow",
|
|
896
|
-
"width=800,height=600"
|
|
897
|
-
);
|
|
898
|
-
};
|
|
899
1037
|
const refreshOverview = async () => {
|
|
900
1038
|
const res = await getOverviewInfoApi();
|
|
901
1039
|
if (res.data) {
|
|
@@ -930,7 +1068,30 @@ function useUserInfo() {
|
|
|
930
1068
|
}
|
|
931
1069
|
throw new Error(res.message);
|
|
932
1070
|
};
|
|
1071
|
+
const bind = async (method) => {
|
|
1072
|
+
switch (method) {
|
|
1073
|
+
case "wallet":
|
|
1074
|
+
return await bindWallet();
|
|
1075
|
+
case "telegram":
|
|
1076
|
+
return await bindTelegram();
|
|
1077
|
+
case "twitter":
|
|
1078
|
+
case "google":
|
|
1079
|
+
case "discord":
|
|
1080
|
+
case "github":
|
|
1081
|
+
case "linkedin":
|
|
1082
|
+
const link = `${endpoints.back}api/v1/auth/${method}?appid=${appid}&provider=${method}&redirect=${encodeURIComponent(endpoints.auth + "bind/" + method)}&authorization=${token.includes("Bearer ") ? token.split(" ")[1] : token}`;
|
|
1083
|
+
matchlog_default.log("link", link);
|
|
1084
|
+
return window.open(
|
|
1085
|
+
link,
|
|
1086
|
+
"authWindow",
|
|
1087
|
+
"width=800,height=600"
|
|
1088
|
+
);
|
|
1089
|
+
default:
|
|
1090
|
+
throw new Error("unsupported method");
|
|
1091
|
+
}
|
|
1092
|
+
};
|
|
933
1093
|
return {
|
|
1094
|
+
loginByMethod,
|
|
934
1095
|
loginByTelegram,
|
|
935
1096
|
loginByTwitter,
|
|
936
1097
|
loginByGoogle,
|
|
@@ -948,7 +1109,9 @@ function useUserInfo() {
|
|
|
948
1109
|
bindWallet,
|
|
949
1110
|
bindTelegram,
|
|
950
1111
|
username: overview?.username || "",
|
|
951
|
-
auth
|
|
1112
|
+
auth,
|
|
1113
|
+
login: loginMethod,
|
|
1114
|
+
bind
|
|
952
1115
|
};
|
|
953
1116
|
}
|
|
954
1117
|
|
|
@@ -1117,8 +1280,31 @@ function useWallet() {
|
|
|
1117
1280
|
};
|
|
1118
1281
|
}
|
|
1119
1282
|
|
|
1283
|
+
// src/hooks/useCopyClipboard.ts
|
|
1284
|
+
import copy from "copy-to-clipboard";
|
|
1285
|
+
import { useCallback, useEffect as useEffect2, useState as useState2 } from "react";
|
|
1286
|
+
function useCopyClipboard(timeout = 500) {
|
|
1287
|
+
const [isCopied, setIsCopied] = useState2(false);
|
|
1288
|
+
const staticCopy = useCallback((text) => {
|
|
1289
|
+
const didCopy = copy(text);
|
|
1290
|
+
setIsCopied(didCopy);
|
|
1291
|
+
}, []);
|
|
1292
|
+
useEffect2(() => {
|
|
1293
|
+
if (isCopied) {
|
|
1294
|
+
const hide = setTimeout(() => {
|
|
1295
|
+
setIsCopied(false);
|
|
1296
|
+
}, timeout);
|
|
1297
|
+
return () => {
|
|
1298
|
+
clearTimeout(hide);
|
|
1299
|
+
};
|
|
1300
|
+
}
|
|
1301
|
+
return void 0;
|
|
1302
|
+
}, [isCopied, setIsCopied, timeout]);
|
|
1303
|
+
return [isCopied, staticCopy];
|
|
1304
|
+
}
|
|
1305
|
+
|
|
1120
1306
|
// src/components/PasswordModal/index.tsx
|
|
1121
|
-
import { jsx as
|
|
1307
|
+
import { jsx as jsx29, jsxs as jsxs18 } from "react/jsx-runtime";
|
|
1122
1308
|
function PasswordModal({
|
|
1123
1309
|
title,
|
|
1124
1310
|
isOpen,
|
|
@@ -1127,9 +1313,9 @@ function PasswordModal({
|
|
|
1127
1313
|
}) {
|
|
1128
1314
|
const { refreshOverview } = useUserInfo();
|
|
1129
1315
|
const { isLogin, did } = useUserInfo();
|
|
1130
|
-
const [password, setPassword] =
|
|
1131
|
-
const [rePassword, setRePassword] =
|
|
1132
|
-
const [error, setError] =
|
|
1316
|
+
const [password, setPassword] = useState3("");
|
|
1317
|
+
const [rePassword, setRePassword] = useState3("");
|
|
1318
|
+
const [error, setError] = useState3("");
|
|
1133
1319
|
const { generateWallet } = useWallet();
|
|
1134
1320
|
const passwordError = useMemo2(() => {
|
|
1135
1321
|
if (password.length < 6) return "Password must be at least 6 characters";
|
|
@@ -1141,13 +1327,13 @@ function PasswordModal({
|
|
|
1141
1327
|
}
|
|
1142
1328
|
return "";
|
|
1143
1329
|
}, [rePassword, password]);
|
|
1144
|
-
|
|
1330
|
+
useEffect3(() => {
|
|
1145
1331
|
if (isOpen) {
|
|
1146
1332
|
setPassword("");
|
|
1147
1333
|
setRePassword("");
|
|
1148
1334
|
}
|
|
1149
1335
|
}, [isOpen]);
|
|
1150
|
-
const [isSubmitting, setIsSubmitting] =
|
|
1336
|
+
const [isSubmitting, setIsSubmitting] = useState3(false);
|
|
1151
1337
|
const onContinue = async () => {
|
|
1152
1338
|
if (isSubmitting) return;
|
|
1153
1339
|
try {
|
|
@@ -1164,13 +1350,13 @@ function PasswordModal({
|
|
|
1164
1350
|
setIsSubmitting(false);
|
|
1165
1351
|
}
|
|
1166
1352
|
};
|
|
1167
|
-
return /* @__PURE__ */
|
|
1168
|
-
/* @__PURE__ */
|
|
1169
|
-
/* @__PURE__ */
|
|
1170
|
-
/* @__PURE__ */
|
|
1353
|
+
return /* @__PURE__ */ jsx29(ModalWithHeader, { isOpen: isOpen && isLogin, ...props, title: title || "Set Password", children: /* @__PURE__ */ jsxs18("div", { className: "matchid-password-box", children: [
|
|
1354
|
+
/* @__PURE__ */ jsxs18("div", { className: "matchid-password-header", children: [
|
|
1355
|
+
/* @__PURE__ */ jsx29("div", { className: "matchid-password-header-icon", children: /* @__PURE__ */ jsx29(PasswordRoundIcon, {}) }),
|
|
1356
|
+
/* @__PURE__ */ jsx29("div", { className: "matchid-password-header-content", children: "Please set the wallet password that will be used to recover the wallet" })
|
|
1171
1357
|
] }),
|
|
1172
|
-
/* @__PURE__ */
|
|
1173
|
-
/* @__PURE__ */
|
|
1358
|
+
/* @__PURE__ */ jsxs18("div", { className: "matchid-password-content", children: [
|
|
1359
|
+
/* @__PURE__ */ jsx29(Field, { label: "Password", error: password.length > 0 && passwordError, children: /* @__PURE__ */ jsx29(
|
|
1174
1360
|
Input,
|
|
1175
1361
|
{
|
|
1176
1362
|
placeholder: "Enter the Password",
|
|
@@ -1180,7 +1366,7 @@ function PasswordModal({
|
|
|
1180
1366
|
value: password
|
|
1181
1367
|
}
|
|
1182
1368
|
) }),
|
|
1183
|
-
/* @__PURE__ */
|
|
1369
|
+
/* @__PURE__ */ jsx29(Field, { label: "Re Password", error: rePassword.length > 0 ? rePasswordError || error : error, children: /* @__PURE__ */ jsx29(
|
|
1184
1370
|
Input,
|
|
1185
1371
|
{
|
|
1186
1372
|
placeholder: "Re Enter the Password",
|
|
@@ -1191,7 +1377,7 @@ function PasswordModal({
|
|
|
1191
1377
|
}
|
|
1192
1378
|
) })
|
|
1193
1379
|
] }),
|
|
1194
|
-
/* @__PURE__ */
|
|
1380
|
+
/* @__PURE__ */ jsx29(
|
|
1195
1381
|
Button,
|
|
1196
1382
|
{
|
|
1197
1383
|
disabled: password.length == 0 || !!passwordError || !!rePasswordError,
|
|
@@ -1207,8 +1393,8 @@ function PasswordModal({
|
|
|
1207
1393
|
}
|
|
1208
1394
|
|
|
1209
1395
|
// src/components/RecoveryModal/index.tsx
|
|
1210
|
-
import { useEffect as
|
|
1211
|
-
import { jsx as
|
|
1396
|
+
import { useEffect as useEffect4, useMemo as useMemo3, useState as useState4 } from "react";
|
|
1397
|
+
import { jsx as jsx30, jsxs as jsxs19 } from "react/jsx-runtime";
|
|
1212
1398
|
function RecoveryModal({
|
|
1213
1399
|
title,
|
|
1214
1400
|
isOpen,
|
|
@@ -1217,19 +1403,19 @@ function RecoveryModal({
|
|
|
1217
1403
|
}) {
|
|
1218
1404
|
const { refreshOverview } = useUserInfo();
|
|
1219
1405
|
const { isLogin } = useUserInfo();
|
|
1220
|
-
const [password, setPassword] =
|
|
1406
|
+
const [password, setPassword] = useState4("");
|
|
1221
1407
|
const { recoveryWallet } = useWallet();
|
|
1222
|
-
const [error, setError] =
|
|
1408
|
+
const [error, setError] = useState4("");
|
|
1223
1409
|
const passwordError = useMemo3(() => {
|
|
1224
1410
|
if (password.length < 6) return "Password must be at least 6 characters";
|
|
1225
1411
|
return "";
|
|
1226
1412
|
}, [password]);
|
|
1227
|
-
|
|
1413
|
+
useEffect4(() => {
|
|
1228
1414
|
if (isOpen) {
|
|
1229
1415
|
setPassword("");
|
|
1230
1416
|
}
|
|
1231
1417
|
}, [isOpen]);
|
|
1232
|
-
const [isSubmitting, setIsSubmitting] =
|
|
1418
|
+
const [isSubmitting, setIsSubmitting] = useState4(false);
|
|
1233
1419
|
const onContinue = async () => {
|
|
1234
1420
|
if (isSubmitting) return;
|
|
1235
1421
|
try {
|
|
@@ -1244,12 +1430,12 @@ function RecoveryModal({
|
|
|
1244
1430
|
setIsSubmitting(false);
|
|
1245
1431
|
}
|
|
1246
1432
|
};
|
|
1247
|
-
return /* @__PURE__ */
|
|
1248
|
-
/* @__PURE__ */
|
|
1249
|
-
/* @__PURE__ */
|
|
1250
|
-
/* @__PURE__ */
|
|
1433
|
+
return /* @__PURE__ */ jsx30(ModalWithHeader, { isOpen: isOpen && isLogin, ...props, title: title || "Recover Wallet", children: /* @__PURE__ */ jsxs19("div", { className: "matchid-password-box", children: [
|
|
1434
|
+
/* @__PURE__ */ jsxs19("div", { className: "matchid-password-header", children: [
|
|
1435
|
+
/* @__PURE__ */ jsx30("div", { className: "matchid-password-header-icon", children: /* @__PURE__ */ jsx30(PasswordRoundIcon, {}) }),
|
|
1436
|
+
/* @__PURE__ */ jsx30("div", { className: "matchid-password-header-content", children: "Please enter your password to recover your wallet" })
|
|
1251
1437
|
] }),
|
|
1252
|
-
/* @__PURE__ */
|
|
1438
|
+
/* @__PURE__ */ jsx30("div", { className: "matchid-password-content", children: /* @__PURE__ */ jsx30(Field, { label: "Password", error: password.length > 0 ? passwordError || error : error, children: /* @__PURE__ */ jsx30(
|
|
1253
1439
|
Input,
|
|
1254
1440
|
{
|
|
1255
1441
|
placeholder: "Enter the Password",
|
|
@@ -1259,7 +1445,7 @@ function RecoveryModal({
|
|
|
1259
1445
|
value: password
|
|
1260
1446
|
}
|
|
1261
1447
|
) }) }),
|
|
1262
|
-
/* @__PURE__ */
|
|
1448
|
+
/* @__PURE__ */ jsx30(
|
|
1263
1449
|
Button,
|
|
1264
1450
|
{
|
|
1265
1451
|
disabled: password.length == 0 || !!passwordError,
|
|
@@ -1275,13 +1461,13 @@ function RecoveryModal({
|
|
|
1275
1461
|
}
|
|
1276
1462
|
|
|
1277
1463
|
// src/context/BusinessProvider.tsx
|
|
1278
|
-
import { Fragment as Fragment2, jsx as
|
|
1464
|
+
import { Fragment as Fragment2, jsx as jsx31, jsxs as jsxs20 } from "react/jsx-runtime";
|
|
1279
1465
|
function BusinessProvider({ children }) {
|
|
1280
1466
|
const { overview, token } = useUserInfo();
|
|
1281
1467
|
const { recoveryModal } = useStore_default();
|
|
1282
|
-
return /* @__PURE__ */
|
|
1283
|
-
/* @__PURE__ */
|
|
1284
|
-
/* @__PURE__ */
|
|
1468
|
+
return /* @__PURE__ */ jsxs20(Fragment2, { children: [
|
|
1469
|
+
/* @__PURE__ */ jsx31(PasswordModal, { isOpen: !!token && !!overview && !overview.address && !!overview.did, showClose: false }),
|
|
1470
|
+
/* @__PURE__ */ jsx31(
|
|
1285
1471
|
RecoveryModal,
|
|
1286
1472
|
{
|
|
1287
1473
|
isOpen: !!token && !!overview && !!overview.address && recoveryModal.open,
|
|
@@ -1294,17 +1480,17 @@ function BusinessProvider({ children }) {
|
|
|
1294
1480
|
}
|
|
1295
1481
|
|
|
1296
1482
|
// src/context/index.tsx
|
|
1297
|
-
import { jsx as
|
|
1483
|
+
import { jsx as jsx32 } from "react/jsx-runtime";
|
|
1298
1484
|
var Providers = ({ children }) => {
|
|
1299
1485
|
return (
|
|
1300
1486
|
// <MpcWalletProvider>
|
|
1301
|
-
/* @__PURE__ */
|
|
1487
|
+
/* @__PURE__ */ jsx32(BusinessProvider, { children })
|
|
1302
1488
|
);
|
|
1303
1489
|
};
|
|
1304
1490
|
var context_default = Providers;
|
|
1305
1491
|
|
|
1306
1492
|
// src/hooks/useWalletInit.ts
|
|
1307
|
-
import { useEffect as
|
|
1493
|
+
import { useEffect as useEffect5, useState as useState5 } from "react";
|
|
1308
1494
|
var AppClientId2 = "react-sdk-" + getVersion();
|
|
1309
1495
|
function useWalletInit({
|
|
1310
1496
|
refreshOverview
|
|
@@ -1313,10 +1499,10 @@ function useWalletInit({
|
|
|
1313
1499
|
const getWalletIframe = () => {
|
|
1314
1500
|
return document.getElementById("match-wallet");
|
|
1315
1501
|
};
|
|
1316
|
-
const [walletInited, setWalletInited] =
|
|
1502
|
+
const [walletInited, setWalletInited] = useState5(false);
|
|
1317
1503
|
const { appid, token, overview } = useLocalStore_default();
|
|
1318
1504
|
const { initWallet, generateWallet } = useWallet();
|
|
1319
|
-
|
|
1505
|
+
useEffect5(() => {
|
|
1320
1506
|
if (endpoints.auth) {
|
|
1321
1507
|
if (!window.matchWalletMessageIdMap) {
|
|
1322
1508
|
window.matchWalletMessageIdMap = {};
|
|
@@ -1374,7 +1560,7 @@ function useWalletInit({
|
|
|
1374
1560
|
}
|
|
1375
1561
|
}
|
|
1376
1562
|
}, [endpoints.auth]);
|
|
1377
|
-
|
|
1563
|
+
useEffect5(() => {
|
|
1378
1564
|
const messageHandle = async (e) => {
|
|
1379
1565
|
if (e.origin !== endpoints.auth.substring(0, endpoints.auth.length - 1)) {
|
|
1380
1566
|
return;
|
|
@@ -1407,7 +1593,7 @@ function useWalletInit({
|
|
|
1407
1593
|
window.removeEventListener("message", messageHandle);
|
|
1408
1594
|
};
|
|
1409
1595
|
}, []);
|
|
1410
|
-
|
|
1596
|
+
useEffect5(() => {
|
|
1411
1597
|
if (token && overview && overview.did && walletInited) {
|
|
1412
1598
|
const did = overview.did.split(":")[2];
|
|
1413
1599
|
const newUserInit = async () => {
|
|
@@ -1438,7 +1624,7 @@ function useWalletInit({
|
|
|
1438
1624
|
}
|
|
1439
1625
|
|
|
1440
1626
|
// src/hooks/useInit.tsx
|
|
1441
|
-
import { useEffect as
|
|
1627
|
+
import { useEffect as useEffect6, useRef } from "react";
|
|
1442
1628
|
function useInit({
|
|
1443
1629
|
theme,
|
|
1444
1630
|
appid,
|
|
@@ -1458,16 +1644,16 @@ function useInit({
|
|
|
1458
1644
|
const searchParams = new URLSearchParams(window.location.search);
|
|
1459
1645
|
const matchToken = searchParams.get("matchToken");
|
|
1460
1646
|
const realEndpoints = endpoints || env_default.endpoints;
|
|
1461
|
-
|
|
1647
|
+
useEffect6(() => {
|
|
1462
1648
|
setTheme(theme);
|
|
1463
1649
|
}, [theme]);
|
|
1464
|
-
|
|
1650
|
+
useEffect6(() => {
|
|
1465
1651
|
setAppid(appid);
|
|
1466
1652
|
}, [appid]);
|
|
1467
|
-
|
|
1653
|
+
useEffect6(() => {
|
|
1468
1654
|
setEndpoints(realEndpoints);
|
|
1469
1655
|
}, [realEndpoints]);
|
|
1470
|
-
|
|
1656
|
+
useEffect6(() => {
|
|
1471
1657
|
if (matchToken) {
|
|
1472
1658
|
const tokenData = JSON.parse(atob(matchToken));
|
|
1473
1659
|
if (tokenData && tokenData.mid && tokenData.token) {
|
|
@@ -1478,7 +1664,7 @@ function useInit({
|
|
|
1478
1664
|
}
|
|
1479
1665
|
}
|
|
1480
1666
|
}, [matchToken]);
|
|
1481
|
-
|
|
1667
|
+
useEffect6(() => {
|
|
1482
1668
|
const onLoginMessage = (event) => {
|
|
1483
1669
|
const res = event.data;
|
|
1484
1670
|
if (res.event === "login" && res.data && (res.data.token || res.data.token_type && res.data.access_token)) {
|
|
@@ -1514,7 +1700,7 @@ function useInit({
|
|
|
1514
1700
|
overviewLoadingRef.current = false;
|
|
1515
1701
|
}
|
|
1516
1702
|
};
|
|
1517
|
-
|
|
1703
|
+
useEffect6(() => {
|
|
1518
1704
|
if (token) {
|
|
1519
1705
|
loadOverview();
|
|
1520
1706
|
}
|
|
@@ -1545,7 +1731,7 @@ function useInit({
|
|
|
1545
1731
|
|
|
1546
1732
|
// src/MatchContext.tsx
|
|
1547
1733
|
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
|
|
1548
|
-
import { jsx as
|
|
1734
|
+
import { jsx as jsx33 } from "react/jsx-runtime";
|
|
1549
1735
|
var queryClient = new QueryClient();
|
|
1550
1736
|
var MatchContext = createContext(void 0);
|
|
1551
1737
|
var MatchProvider = ({ children, appid, events, theme = "light", endpoints }) => {
|
|
@@ -1558,7 +1744,7 @@ var MatchProvider = ({ children, appid, events, theme = "light", endpoints }) =>
|
|
|
1558
1744
|
useWalletInit({
|
|
1559
1745
|
refreshOverview: loadOverview
|
|
1560
1746
|
});
|
|
1561
|
-
return /* @__PURE__ */
|
|
1747
|
+
return /* @__PURE__ */ jsx33(QueryClientProvider, { client: queryClient, children: /* @__PURE__ */ jsx33(
|
|
1562
1748
|
MatchContext.Provider,
|
|
1563
1749
|
{
|
|
1564
1750
|
value: {
|
|
@@ -1568,7 +1754,7 @@ var MatchProvider = ({ children, appid, events, theme = "light", endpoints }) =>
|
|
|
1568
1754
|
login,
|
|
1569
1755
|
theme
|
|
1570
1756
|
},
|
|
1571
|
-
children: /* @__PURE__ */
|
|
1757
|
+
children: /* @__PURE__ */ jsx33(context_default, { children })
|
|
1572
1758
|
}
|
|
1573
1759
|
) });
|
|
1574
1760
|
};
|
|
@@ -1594,18 +1780,19 @@ __export(components_exports, {
|
|
|
1594
1780
|
Modal: () => Modal,
|
|
1595
1781
|
ModalWithHeader: () => ModalWithHeader,
|
|
1596
1782
|
PasswordModal: () => PasswordModal,
|
|
1783
|
+
Popover: () => Popover,
|
|
1597
1784
|
UsernameModal: () => UsernameModal
|
|
1598
1785
|
});
|
|
1599
1786
|
|
|
1600
1787
|
// src/components/EmailModal/index.tsx
|
|
1601
|
-
import { useEffect as
|
|
1788
|
+
import { useEffect as useEffect10, useState as useState9 } from "react";
|
|
1602
1789
|
|
|
1603
1790
|
// src/components/EmailModal/StepEmail.tsx
|
|
1604
|
-
import { useEffect as
|
|
1605
|
-
import { jsx as
|
|
1791
|
+
import { useEffect as useEffect8, useMemo as useMemo4, useState as useState7 } from "react";
|
|
1792
|
+
import { jsx as jsx34, jsxs as jsxs21 } from "react/jsx-runtime";
|
|
1606
1793
|
function StepEmail(props) {
|
|
1607
|
-
const [emailVal, setEmailVal] =
|
|
1608
|
-
|
|
1794
|
+
const [emailVal, setEmailVal] = useState7("");
|
|
1795
|
+
useEffect8(() => {
|
|
1609
1796
|
if (props.email) {
|
|
1610
1797
|
setEmailVal(props.email);
|
|
1611
1798
|
}
|
|
@@ -1616,8 +1803,8 @@ function StepEmail(props) {
|
|
|
1616
1803
|
const onContinue = async () => {
|
|
1617
1804
|
props.onContinue(emailVal);
|
|
1618
1805
|
};
|
|
1619
|
-
return /* @__PURE__ */
|
|
1620
|
-
/* @__PURE__ */
|
|
1806
|
+
return /* @__PURE__ */ jsxs21("div", { className: "matchid-email-email-box", children: [
|
|
1807
|
+
/* @__PURE__ */ jsx34(Field, { label: "Email Address", children: /* @__PURE__ */ jsx34(
|
|
1621
1808
|
Input,
|
|
1622
1809
|
{
|
|
1623
1810
|
placeholder: "Enter Your Email Address",
|
|
@@ -1625,29 +1812,29 @@ function StepEmail(props) {
|
|
|
1625
1812
|
value: emailVal
|
|
1626
1813
|
}
|
|
1627
1814
|
) }),
|
|
1628
|
-
/* @__PURE__ */
|
|
1815
|
+
/* @__PURE__ */ jsx34(Button, { disabled: !canContinue, style: {
|
|
1629
1816
|
marginTop: "64px"
|
|
1630
1817
|
}, onClick: onContinue, size: "lg", block: true, highlight: true, children: "Continue" })
|
|
1631
1818
|
] });
|
|
1632
1819
|
}
|
|
1633
1820
|
|
|
1634
1821
|
// src/components/EmailModal/StepVerify.tsx
|
|
1635
|
-
import { useEffect as
|
|
1822
|
+
import { useEffect as useEffect9, useMemo as useMemo5, useRef as useRef3, useState as useState8 } from "react";
|
|
1636
1823
|
|
|
1637
1824
|
// src/config/index.tsx
|
|
1638
1825
|
var EMAIL_INTERVAL = 60;
|
|
1639
1826
|
var EMAIL_CODE_LENGTH = 6;
|
|
1640
1827
|
|
|
1641
1828
|
// src/components/EmailModal/StepVerify.tsx
|
|
1642
|
-
import { jsx as
|
|
1829
|
+
import { jsx as jsx35, jsxs as jsxs22 } from "react/jsx-runtime";
|
|
1643
1830
|
function StepVerify(props) {
|
|
1644
1831
|
const { getLoginEmailCode, loginByEmail } = useUserInfo();
|
|
1645
|
-
const [error, setError] =
|
|
1646
|
-
const [code, setCode] =
|
|
1647
|
-
const [sending, setSending] =
|
|
1648
|
-
const [submitting, setSubmitting] =
|
|
1832
|
+
const [error, setError] = useState8("");
|
|
1833
|
+
const [code, setCode] = useState8("");
|
|
1834
|
+
const [sending, setSending] = useState8(false);
|
|
1835
|
+
const [submitting, setSubmitting] = useState8(false);
|
|
1649
1836
|
const sendTimeRef = useRef3(0);
|
|
1650
|
-
const [sendBtnText, setSendBtnText] =
|
|
1837
|
+
const [sendBtnText, setSendBtnText] = useState8("Send");
|
|
1651
1838
|
const intervalTime = EMAIL_INTERVAL;
|
|
1652
1839
|
const codeLength = EMAIL_CODE_LENGTH;
|
|
1653
1840
|
const intervalRef = useRef3(null);
|
|
@@ -1676,7 +1863,7 @@ function StepVerify(props) {
|
|
|
1676
1863
|
setSending(false);
|
|
1677
1864
|
}
|
|
1678
1865
|
};
|
|
1679
|
-
|
|
1866
|
+
useEffect9(() => {
|
|
1680
1867
|
onSend();
|
|
1681
1868
|
return () => {
|
|
1682
1869
|
if (intervalRef.current) {
|
|
@@ -1708,22 +1895,22 @@ function StepVerify(props) {
|
|
|
1708
1895
|
setSubmitting(false);
|
|
1709
1896
|
}
|
|
1710
1897
|
};
|
|
1711
|
-
return /* @__PURE__ */
|
|
1712
|
-
/* @__PURE__ */
|
|
1713
|
-
/* @__PURE__ */
|
|
1714
|
-
/* @__PURE__ */
|
|
1715
|
-
/* @__PURE__ */
|
|
1716
|
-
/* @__PURE__ */
|
|
1898
|
+
return /* @__PURE__ */ jsxs22("div", { className: "matchid-email-verify-box", children: [
|
|
1899
|
+
/* @__PURE__ */ jsxs22("div", { className: "matchid-email-verify-header", children: [
|
|
1900
|
+
/* @__PURE__ */ jsx35("div", { className: "matchid-email-verify-header-icon", children: /* @__PURE__ */ jsx35(EmailLineIcon, {}) }),
|
|
1901
|
+
/* @__PURE__ */ jsxs22("div", { className: "matchid-email-verify-header-content", children: [
|
|
1902
|
+
/* @__PURE__ */ jsx35("div", { className: "matchid-email-verify-header-value", children: props.email }),
|
|
1903
|
+
/* @__PURE__ */ jsx35("div", { className: "matchid-email-verify-header-tips", children: "We have sent a verification code to your email" })
|
|
1717
1904
|
] })
|
|
1718
1905
|
] }),
|
|
1719
|
-
/* @__PURE__ */
|
|
1906
|
+
/* @__PURE__ */ jsx35(Field, { label: "Verification Code", error, children: /* @__PURE__ */ jsx35(
|
|
1720
1907
|
Input,
|
|
1721
1908
|
{
|
|
1722
1909
|
placeholder: "Enter the code",
|
|
1723
1910
|
maxLength: codeLength,
|
|
1724
1911
|
onChange: (e) => setCode(e.target.value),
|
|
1725
1912
|
value: code,
|
|
1726
|
-
after: /* @__PURE__ */
|
|
1913
|
+
after: /* @__PURE__ */ jsx35(
|
|
1727
1914
|
Button,
|
|
1728
1915
|
{
|
|
1729
1916
|
highlight: true,
|
|
@@ -1742,12 +1929,12 @@ function StepVerify(props) {
|
|
|
1742
1929
|
)
|
|
1743
1930
|
}
|
|
1744
1931
|
) }),
|
|
1745
|
-
/* @__PURE__ */
|
|
1932
|
+
/* @__PURE__ */ jsx35(Button, { disabled: !canContinue, highlight: true, block: true, size: "lg", onClick: onContinue, children: "Continue" })
|
|
1746
1933
|
] });
|
|
1747
1934
|
}
|
|
1748
1935
|
|
|
1749
1936
|
// src/components/EmailModal/index.tsx
|
|
1750
|
-
import { jsx as
|
|
1937
|
+
import { jsx as jsx36 } from "react/jsx-runtime";
|
|
1751
1938
|
function EmailModal({
|
|
1752
1939
|
isOpen = false,
|
|
1753
1940
|
width = 480,
|
|
@@ -1755,15 +1942,15 @@ function EmailModal({
|
|
|
1755
1942
|
onBack,
|
|
1756
1943
|
onLogin
|
|
1757
1944
|
}) {
|
|
1758
|
-
const [step, setStep] =
|
|
1759
|
-
const [emailVal, setEmailVal] =
|
|
1760
|
-
|
|
1945
|
+
const [step, setStep] = useState9("input");
|
|
1946
|
+
const [emailVal, setEmailVal] = useState9("");
|
|
1947
|
+
useEffect10(() => {
|
|
1761
1948
|
if (!isOpen) {
|
|
1762
1949
|
setStep("input");
|
|
1763
1950
|
setEmailVal("");
|
|
1764
1951
|
}
|
|
1765
1952
|
}, [isOpen]);
|
|
1766
|
-
return /* @__PURE__ */
|
|
1953
|
+
return /* @__PURE__ */ jsx36(
|
|
1767
1954
|
ModalWithHeader,
|
|
1768
1955
|
{
|
|
1769
1956
|
isOpen,
|
|
@@ -1771,29 +1958,60 @@ function EmailModal({
|
|
|
1771
1958
|
onClose,
|
|
1772
1959
|
title: "Email",
|
|
1773
1960
|
onBack: step == "verify" ? () => setStep("input") : onBack,
|
|
1774
|
-
children: step === "input" ? /* @__PURE__ */
|
|
1961
|
+
children: step === "input" ? /* @__PURE__ */ jsx36(StepEmail, { email: emailVal, onContinue: (email) => {
|
|
1775
1962
|
setEmailVal(email);
|
|
1776
1963
|
setStep("verify");
|
|
1777
|
-
} }) : /* @__PURE__ */
|
|
1964
|
+
} }) : /* @__PURE__ */ jsx36(StepVerify, { email: emailVal, onSuccess: onLogin })
|
|
1965
|
+
}
|
|
1966
|
+
);
|
|
1967
|
+
}
|
|
1968
|
+
|
|
1969
|
+
// src/components/Popover/index.tsx
|
|
1970
|
+
import { useState as useState10 } from "react";
|
|
1971
|
+
import { jsx as jsx37, jsxs as jsxs23 } from "react/jsx-runtime";
|
|
1972
|
+
function Popover({
|
|
1973
|
+
children,
|
|
1974
|
+
content,
|
|
1975
|
+
position = "right",
|
|
1976
|
+
type = "hover",
|
|
1977
|
+
className = "",
|
|
1978
|
+
gap = "20px"
|
|
1979
|
+
}) {
|
|
1980
|
+
const [active, setActive] = useState10(false);
|
|
1981
|
+
return /* @__PURE__ */ jsxs23(
|
|
1982
|
+
"div",
|
|
1983
|
+
{
|
|
1984
|
+
onClick: () => {
|
|
1985
|
+
if (type == "click") {
|
|
1986
|
+
setActive(!active);
|
|
1987
|
+
}
|
|
1988
|
+
},
|
|
1989
|
+
className: `matchid-popover-box matchid-popover-${position} matchid-popover-${type} ${className} ${type == "click" && active ? "matchid-popover-click-active" : ""}`,
|
|
1990
|
+
children: [
|
|
1991
|
+
children,
|
|
1992
|
+
/* @__PURE__ */ jsx37("div", { style: {
|
|
1993
|
+
paddingTop: gap
|
|
1994
|
+
}, children: /* @__PURE__ */ jsx37("div", { className: `matchid-popover-content`, children: content }) })
|
|
1995
|
+
]
|
|
1778
1996
|
}
|
|
1779
1997
|
);
|
|
1780
1998
|
}
|
|
1781
1999
|
|
|
1782
2000
|
// src/components/LoginBox/index.tsx
|
|
1783
|
-
import { useMemo as useMemo6, useState as
|
|
1784
|
-
import { Fragment as Fragment3, jsx as
|
|
2001
|
+
import { useMemo as useMemo6, useState as useState11 } from "react";
|
|
2002
|
+
import { Fragment as Fragment3, jsx as jsx38, jsxs as jsxs24 } from "react/jsx-runtime";
|
|
1785
2003
|
function LoginBox({
|
|
1786
2004
|
methods,
|
|
1787
2005
|
inModal = false
|
|
1788
2006
|
}) {
|
|
1789
|
-
const [emailOpen, setEmailOpen] =
|
|
1790
|
-
const {
|
|
2007
|
+
const [emailOpen, setEmailOpen] = useState11(false);
|
|
2008
|
+
const { login } = useUserInfo();
|
|
1791
2009
|
const defaultMethods = [
|
|
1792
2010
|
"wallet",
|
|
1793
2011
|
"google",
|
|
1794
2012
|
"email",
|
|
1795
2013
|
"telegram",
|
|
1796
|
-
"
|
|
2014
|
+
"twitter"
|
|
1797
2015
|
];
|
|
1798
2016
|
const methodList = useMemo6(() => {
|
|
1799
2017
|
return methods || defaultMethods;
|
|
@@ -1803,46 +2021,56 @@ function LoginBox({
|
|
|
1803
2021
|
name,
|
|
1804
2022
|
onClick
|
|
1805
2023
|
}) => {
|
|
1806
|
-
return /* @__PURE__ */
|
|
1807
|
-
/* @__PURE__ */
|
|
1808
|
-
/* @__PURE__ */
|
|
1809
|
-
/* @__PURE__ */
|
|
2024
|
+
return /* @__PURE__ */ jsxs24("div", { className: "matchid-login-method", onClick, children: [
|
|
2025
|
+
/* @__PURE__ */ jsxs24("div", { className: "matchid-login-method-content", children: [
|
|
2026
|
+
/* @__PURE__ */ jsx38("div", { className: "matchid-login-method-icon", children: icon }),
|
|
2027
|
+
/* @__PURE__ */ jsx38("span", { className: "matchid-login-method-name", children: name })
|
|
1810
2028
|
] }),
|
|
1811
|
-
/* @__PURE__ */
|
|
2029
|
+
/* @__PURE__ */ jsx38(ArrowRightIcon, { className: "matchid-login-method-arrow", size: 20, color: "var(--matchid-arrow-color)" })
|
|
1812
2030
|
] });
|
|
1813
2031
|
};
|
|
1814
2032
|
const methodMap = {
|
|
1815
2033
|
wallet: {
|
|
1816
|
-
icon: /* @__PURE__ */
|
|
2034
|
+
icon: /* @__PURE__ */ jsx38(WalletIcon, {}),
|
|
1817
2035
|
name: "Wallet",
|
|
1818
|
-
onClick:
|
|
2036
|
+
onClick: () => login("wallet")
|
|
1819
2037
|
},
|
|
1820
2038
|
email: {
|
|
1821
|
-
icon: /* @__PURE__ */
|
|
2039
|
+
icon: /* @__PURE__ */ jsx38(EmailIcon, {}),
|
|
1822
2040
|
name: "Email",
|
|
1823
2041
|
onClick: () => {
|
|
1824
2042
|
setEmailOpen(true);
|
|
1825
2043
|
}
|
|
1826
2044
|
},
|
|
1827
2045
|
google: {
|
|
1828
|
-
icon: /* @__PURE__ */
|
|
2046
|
+
icon: /* @__PURE__ */ jsx38(GoogleIcon, {}),
|
|
1829
2047
|
name: "Google",
|
|
1830
|
-
onClick:
|
|
2048
|
+
onClick: () => login("google")
|
|
1831
2049
|
},
|
|
1832
|
-
|
|
1833
|
-
icon: /* @__PURE__ */
|
|
2050
|
+
twitter: {
|
|
2051
|
+
icon: /* @__PURE__ */ jsx38(XIcon, {}),
|
|
1834
2052
|
name: "X",
|
|
1835
|
-
onClick:
|
|
2053
|
+
onClick: () => login("twitter")
|
|
1836
2054
|
},
|
|
1837
2055
|
telegram: {
|
|
1838
|
-
icon: /* @__PURE__ */
|
|
2056
|
+
icon: /* @__PURE__ */ jsx38(TelegramIcon, {}),
|
|
1839
2057
|
name: "Telegram",
|
|
1840
|
-
onClick:
|
|
2058
|
+
onClick: () => login("telegram")
|
|
2059
|
+
},
|
|
2060
|
+
github: {
|
|
2061
|
+
icon: /* @__PURE__ */ jsx38(GithubIcon, {}),
|
|
2062
|
+
name: "Github",
|
|
2063
|
+
onClick: () => login("github")
|
|
2064
|
+
},
|
|
2065
|
+
discord: {
|
|
2066
|
+
icon: /* @__PURE__ */ jsx38(DiscordIcon, {}),
|
|
2067
|
+
name: "Discord",
|
|
2068
|
+
onClick: () => login("discord")
|
|
1841
2069
|
}
|
|
1842
2070
|
};
|
|
1843
|
-
return /* @__PURE__ */
|
|
1844
|
-
(!inModal || !emailOpen) && /* @__PURE__ */
|
|
1845
|
-
return /* @__PURE__ */
|
|
2071
|
+
return /* @__PURE__ */ jsxs24(Fragment3, { children: [
|
|
2072
|
+
(!inModal || !emailOpen) && /* @__PURE__ */ jsx38("div", { className: "matchid-login-box", children: methodList.map((m) => {
|
|
2073
|
+
return /* @__PURE__ */ jsx38(
|
|
1846
2074
|
LoginItem,
|
|
1847
2075
|
{
|
|
1848
2076
|
icon: methodMap[m].icon,
|
|
@@ -1852,7 +2080,7 @@ function LoginBox({
|
|
|
1852
2080
|
m
|
|
1853
2081
|
);
|
|
1854
2082
|
}) }),
|
|
1855
|
-
/* @__PURE__ */
|
|
2083
|
+
/* @__PURE__ */ jsx38(
|
|
1856
2084
|
EmailModal,
|
|
1857
2085
|
{
|
|
1858
2086
|
isOpen: emailOpen,
|
|
@@ -1868,83 +2096,174 @@ function LoginBox({
|
|
|
1868
2096
|
}
|
|
1869
2097
|
|
|
1870
2098
|
// src/components/LoginButton/index.tsx
|
|
1871
|
-
import { useState as
|
|
2099
|
+
import { useState as useState13 } from "react";
|
|
1872
2100
|
|
|
1873
2101
|
// src/components/LoginPanel/index.tsx
|
|
1874
|
-
import { jsx as
|
|
2102
|
+
import { jsx as jsx39, jsxs as jsxs25 } from "react/jsx-runtime";
|
|
1875
2103
|
function LoginPanel({
|
|
1876
2104
|
header,
|
|
1877
2105
|
onClose,
|
|
1878
2106
|
...props
|
|
1879
2107
|
}) {
|
|
1880
|
-
return /* @__PURE__ */
|
|
1881
|
-
header ? header : /* @__PURE__ */
|
|
1882
|
-
/* @__PURE__ */
|
|
1883
|
-
/* @__PURE__ */
|
|
1884
|
-
/* @__PURE__ */
|
|
2108
|
+
return /* @__PURE__ */ jsxs25("div", { className: "matchid-login-panel", children: [
|
|
2109
|
+
header ? header : /* @__PURE__ */ jsxs25("div", { className: "matchid-login-panel-header", children: [
|
|
2110
|
+
/* @__PURE__ */ jsxs25("div", { className: "matchid-login-panel-header-content", children: [
|
|
2111
|
+
/* @__PURE__ */ jsx39("div", { className: "matchid-login-panel-header-title", children: "Log in / Sign up" }),
|
|
2112
|
+
/* @__PURE__ */ jsx39("div", { className: "matchid-login-panel-header-subtilte", children: "You can use the following methods" })
|
|
1885
2113
|
] }),
|
|
1886
|
-
onClose && /* @__PURE__ */
|
|
2114
|
+
onClose && /* @__PURE__ */ jsx39("div", { className: "matchid-login-panel-header-close", onClick: onClose, children: /* @__PURE__ */ jsx39(CloseRoundIcon, {}) })
|
|
1887
2115
|
] }),
|
|
1888
|
-
/* @__PURE__ */
|
|
1889
|
-
/* @__PURE__ */
|
|
2116
|
+
/* @__PURE__ */ jsx39("div", { className: "matchid-login-panel-divide" }),
|
|
2117
|
+
/* @__PURE__ */ jsx39(LoginBox, { ...props })
|
|
1890
2118
|
] });
|
|
1891
2119
|
}
|
|
1892
2120
|
|
|
1893
2121
|
// src/components/LoginModal/index.tsx
|
|
1894
|
-
import { jsx as
|
|
2122
|
+
import { jsx as jsx40 } from "react/jsx-runtime";
|
|
1895
2123
|
function LoginModal({
|
|
1896
2124
|
isOpen = false,
|
|
1897
2125
|
width = 480,
|
|
1898
2126
|
...props
|
|
1899
2127
|
}) {
|
|
1900
2128
|
const { isLogin } = useUserInfo();
|
|
1901
|
-
return /* @__PURE__ */
|
|
2129
|
+
return /* @__PURE__ */ jsx40(
|
|
1902
2130
|
Modal,
|
|
1903
2131
|
{
|
|
1904
2132
|
isOpen: isOpen && !isLogin,
|
|
1905
2133
|
width,
|
|
1906
|
-
children: /* @__PURE__ */
|
|
2134
|
+
children: /* @__PURE__ */ jsx40(LoginPanel, { ...props, inModal: true })
|
|
1907
2135
|
}
|
|
1908
2136
|
);
|
|
1909
2137
|
}
|
|
1910
2138
|
|
|
2139
|
+
// src/components/UserPopover/index.tsx
|
|
2140
|
+
import { useState as useState12 } from "react";
|
|
2141
|
+
|
|
2142
|
+
// src/assets/icon/ProfileIcon.tsx
|
|
2143
|
+
import { jsx as jsx41, jsxs as jsxs26 } from "react/jsx-runtime";
|
|
2144
|
+
function ProfileIcon({ size = 24, color = "black", ...props }) {
|
|
2145
|
+
return /* @__PURE__ */ jsxs26("svg", { width: size, height: size, viewBox: "0 0 24 24", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: [
|
|
2146
|
+
/* @__PURE__ */ jsx41(
|
|
2147
|
+
"path",
|
|
2148
|
+
{
|
|
2149
|
+
fillRule: "evenodd",
|
|
2150
|
+
clipRule: "evenodd",
|
|
2151
|
+
d: "M7.5 6.75C7.5 4.95507 8.95507 3.5 10.75 3.5C12.5449 3.5 14 4.95507 14 6.75C14 8.54493 12.5449 10 10.75 10C8.95507 10 7.5 8.54493 7.5 6.75ZM10.75 2C8.12665 2 6 4.12665 6 6.75C6 9.37335 8.12665 11.5 10.75 11.5C13.3734 11.5 15.5 9.37335 15.5 6.75C15.5 4.12665 13.3734 2 10.75 2ZM8.75 13C5.57436 13 3 15.5744 3 18.75V19.75C3 20.7165 3.7835 21.5 4.75 21.5H13.6646L13.0292 20.8646C12.7764 20.6118 12.5733 20.3185 12.4263 20H4.75C4.61193 20 4.5 19.8881 4.5 19.75V18.75C4.5 16.4028 6.40279 14.5 8.75 14.5H12.6452C13.0508 13.8858 13.676 13.4295 14.4091 13.243C13.8838 13.0849 13.3268 13 12.75 13H8.75Z",
|
|
2152
|
+
fill: color
|
|
2153
|
+
}
|
|
2154
|
+
),
|
|
2155
|
+
/* @__PURE__ */ jsx41(
|
|
2156
|
+
"path",
|
|
2157
|
+
{
|
|
2158
|
+
fillRule: "evenodd",
|
|
2159
|
+
clipRule: "evenodd",
|
|
2160
|
+
d: "M19.0677 22.4771L21.4771 20.0677C21.841 19.7038 21.841 19.1139 21.4771 18.75L17.75 15.0229C17.5753 14.8482 17.3383 14.75 17.0911 14.75H14.6818C14.1672 14.75 13.75 15.1672 13.75 15.6818V18.0911C13.75 18.3383 13.8482 18.5753 14.0229 18.75L17.75 22.4771C18.1139 22.841 18.7038 22.841 19.0677 22.4771ZM15.6135 17.3124C15.9995 17.3124 16.3124 16.9995 16.3124 16.6135C16.3124 16.2276 15.9995 15.9147 15.6135 15.9147C15.2276 15.9147 14.9147 16.2276 14.9147 16.6135C14.9147 16.9995 15.2276 17.3124 15.6135 17.3124Z",
|
|
2161
|
+
fill: color
|
|
2162
|
+
}
|
|
2163
|
+
)
|
|
2164
|
+
] });
|
|
2165
|
+
}
|
|
2166
|
+
|
|
2167
|
+
// src/components/UserPopover/index.tsx
|
|
2168
|
+
import { jsx as jsx42, jsxs as jsxs27 } from "react/jsx-runtime";
|
|
2169
|
+
function UserContent() {
|
|
2170
|
+
const { logout, address, username } = useUserInfo();
|
|
2171
|
+
const [logouting, setLogouting] = useState12(false);
|
|
2172
|
+
const onLogout = async () => {
|
|
2173
|
+
if (logouting) return;
|
|
2174
|
+
try {
|
|
2175
|
+
setLogouting(true);
|
|
2176
|
+
await logout();
|
|
2177
|
+
} catch (error) {
|
|
2178
|
+
console.error(error);
|
|
2179
|
+
} finally {
|
|
2180
|
+
setLogouting(false);
|
|
2181
|
+
}
|
|
2182
|
+
};
|
|
2183
|
+
const UserItem = ({
|
|
2184
|
+
children,
|
|
2185
|
+
icon,
|
|
2186
|
+
rightIcon,
|
|
2187
|
+
onClick
|
|
2188
|
+
}) => {
|
|
2189
|
+
return /* @__PURE__ */ jsxs27("div", { className: "matchid-user-popover-item", onClick, children: [
|
|
2190
|
+
/* @__PURE__ */ jsxs27("div", { className: `matchid-user-popover-item-content`, children: [
|
|
2191
|
+
icon,
|
|
2192
|
+
/* @__PURE__ */ jsx42("div", { className: "matchid-user-popover-item-text", children })
|
|
2193
|
+
] }),
|
|
2194
|
+
rightIcon
|
|
2195
|
+
] });
|
|
2196
|
+
};
|
|
2197
|
+
const UserDivider = () => {
|
|
2198
|
+
return /* @__PURE__ */ jsx42("div", { className: `matchid-user-popover-divider` });
|
|
2199
|
+
};
|
|
2200
|
+
const [usernameOpen, setUsernameOpen] = useState12(false);
|
|
2201
|
+
const [copied, setCopied] = useCopyClipboard();
|
|
2202
|
+
return /* @__PURE__ */ jsxs27("div", { className: "matchid-user-popover-content", children: [
|
|
2203
|
+
/* @__PURE__ */ jsxs27("div", { className: "matchid-user-popover-list", children: [
|
|
2204
|
+
/* @__PURE__ */ jsx42(UserItem, { onClick: () => {
|
|
2205
|
+
setCopied(address);
|
|
2206
|
+
}, icon: copied ? /* @__PURE__ */ jsx42(CheckIcon, { size: 20, color: "#0ecb81" }) : /* @__PURE__ */ jsx42(CopyIcon, { size: 20, color: "var(--icon-color)" }), rightIcon: /* @__PURE__ */ jsx42(CheckIcon, { size: 20, color: "var(--icon-color)" }), children: truncateAddress(address) }),
|
|
2207
|
+
/* @__PURE__ */ jsx42(UserDivider, {}),
|
|
2208
|
+
/* @__PURE__ */ jsx42(UserItem, { onClick: () => {
|
|
2209
|
+
setUsernameOpen(true);
|
|
2210
|
+
}, icon: /* @__PURE__ */ jsx42(ProfileIcon, { size: 20, color: "var(--icon-color)" }), rightIcon: /* @__PURE__ */ jsx42(ArrowRightIcon, { size: 20, color: "var(--icon-color)" }), children: username || "Set a username" })
|
|
2211
|
+
] }),
|
|
2212
|
+
/* @__PURE__ */ jsx42(Button, { onClick: onLogout, loading: logouting, children: "Disconnect" }),
|
|
2213
|
+
/* @__PURE__ */ jsx42(UsernameModal, { isOpen: usernameOpen, onClose: () => {
|
|
2214
|
+
setUsernameOpen(false);
|
|
2215
|
+
}, onSuccess: () => {
|
|
2216
|
+
setUsernameOpen(false);
|
|
2217
|
+
} })
|
|
2218
|
+
] });
|
|
2219
|
+
}
|
|
2220
|
+
function UserPopover({
|
|
2221
|
+
children,
|
|
2222
|
+
...props
|
|
2223
|
+
}) {
|
|
2224
|
+
return /* @__PURE__ */ jsx42(Popover, { ...props, content: /* @__PURE__ */ jsx42(UserContent, {}), children });
|
|
2225
|
+
}
|
|
2226
|
+
|
|
1911
2227
|
// src/components/LoginButton/index.tsx
|
|
1912
|
-
import { Fragment as Fragment4, jsx as
|
|
2228
|
+
import { Fragment as Fragment4, jsx as jsx43, jsxs as jsxs28 } from "react/jsx-runtime";
|
|
1913
2229
|
function LoginButton({
|
|
1914
2230
|
loginRender,
|
|
1915
2231
|
methods,
|
|
1916
2232
|
onLoginClick,
|
|
2233
|
+
popoverPosition = "right",
|
|
2234
|
+
popoverType = "hover",
|
|
2235
|
+
popoverGap = 20,
|
|
1917
2236
|
...props
|
|
1918
2237
|
}) {
|
|
1919
2238
|
const { isLogin, username } = useUserInfo();
|
|
1920
|
-
const [loginOpen, setLoginOpen] =
|
|
2239
|
+
const [loginOpen, setLoginOpen] = useState13(false);
|
|
1921
2240
|
if (!isLogin) {
|
|
1922
|
-
return /* @__PURE__ */
|
|
1923
|
-
/* @__PURE__ */
|
|
1924
|
-
/* @__PURE__ */
|
|
1925
|
-
/* @__PURE__ */
|
|
1926
|
-
/* @__PURE__ */
|
|
2241
|
+
return /* @__PURE__ */ jsxs28(Fragment4, { children: [
|
|
2242
|
+
/* @__PURE__ */ jsx43(LoginModal, { methods, isOpen: loginOpen, onClose: () => setLoginOpen(false) }),
|
|
2243
|
+
/* @__PURE__ */ jsxs28(Button, { className: "matchid-unlogin-btn", ...props, highlight: true, onClick: () => setLoginOpen(true), children: [
|
|
2244
|
+
/* @__PURE__ */ jsx43(UnLoginIcon_default, {}),
|
|
2245
|
+
/* @__PURE__ */ jsx43("span", { children: "Login" })
|
|
1927
2246
|
] })
|
|
1928
2247
|
] });
|
|
1929
2248
|
}
|
|
1930
|
-
return loginRender ? loginRender(
|
|
1931
|
-
/* @__PURE__ */
|
|
1932
|
-
/* @__PURE__ */
|
|
1933
|
-
] });
|
|
2249
|
+
return loginRender ? { loginRender } : /* @__PURE__ */ jsx43(UserPopover, { position: popoverPosition, type: popoverType, gap: popoverGap, children: /* @__PURE__ */ jsxs28(Button, { onClick: onLoginClick, className: "matchid-login-btn", ...props, children: [
|
|
2250
|
+
/* @__PURE__ */ jsx43(LoginIcon_default, {}),
|
|
2251
|
+
/* @__PURE__ */ jsx43("span", { children: username ? truncateAddress(username) : "MatchID User" })
|
|
2252
|
+
] }) });
|
|
1934
2253
|
}
|
|
1935
2254
|
|
|
1936
2255
|
// src/components/UsernameModal/index.tsx
|
|
1937
|
-
import { useEffect as
|
|
2256
|
+
import { useEffect as useEffect11, useMemo as useMemo7, useState as useState14 } from "react";
|
|
1938
2257
|
|
|
1939
2258
|
// src/assets/icon/InfoRoundIcon.tsx
|
|
1940
|
-
import { jsx as
|
|
2259
|
+
import { jsx as jsx44, jsxs as jsxs29 } from "react/jsx-runtime";
|
|
1941
2260
|
function InfoRoundIcon({
|
|
1942
2261
|
size,
|
|
1943
2262
|
color = "#6E6E6E",
|
|
1944
2263
|
...props
|
|
1945
2264
|
}) {
|
|
1946
|
-
return /* @__PURE__ */
|
|
1947
|
-
/* @__PURE__ */
|
|
2265
|
+
return /* @__PURE__ */ jsxs29("svg", { width: size, height: size, viewBox: "0 0 16 16", fill: "none", xmlns: "http://www.w3.org/2000/svg", ...props, children: [
|
|
2266
|
+
/* @__PURE__ */ jsx44("g", { clipPath: "url(#clip0_418_7746)", children: /* @__PURE__ */ jsx44(
|
|
1948
2267
|
"path",
|
|
1949
2268
|
{
|
|
1950
2269
|
fillRule: "evenodd",
|
|
@@ -1953,19 +2272,19 @@ function InfoRoundIcon({
|
|
|
1953
2272
|
fill: color
|
|
1954
2273
|
}
|
|
1955
2274
|
) }),
|
|
1956
|
-
/* @__PURE__ */
|
|
2275
|
+
/* @__PURE__ */ jsx44("defs", { children: /* @__PURE__ */ jsx44("clipPath", { id: "clip0_418_7746", children: /* @__PURE__ */ jsx44("rect", { width: "16", height: "16", fill: "white" }) }) })
|
|
1957
2276
|
] });
|
|
1958
2277
|
}
|
|
1959
2278
|
|
|
1960
2279
|
// src/components/UsernameModal/index.tsx
|
|
1961
|
-
import { jsx as
|
|
2280
|
+
import { jsx as jsx45, jsxs as jsxs30 } from "react/jsx-runtime";
|
|
1962
2281
|
var ValidItem = ({
|
|
1963
2282
|
success = false,
|
|
1964
2283
|
text
|
|
1965
2284
|
}) => {
|
|
1966
|
-
return /* @__PURE__ */
|
|
1967
|
-
success ? /* @__PURE__ */
|
|
1968
|
-
/* @__PURE__ */
|
|
2285
|
+
return /* @__PURE__ */ jsxs30("div", { className: `matchid-valid-status-item matchid-valid-status-${success ? "success" : "error"}`, children: [
|
|
2286
|
+
success ? /* @__PURE__ */ jsx45(CheckRoundIcon, { size: 16 }) : /* @__PURE__ */ jsx45(InfoRoundIcon, { size: 16 }),
|
|
2287
|
+
/* @__PURE__ */ jsx45("span", { children: text })
|
|
1969
2288
|
] });
|
|
1970
2289
|
};
|
|
1971
2290
|
function UsernameModal({
|
|
@@ -1976,9 +2295,9 @@ function UsernameModal({
|
|
|
1976
2295
|
}) {
|
|
1977
2296
|
const { username, refreshOverview } = useUserInfo();
|
|
1978
2297
|
const { isLogin } = useUserInfo();
|
|
1979
|
-
const [val, setVal] =
|
|
1980
|
-
const [error, setError] =
|
|
1981
|
-
|
|
2298
|
+
const [val, setVal] = useState14(username);
|
|
2299
|
+
const [error, setError] = useState14("");
|
|
2300
|
+
useEffect11(() => {
|
|
1982
2301
|
if (isOpen) {
|
|
1983
2302
|
setVal(username);
|
|
1984
2303
|
setError("");
|
|
@@ -1991,7 +2310,7 @@ function UsernameModal({
|
|
|
1991
2310
|
return val.length >= 2 && val.length <= 32;
|
|
1992
2311
|
}, [val]);
|
|
1993
2312
|
const isSafe = isValid && isLength;
|
|
1994
|
-
const [isSubmitting, setIsSubmitting] =
|
|
2313
|
+
const [isSubmitting, setIsSubmitting] = useState14(false);
|
|
1995
2314
|
const onSubmit = async () => {
|
|
1996
2315
|
if (isSubmitting) return;
|
|
1997
2316
|
try {
|
|
@@ -2011,8 +2330,8 @@ function UsernameModal({
|
|
|
2011
2330
|
setIsSubmitting(false);
|
|
2012
2331
|
}
|
|
2013
2332
|
};
|
|
2014
|
-
return /* @__PURE__ */
|
|
2015
|
-
/* @__PURE__ */
|
|
2333
|
+
return /* @__PURE__ */ jsx45(ModalWithHeader, { isOpen: isOpen && isLogin, ...props, title: title || (username ? "Edit User Name" : "Set User Name"), children: /* @__PURE__ */ jsxs30("div", { className: "matchid-username-box", children: [
|
|
2334
|
+
/* @__PURE__ */ jsx45(Field, { label: "User Name", error, children: /* @__PURE__ */ jsx45(
|
|
2016
2335
|
Input,
|
|
2017
2336
|
{
|
|
2018
2337
|
placeholder: "Enter Your User Name",
|
|
@@ -2023,20 +2342,20 @@ function UsernameModal({
|
|
|
2023
2342
|
value: val
|
|
2024
2343
|
}
|
|
2025
2344
|
) }),
|
|
2026
|
-
/* @__PURE__ */
|
|
2027
|
-
/* @__PURE__ */
|
|
2345
|
+
/* @__PURE__ */ jsxs30("div", { className: "matchid-valid", children: [
|
|
2346
|
+
/* @__PURE__ */ jsx45(
|
|
2028
2347
|
ValidItem,
|
|
2029
2348
|
{
|
|
2030
2349
|
success: isValid,
|
|
2031
2350
|
text: "Name can be composed of numbers and letters as well as characters"
|
|
2032
2351
|
}
|
|
2033
2352
|
),
|
|
2034
|
-
/* @__PURE__ */
|
|
2353
|
+
/* @__PURE__ */ jsx45(ValidItem, { success: isLength, text: "No less than 2 characters" })
|
|
2035
2354
|
] }),
|
|
2036
|
-
/* @__PURE__ */
|
|
2355
|
+
/* @__PURE__ */ jsx45(Button, { disabled: !isSafe, loading: isSubmitting, style: {
|
|
2037
2356
|
marginTop: "64px"
|
|
2038
2357
|
}, onClick: onSubmit, size: "lg", block: true, highlight: true, children: "Confirm" }),
|
|
2039
|
-
/* @__PURE__ */
|
|
2358
|
+
/* @__PURE__ */ jsx45(Button, { style: {
|
|
2040
2359
|
marginTop: "24px"
|
|
2041
2360
|
}, onClick: props.onClose, size: "lg", block: true, children: "Next Time" })
|
|
2042
2361
|
] }) });
|