@matchain/matchid-sdk-react 0.1.53-alpha.6 → 0.1.53-alpha.8
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/assets/icon/index.d.mts +4 -146
- package/dist/assets/icon/index.d.ts +4 -146
- package/dist/assets/icon/index.js +35 -0
- package/dist/assets/icon/index.js.map +1 -1
- package/dist/assets/icon/index.mjs +3 -1
- package/dist/{chunk-3USZ4ZZY.mjs → chunk-FKXS2XRG.mjs} +96 -2
- package/dist/chunk-FKXS2XRG.mjs.map +1 -0
- package/dist/{chunk-OCQ2AIM3.mjs → chunk-IZOOVZAD.mjs} +5 -5
- package/dist/chunk-IZOOVZAD.mjs.map +1 -0
- package/dist/{chunk-Z7DMYFH5.mjs → chunk-QTUR37B2.mjs} +5729 -5364
- package/dist/chunk-QTUR37B2.mjs.map +1 -0
- package/dist/{chunk-V2S54LGG.mjs → chunk-X5HGL3ZX.mjs} +45 -3
- package/dist/chunk-X5HGL3ZX.mjs.map +1 -0
- package/dist/components/index.d.mts +3 -3
- package/dist/components/index.d.ts +3 -3
- package/dist/components/index.js +726 -360
- package/dist/components/index.js.map +1 -1
- package/dist/components/index.mjs +9 -5
- package/dist/hooks/api/index.d.mts +3 -2
- package/dist/hooks/api/index.d.ts +3 -2
- package/dist/hooks/api/index.js +249 -62
- package/dist/hooks/api/index.js.map +1 -1
- package/dist/hooks/api/index.mjs +9 -9
- package/dist/hooks/index.d.mts +3 -2
- package/dist/hooks/index.d.ts +3 -2
- package/dist/hooks/index.js +359 -320
- package/dist/hooks/index.js.map +1 -1
- package/dist/hooks/index.mjs +5 -5
- package/dist/{index-W6yjuOKT.d.mts → index-BDffLLM_.d.mts} +29 -17
- package/dist/index-BVfCh4l-.d.mts +203 -0
- package/dist/{index-Bpd2gBNh.d.mts → index-BaFmUVw-.d.mts} +1 -1
- package/dist/{index-Dt92N6yZ.d.ts → index-BsX-ovIl.d.ts} +29 -17
- package/dist/{index-wqqEUufi.d.mts → index-C0UKUm0h.d.ts} +25 -5
- package/dist/{index-DaXXoRxr.d.ts → index-CQmN0dN4.d.ts} +1 -1
- package/dist/index-D3Kp05kW.d.ts +203 -0
- package/dist/{index-BaYTgL99.d.mts → index-D5WIVIkc.d.ts} +3 -2
- package/dist/{index-D_UNctDI.d.mts → index-D7S5DMUy.d.mts} +18 -5
- package/dist/{index-BhU3hF7y.d.ts → index-DC4F1u-w.d.mts} +25 -5
- package/dist/{index-C5StsjWY.d.ts → index-DQFQ39D9.d.ts} +18 -5
- package/dist/{index-mxbJ8CFx.d.mts → index-DjbH13zc.d.mts} +3 -1
- package/dist/{index-D1QeVZyN.d.ts → index-SOVt-ADK.d.mts} +3 -2
- package/dist/{index-CFqk8eNo.d.ts → index-zc2GEzJ9.d.ts} +3 -1
- package/dist/index.css +123 -15
- package/dist/index.d.mts +9 -7
- package/dist/index.d.ts +9 -7
- package/dist/index.js +1023 -564
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +13 -12
- package/dist/request-B0CyrGFT.d.mts +15 -0
- package/dist/request-B0CyrGFT.d.ts +15 -0
- package/dist/types/index.d.mts +1 -1
- package/dist/types/index.d.ts +1 -1
- package/dist/{types-Bx_FJ11s.d.mts → types-VrV1kYga.d.mts} +9 -1
- package/dist/{types-Bx_FJ11s.d.ts → types-VrV1kYga.d.ts} +9 -1
- package/dist/ui/index.d.mts +3 -3
- package/dist/ui/index.d.ts +3 -3
- package/dist/ui/index.js +106 -61
- package/dist/ui/index.js.map +1 -1
- package/dist/ui/index.mjs +8 -4
- package/dist/utils/index.d.mts +1 -1
- package/dist/utils/index.d.ts +1 -1
- package/dist/utils/index.js +4 -4
- package/dist/utils/index.js.map +1 -1
- package/dist/utils/index.mjs +1 -1
- package/example/package.json +3 -1
- package/example/src/App.tsx +30 -7
- package/example/src/pages/Contact/index.tsx +90 -0
- package/example/src/pages/UI/components/Tabs.tsx +18 -0
- package/example/src/pages/UI/index.tsx +2 -0
- package/package.json +4 -1
- package/dist/chunk-3USZ4ZZY.mjs.map +0 -1
- package/dist/chunk-OCQ2AIM3.mjs.map +0 -1
- package/dist/chunk-UDXKFDXO.mjs +0 -97
- package/dist/chunk-UDXKFDXO.mjs.map +0 -1
- package/dist/chunk-V2S54LGG.mjs.map +0 -1
- package/dist/chunk-Z7DMYFH5.mjs.map +0 -1
package/dist/ui/index.mjs
CHANGED
|
@@ -11,9 +11,11 @@ import {
|
|
|
11
11
|
Overlay,
|
|
12
12
|
Popover,
|
|
13
13
|
Radio,
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
14
|
+
Skeleton_default,
|
|
15
|
+
Switch,
|
|
16
|
+
Tabs
|
|
17
|
+
} from "../chunk-X5HGL3ZX.mjs";
|
|
18
|
+
import "../chunk-FKXS2XRG.mjs";
|
|
17
19
|
import "../chunk-J5LGTIGS.mjs";
|
|
18
20
|
export {
|
|
19
21
|
AlphaAvatar,
|
|
@@ -28,6 +30,8 @@ export {
|
|
|
28
30
|
Overlay,
|
|
29
31
|
Popover,
|
|
30
32
|
Radio,
|
|
31
|
-
|
|
33
|
+
Skeleton_default as Skeleton,
|
|
34
|
+
Switch,
|
|
35
|
+
Tabs
|
|
32
36
|
};
|
|
33
37
|
//# sourceMappingURL=index.mjs.map
|
package/dist/utils/index.d.mts
CHANGED
|
@@ -4,7 +4,7 @@ declare function decodeBase64(input: string): string;
|
|
|
4
4
|
declare const isValidEmail: (email: string) => boolean;
|
|
5
5
|
declare const isValidUsername: (username: string) => boolean;
|
|
6
6
|
declare const deepMerge: (target: any, source: any) => any;
|
|
7
|
-
declare function truncateAddress(address: string): string;
|
|
7
|
+
declare function truncateAddress(address: string, startLen?: number, endLen?: number): string;
|
|
8
8
|
declare function firstUpperCase(str: string): string;
|
|
9
9
|
declare function getAppClientId(): string;
|
|
10
10
|
interface NumberFormatterProps {
|
package/dist/utils/index.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ declare function decodeBase64(input: string): string;
|
|
|
4
4
|
declare const isValidEmail: (email: string) => boolean;
|
|
5
5
|
declare const isValidUsername: (username: string) => boolean;
|
|
6
6
|
declare const deepMerge: (target: any, source: any) => any;
|
|
7
|
-
declare function truncateAddress(address: string): string;
|
|
7
|
+
declare function truncateAddress(address: string, startLen?: number, endLen?: number): string;
|
|
8
8
|
declare function firstUpperCase(str: string): string;
|
|
9
9
|
declare function getAppClientId(): string;
|
|
10
10
|
interface NumberFormatterProps {
|
package/dist/utils/index.js
CHANGED
|
@@ -73,12 +73,12 @@ var deepMerge = (target, source) => {
|
|
|
73
73
|
}
|
|
74
74
|
return target;
|
|
75
75
|
};
|
|
76
|
-
function truncateAddress(address) {
|
|
77
|
-
if (address.length <=
|
|
76
|
+
function truncateAddress(address, startLen = 4, endLen = 4) {
|
|
77
|
+
if (address.length <= startLen + endLen) {
|
|
78
78
|
return address;
|
|
79
79
|
}
|
|
80
|
-
const start = address.slice(0,
|
|
81
|
-
const end = address.slice(-
|
|
80
|
+
const start = address.slice(0, startLen);
|
|
81
|
+
const end = address.slice(-endLen);
|
|
82
82
|
return `${start}...${end}`;
|
|
83
83
|
}
|
|
84
84
|
function firstUpperCase(str) {
|
package/dist/utils/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/utils/index.tsx"],"sourcesContent":["import moment from 'moment';\n\nexport const getVersion = (): string => {\n return \"0.0.2\";\n};\n\nexport function encodeBase64(input: string) {\n return btoa(unescape(encodeURIComponent(input)));\n}\n\nexport function decodeBase64(input: string) {\n return decodeURIComponent(escape(atob(input)));\n}\n\nexport const isValidEmail = (email: string) => {\n return /^[^\\s@]+@[^\\s@]+\\.[^\\s@]+$/.test(email)\n}\nexport const isValidUsername = (username: string) => {\n //8-32 alpha number - _\n return /^[a-zA-Z0-9_-]+$/.test(username)\n}\n\nexport const deepMerge = (target: any, source: any): any => {\n for (const key in source) {\n if (source[key] instanceof Object && key in target) {\n target[key] = deepMerge(target[key], source[key]);\n } else {\n target[key] = source[key];\n }\n }\n return target;\n};\n\nexport function truncateAddress(address: string): string {\n if (address.length <=
|
|
1
|
+
{"version":3,"sources":["../../src/utils/index.tsx"],"sourcesContent":["import moment from 'moment';\n\nexport const getVersion = (): string => {\n return \"0.0.2\";\n};\n\nexport function encodeBase64(input: string) {\n return btoa(unescape(encodeURIComponent(input)));\n}\n\nexport function decodeBase64(input: string) {\n return decodeURIComponent(escape(atob(input)));\n}\n\nexport const isValidEmail = (email: string) => {\n return /^[^\\s@]+@[^\\s@]+\\.[^\\s@]+$/.test(email)\n}\nexport const isValidUsername = (username: string) => {\n //8-32 alpha number - _\n return /^[a-zA-Z0-9_-]+$/.test(username)\n}\n\nexport const deepMerge = (target: any, source: any): any => {\n for (const key in source) {\n if (source[key] instanceof Object && key in target) {\n target[key] = deepMerge(target[key], source[key]);\n } else {\n target[key] = source[key];\n }\n }\n return target;\n};\n\nexport function truncateAddress(address: string, startLen = 4, endLen = 4): string {\n if (address.length <= startLen + endLen) {\n return address;\n }\n const start = address.slice(0, startLen);\n const end = address.slice(-endLen);\n return `${start}...${end}`;\n}\n\n\nexport function firstUpperCase(str: string): string {\n return str.toString()[0].toUpperCase() + str.toString().slice(1);\n}\n\nexport function getAppClientId() {\n return \"react-sdk-\" + getVersion()\n}\n\n\nfunction convertScientificToDecimal(num: number) {\n let str = num.toFixed(12)\n str = str.replace(/0+$/, '')\n str = str.replace(/\\.$/, '')\n return str\n}\n\ninterface NumberFormatterProps {\n value: number | string | undefined\n prefix?: string\n suffix?: string\n separator?: boolean\n fixNum?: number //number >= 1 fix num\n tFixNum?: number //number < 1 fix num\n intClassName?: string\n decimalClassName?: string\n prefixClassName?: string\n className?: string\n}\n\nexport const NumberFormatter: React.FC<NumberFormatterProps> = ({\n value,\n prefix = '',\n suffix = '',\n separator = true,\n fixNum = 2,\n tFixNum = 4,\n intClassName = \"\",\n decimalClassName = \"\",\n prefixClassName = \"\",\n className = \"\"\n }) => {\n const numberValue =\n typeof value === 'number'\n ? convertScientificToDecimal(value)\n : value\n ? value\n : '0'\n\n const [intPart, decimalPart] = numberValue.toString().split('.')\n\n const intFormat = separator\n ? intPart.replace(/\\B(?=(\\d{3})+(?!\\d))/g, ',')\n : intPart\n\n if (Math.abs(parseFloat(numberValue)) >= 1) {\n return (\n <span className={className}>\n {prefix && <span className={prefixClassName}>{prefix}</span>}\n <span className={intClassName}>{intFormat}</span>\n {decimalPart ? (\n <span className={decimalClassName}>\n .{decimalPart.substring(0, fixNum)}\n </span>\n ) : (\n ''\n )}\n {suffix}\n </span>\n )\n }\n\n if (decimalPart) {\n let zeroCount = 0\n for (let i = 0; i < decimalPart.length; i++) {\n if (decimalPart[i] === '0') {\n zeroCount++\n } else {\n break\n }\n }\n if (zeroCount < tFixNum) {\n return (\n <span className={className}>\n {prefix && <span className={prefixClassName}>{prefix}</span>}\n <span className={intClassName}>{intFormat}</span>\n <span className={decimalClassName}>\n .{decimalPart.substring(0, tFixNum)}\n </span>\n {suffix}\n </span>\n )\n }\n return (\n <span className={className}>\n {prefix && <span className={prefixClassName}>{prefix}</span>}\n <span className={intClassName}>{intFormat}</span>\n <span className={decimalClassName}>\n .0<sub>{zeroCount}</sub>\n {decimalPart?.substring(zeroCount, zeroCount + tFixNum - 2)}\n </span>\n {suffix}\n </span>\n )\n }\n return (\n <span className={className}>\n {prefix && <span className={prefixClassName}>{prefix}</span>}\n <span className={intClassName}>{intPart}</span>\n {suffix}\n </span>\n )\n}\n\nexport function formatAddress(address: string, pre = 4, after = 5) {\n return `${address.substring(0, pre)}...${address.substring(address.length - after, address.length)}`\n}\n\nexport const formatDate = (value: any, formatString = 'YYYY-MM-DD HH:mm:ss') => {\n if (value) {\n return moment.unix(value).format(formatString)\n }\n return '--'\n}\nexport const isInTgApp = () => {\n return !!(window.TelegramWebviewProxy)\n}\n\nexport function bytesToBase64(bytes: Uint8Array) {\n const binString = String.fromCodePoint(...bytes);\n return btoa(binString);\n}"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA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AAAA,SACL;AAAA,IAER;AACA,WACI,6CAAC,UAAK,WACO;AAAA,gBAAU,4CAAC,UAAK,WAAW,iBAAkB,kBAAO;AAAA,MAC7D,4CAAC,UAAK,WAAW,cAAe,qBAAU;AAAA,MACtC,6CAAC,UAAK,WAAW,kBAAkB;AAAA;AAAA,QACjC,4CAAC,SAAK,qBAAU;AAAA,QACb,aAAa,UAAU,WAAW,YAAY,UAAU,CAAC;AAAA,SAClE;AAAA,MACC;AAAA,OACD;AAAA,EAEZ;AACA,SACI,6CAAC,UAAK,WACO;AAAA,cAAU,4CAAC,UAAK,WAAW,iBAAkB,kBAAO;AAAA,IAC7D,4CAAC,UAAK,WAAW,cAAe,mBAAQ;AAAA,IACvC;AAAA,KACG;AAEhB;AAEO,SAAS,cAAc,SAAiB,MAAM,GAAG,QAAQ,GAAG;AAC/D,SAAO,GAAG,QAAQ,UAAU,GAAG,GAAG,CAAC,MAAM,QAAQ,UAAU,QAAQ,SAAS,OAAO,QAAQ,MAAM,CAAC;AACtG;AAEO,IAAM,aAAa,CAAC,OAAY,eAAe,0BAA0B;AAC5E,MAAI,OAAO;AACP,WAAO,cAAAA,QAAO,KAAK,KAAK,EAAE,OAAO,YAAY;AAAA,EACjD;AACA,SAAO;AACX;AACO,IAAM,YAAY,MAAM;AAC3B,SAAO,CAAC,CAAE,OAAO;AACrB;AAEO,SAAS,cAAc,OAAmB;AAC7C,QAAM,YAAY,OAAO,cAAc,GAAG,KAAK;AAC/C,SAAO,KAAK,SAAS;AACzB;","names":["moment"]}
|
package/dist/utils/index.mjs
CHANGED
package/example/package.json
CHANGED
|
@@ -17,10 +17,12 @@
|
|
|
17
17
|
"viem": "../node_modules/viem",
|
|
18
18
|
"react": "../node_modules/react",
|
|
19
19
|
"react-dom": "../node_modules/react-dom/profiling",
|
|
20
|
+
"lodash": "../node_modules/lodash",
|
|
20
21
|
"axios": "../node_modules/axios",
|
|
21
22
|
"zustand": "../node_modules/zustand",
|
|
22
23
|
"react-router-dom": "../node_modules/react-router-dom",
|
|
23
|
-
"@types/react-router-dom": "../node_modules/@types/react-router-dom"
|
|
24
|
+
"@types/react-router-dom": "../node_modules/@types/react-router-dom",
|
|
25
|
+
"@types/lodash": "../node_modules/@types/lodash"
|
|
24
26
|
},
|
|
25
27
|
"dependencies": {
|
|
26
28
|
"@matchain/matchid-sdk-react": "../dist",
|
package/example/src/App.tsx
CHANGED
|
@@ -14,6 +14,7 @@ import useLocalStore from "@/store/useLocalStore";
|
|
|
14
14
|
import {LoginButton} from "@matchain/matchid-sdk-react/components";
|
|
15
15
|
import UI from "@/pages/UI";
|
|
16
16
|
import TgApp from "@/pages/TgApp";
|
|
17
|
+
import Contact from "./pages/Contact";
|
|
17
18
|
|
|
18
19
|
|
|
19
20
|
function Nav() {
|
|
@@ -51,6 +52,12 @@ function Nav() {
|
|
|
51
52
|
url: '/wallet',
|
|
52
53
|
onActive: location.pathname === '/wallet',
|
|
53
54
|
hidden: !isLogin
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
name: 'Contact',
|
|
58
|
+
url: '/contact',
|
|
59
|
+
onActive: location.pathname === '/contact',
|
|
60
|
+
hidden: !isLogin
|
|
54
61
|
}
|
|
55
62
|
]
|
|
56
63
|
return list
|
|
@@ -59,7 +66,7 @@ function Nav() {
|
|
|
59
66
|
<nav className={`text-2xl mb-5 p-2 text-red-600 flex gap-10 flex-wrap`}>
|
|
60
67
|
{menus.map((menu) => {
|
|
61
68
|
return <Link key={menu.url} to={menu.url}
|
|
62
|
-
className={`text-2xl ${menu.onActive ? 'text-red-600' : 'text-gray-400'} ${menu.hidden?'hidden' :''}`}>{menu.name}</Link>
|
|
69
|
+
className={`text-2xl ${menu.onActive ? 'text-red-600' : 'text-gray-400'} ${menu.hidden ? 'hidden' : ''}`}>{menu.name}</Link>
|
|
63
70
|
})}
|
|
64
71
|
|
|
65
72
|
<LoginButton/>
|
|
@@ -69,15 +76,29 @@ function Nav() {
|
|
|
69
76
|
}
|
|
70
77
|
|
|
71
78
|
function RouterApp() {
|
|
72
|
-
const {
|
|
79
|
+
const {
|
|
80
|
+
appid,
|
|
81
|
+
setAppid,
|
|
82
|
+
locale,
|
|
83
|
+
setLocale,
|
|
84
|
+
endpoints,
|
|
85
|
+
setEndpoints,
|
|
86
|
+
setWalletType,
|
|
87
|
+
walletType,
|
|
88
|
+
backgroundColor,
|
|
89
|
+
setBackgroundColor,
|
|
90
|
+
color,
|
|
91
|
+
setColor
|
|
92
|
+
} = useLocalStore()
|
|
73
93
|
|
|
74
94
|
return <Router>
|
|
75
95
|
<div className={`mb-2 p-2 flex gap-2 flex-col`}>
|
|
76
96
|
<div>
|
|
77
97
|
<label>BackgroundColor:</label>
|
|
78
|
-
<input value={backgroundColor} placeholder={"BackgroundColor"} className={"border-solid border"}
|
|
79
|
-
|
|
80
|
-
|
|
98
|
+
<input value={backgroundColor} placeholder={"BackgroundColor"} className={"border-solid border"}
|
|
99
|
+
onChange={(ele) => {
|
|
100
|
+
setBackgroundColor(ele.target.value)
|
|
101
|
+
}}/></div>
|
|
81
102
|
<div>
|
|
82
103
|
<label>Color:</label>
|
|
83
104
|
<input value={color} placeholder={"Color"} className={"border-solid border"} onChange={(ele) => {
|
|
@@ -128,6 +149,7 @@ function RouterApp() {
|
|
|
128
149
|
<Route element={<RoutePrivate/>}>
|
|
129
150
|
<Route path="/user" element={<User/>}/>
|
|
130
151
|
<Route path="/wallet" element={<Wallet/>}/>
|
|
152
|
+
<Route path="/contact" element={<Contact/>}/>
|
|
131
153
|
</Route>
|
|
132
154
|
</Routes>
|
|
133
155
|
</div>
|
|
@@ -135,7 +157,7 @@ function RouterApp() {
|
|
|
135
157
|
}
|
|
136
158
|
|
|
137
159
|
function App() {
|
|
138
|
-
const {appid, locale, endpoints,walletType,backgroundColor,color} = useLocalStore()
|
|
160
|
+
const {appid, locale, endpoints, walletType, backgroundColor, color} = useLocalStore()
|
|
139
161
|
|
|
140
162
|
return <div style={{
|
|
141
163
|
backgroundColor: backgroundColor,
|
|
@@ -157,7 +179,8 @@ function App() {
|
|
|
157
179
|
}}
|
|
158
180
|
>
|
|
159
181
|
<RouterApp/>
|
|
160
|
-
</MatchProvider
|
|
182
|
+
</MatchProvider>
|
|
183
|
+
</div>;
|
|
161
184
|
}
|
|
162
185
|
|
|
163
186
|
export default App;
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import {ContactList,ContactCard} from "@matchain/matchid-sdk-react/components"
|
|
2
|
+
import {Field, Input, Button, Radio} from "@matchain/matchid-sdk-react/ui"
|
|
3
|
+
import {Api,Icon} from "@matchain/matchid-sdk-react"
|
|
4
|
+
import React, {useCallback, useEffect, useState} from "react";
|
|
5
|
+
import {debounce} from "lodash";
|
|
6
|
+
import {useToast} from "@matchain/matchid-sdk-react/hooks";
|
|
7
|
+
|
|
8
|
+
const {contact} = Api
|
|
9
|
+
|
|
10
|
+
function ContactSearch() {
|
|
11
|
+
const [value, setValue] = useState("")
|
|
12
|
+
const [searchValue, setSearchValue] = useState("")
|
|
13
|
+
const [loading,setLoading] = useState(false)
|
|
14
|
+
const [searching,setSearching] = useState(false)
|
|
15
|
+
const toast = useToast()
|
|
16
|
+
const debouncedSetKeyword = useCallback(
|
|
17
|
+
debounce((newKeyword) => {
|
|
18
|
+
setSearchValue(newKeyword);
|
|
19
|
+
}, 1500),
|
|
20
|
+
[]
|
|
21
|
+
);
|
|
22
|
+
|
|
23
|
+
const onChange = (e: React.ChangeEvent<HTMLInputElement>) => {
|
|
24
|
+
setValue(e.target.value);
|
|
25
|
+
debouncedSetKeyword(e.target.value);
|
|
26
|
+
setSearching(true)
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const searchQuery = contact.useContactSearch(searchValue)
|
|
30
|
+
|
|
31
|
+
useEffect(() => {
|
|
32
|
+
if(searchQuery.isFetched){
|
|
33
|
+
setSearching(false)
|
|
34
|
+
}
|
|
35
|
+
}, [searchQuery.isFetched]);
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
const onAdd = async()=>{
|
|
39
|
+
if(!searchQuery.data){
|
|
40
|
+
return
|
|
41
|
+
}
|
|
42
|
+
setLoading(true)
|
|
43
|
+
try{
|
|
44
|
+
await contact.addContact(searchQuery.data)
|
|
45
|
+
toast.success("Add Success")
|
|
46
|
+
}catch(error:any){
|
|
47
|
+
toast.success(error.message)
|
|
48
|
+
console.error(error)
|
|
49
|
+
}finally {
|
|
50
|
+
setLoading(false)
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
return <div className={`flex gap-4 flex-col`}>
|
|
54
|
+
<Field label={"Search"}>
|
|
55
|
+
<Input placeholder={"Input address or MatchID"} value={value} onChange={onChange}/>
|
|
56
|
+
</Field>
|
|
57
|
+
{(searchQuery.data || searching )&& <div className={"break-all"}>
|
|
58
|
+
<ContactCard loading={searching} data={!searching ?(searchQuery.data||undefined) : undefined}
|
|
59
|
+
action={()=>{
|
|
60
|
+
return searchQuery.data && <Button size="sm" onClick={onAdd} disabled={!searchQuery.data} loading={loading}>Add</Button>
|
|
61
|
+
}}
|
|
62
|
+
/>
|
|
63
|
+
</div>}
|
|
64
|
+
</div>
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
export default function Contact() {
|
|
68
|
+
const [contactType, setContactType] = useState<"Friend" | "Requests">("Friend")
|
|
69
|
+
|
|
70
|
+
return <div className={`grid md:grid-cols-2 gap-4`}>
|
|
71
|
+
<div>
|
|
72
|
+
<Field label={"Type"}>
|
|
73
|
+
<div className={`flex gap-4`}>
|
|
74
|
+
<div onClick={() => setContactType("Friend")}
|
|
75
|
+
className={`flex gap-2 items-center cursor-pointer`}>
|
|
76
|
+
<Radio checked={contactType == "Friend"}/>
|
|
77
|
+
Friend
|
|
78
|
+
</div>
|
|
79
|
+
<div onClick={() => setContactType("Requests")}
|
|
80
|
+
className={`flex gap-2 items-center cursor-pointer`}>
|
|
81
|
+
<Radio checked={contactType == "Requests"}/>
|
|
82
|
+
Requests
|
|
83
|
+
</div>
|
|
84
|
+
</div>
|
|
85
|
+
</Field>
|
|
86
|
+
<ContactList type={contactType}/>
|
|
87
|
+
</div>
|
|
88
|
+
<ContactSearch/>
|
|
89
|
+
</div>
|
|
90
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import {useState} from "react";
|
|
2
|
+
import {Tabs} from "@matchain/matchid-sdk-react/ui"
|
|
3
|
+
export default function TabsDemo(){
|
|
4
|
+
const list = ['Tab1', 'Tab2', 'Tab3']
|
|
5
|
+
const [activeTab, setActiveTab] = useState(0)
|
|
6
|
+
return <div>
|
|
7
|
+
<Tabs tabs={list} activeTab={activeTab} setActiveTab={setActiveTab}/>
|
|
8
|
+
<div>
|
|
9
|
+
{list.map((tab, index) => {
|
|
10
|
+
return <div key={index} style={{display: activeTab === index ? 'block' : 'none'}}>
|
|
11
|
+
{tab}
|
|
12
|
+
</div>
|
|
13
|
+
})}
|
|
14
|
+
</div>
|
|
15
|
+
</div>
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
}
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import SwitchDemo from "@/pages/UI/components/Switch";
|
|
2
2
|
import AlphaAvatarDemo from "@/pages/UI/components/AlphaAvatar";
|
|
3
3
|
import RadioDemo from "@/pages/UI/components/Radio";
|
|
4
|
+
import TabsDemo from "@/pages/UI/components/Tabs";
|
|
4
5
|
|
|
5
6
|
export default function UI(){
|
|
6
7
|
return <div>
|
|
7
8
|
<SwitchDemo/>
|
|
8
9
|
<AlphaAvatarDemo/>
|
|
9
10
|
<RadioDemo/>
|
|
11
|
+
<TabsDemo/>
|
|
10
12
|
</div>
|
|
11
13
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@matchain/matchid-sdk-react",
|
|
3
|
-
"version": "0.1.53-alpha.
|
|
3
|
+
"version": "0.1.53-alpha.8",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
6
|
"exports": {
|
|
@@ -73,11 +73,13 @@
|
|
|
73
73
|
"axios-retry": "^4.5.0",
|
|
74
74
|
"copy-to-clipboard": "^3.3.3",
|
|
75
75
|
"ethers": "^5.7.2",
|
|
76
|
+
"lodash": "^4.17.21",
|
|
76
77
|
"moment": "^2.30.1",
|
|
77
78
|
"react-infinite-scroll-component": "^6.1.0",
|
|
78
79
|
"react-intl": "^7.1.0",
|
|
79
80
|
"react-qrcode": "^0.3.6",
|
|
80
81
|
"react-router-dom": "^6.0.0",
|
|
82
|
+
"react-virtuoso": "^4.12.5",
|
|
81
83
|
"sats-connect": "^3.0.1",
|
|
82
84
|
"siwe": "^2.3.2",
|
|
83
85
|
"styled-components": "^6.1.13",
|
|
@@ -87,6 +89,7 @@
|
|
|
87
89
|
},
|
|
88
90
|
"devDependencies": {
|
|
89
91
|
"@swc/core": "^1.9.1",
|
|
92
|
+
"@types/lodash": "^4.17.16",
|
|
90
93
|
"@types/react": "^18.0.0",
|
|
91
94
|
"@types/react-dom": "^18.0.0",
|
|
92
95
|
"@types/react-modal": "^3.16.3",
|