@jaw.id/ui 0.0.3 → 0.0.4
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/cjs-error.cjs +3 -0
- package/dist/{ccip-BYa9WTP9.js → ccip-yRQNp5zr.js} +1 -1
- package/dist/{index-DBYNWeek.js → index-BcDVfcdq.js} +20832 -20511
- package/dist/index.js +1 -1
- package/package.json +8 -2
- package/.babelrc +0 -12
- package/CHANGELOG.md +0 -23
- package/components.json +0 -22
- package/postcss.config.cjs +0 -6
- package/src/components/ConnectDialog/index.tsx +0 -270
- package/src/components/ConnectDialog/types.ts +0 -34
- package/src/components/DefaultDialog/index.tsx +0 -99
- package/src/components/Eip712Dialog/index.tsx +0 -525
- package/src/components/Eip712Dialog/types.ts +0 -27
- package/src/components/FeeTokenSelector/index.tsx +0 -308
- package/src/components/OnboardingDialog/index.tsx +0 -317
- package/src/components/OnboardingDialog/types.ts +0 -43
- package/src/components/OrSeparator/index.tsx +0 -13
- package/src/components/PermissionDialog/index.tsx +0 -598
- package/src/components/PermissionDialog/types.ts +0 -77
- package/src/components/SignatureDialog/index.tsx +0 -180
- package/src/components/SignatureDialog/types.ts +0 -27
- package/src/components/SiweDialog/index.tsx +0 -231
- package/src/components/SiweDialog/types.ts +0 -34
- package/src/components/TransactionDialog/DecodedCalldata.tsx +0 -79
- package/src/components/TransactionDialog/index.tsx +0 -663
- package/src/components/TransactionDialog/types.ts +0 -54
- package/src/components/ui/accordion.tsx +0 -66
- package/src/components/ui/avatar.tsx +0 -53
- package/src/components/ui/button.tsx +0 -59
- package/src/components/ui/card.tsx +0 -92
- package/src/components/ui/checkbox.tsx +0 -32
- package/src/components/ui/dialog.tsx +0 -183
- package/src/components/ui/dropdown-menu.tsx +0 -258
- package/src/components/ui/form.tsx +0 -167
- package/src/components/ui/input.tsx +0 -60
- package/src/components/ui/label.tsx +0 -24
- package/src/components/ui/popover.tsx +0 -48
- package/src/components/ui/scroll-area.tsx +0 -58
- package/src/components/ui/select.tsx +0 -160
- package/src/components/ui/separator.tsx +0 -28
- package/src/components/ui/sheet.tsx +0 -169
- package/src/components/ui/spinner.tsx +0 -18
- package/src/components/ui/tabs.tsx +0 -69
- package/src/components/ui/tooltip.tsx +0 -61
- package/src/hooks/index.ts +0 -5
- package/src/hooks/useChainIconURI.tsx +0 -117
- package/src/hooks/useDecodedCalldata.ts +0 -128
- package/src/hooks/useFeeTokenPrice.tsx +0 -36
- package/src/hooks/useGasEstimation.ts +0 -474
- package/src/hooks/useIsMobile.ts +0 -36
- package/src/icons/index.tsx +0 -114
- package/src/index.ts +0 -19
- package/src/lib/utils.ts +0 -6
- package/src/react/ReactUIHandler.tsx +0 -3004
- package/src/react/index.ts +0 -2
- package/src/styles.css +0 -210
- package/src/utils/formatAddress.ts +0 -24
- package/src/utils/index.ts +0 -4
- package/src/utils/justaNameInstance.ts +0 -25
- package/src/utils/tokenBalance.ts +0 -41
- package/src/utils/tokenPrice.ts +0 -58
- package/tailwind.config.js +0 -130
- package/tsconfig.json +0 -19
- package/tsconfig.lib.json +0 -43
- package/vite.config.ts +0 -45
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { h as e, C as o, j as n, k as c, m as i, D as t, E as l, n as r, o as I, F as d, G as g, L as D, O as k, p as u, P as T, R as C, S as p, q as h, T as m, U as f, r as E, W as P, t as S, u as U, v as y, w as A, x as F, y as G, z as N, A as O, I as R, J as b, K as v, M as w, N as x } from "./index-BcDVfcdq.js";
|
|
2
2
|
export {
|
|
3
3
|
e as BadgeDollarIcon,
|
|
4
4
|
o as CloseIcon,
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jaw.id/ui",
|
|
3
3
|
"description": "Pre-built React dialogs for JAW.id",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.4",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sideEffects": [
|
|
7
7
|
"**/*.css",
|
|
@@ -16,6 +16,11 @@
|
|
|
16
16
|
"publishConfig": {
|
|
17
17
|
"access": "public"
|
|
18
18
|
},
|
|
19
|
+
"files": [
|
|
20
|
+
"dist",
|
|
21
|
+
"cjs-error.cjs",
|
|
22
|
+
"!**/*.tsbuildinfo"
|
|
23
|
+
],
|
|
19
24
|
"main": "./dist/index.js",
|
|
20
25
|
"module": "./dist/index.js",
|
|
21
26
|
"types": "./dist/index.d.ts",
|
|
@@ -25,6 +30,7 @@
|
|
|
25
30
|
"@jaw-mono/source": "./src/index.ts",
|
|
26
31
|
"types": "./dist/index.d.ts",
|
|
27
32
|
"import": "./dist/index.js",
|
|
33
|
+
"require": "./cjs-error.cjs",
|
|
28
34
|
"default": "./dist/index.js"
|
|
29
35
|
}
|
|
30
36
|
},
|
|
@@ -33,7 +39,7 @@
|
|
|
33
39
|
"react-dom": ">=18.0.0"
|
|
34
40
|
},
|
|
35
41
|
"dependencies": {
|
|
36
|
-
"@jaw.id/core": "0.0.
|
|
42
|
+
"@jaw.id/core": "0.0.2",
|
|
37
43
|
"@hookform/resolvers": "^5.2.2",
|
|
38
44
|
"@justaname.id/sdk": "^0.2.204",
|
|
39
45
|
"@radix-ui/react-accordion": "^1.2.12",
|
package/.babelrc
DELETED
package/CHANGELOG.md
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
## 0.0.3 (2026-02-19)
|
|
2
|
-
|
|
3
|
-
### 🩹 Fixes
|
|
4
|
-
|
|
5
|
-
- **core,ui,wagmi:** updated README.mds ([#112](https://github.com/JustaName-id/jaw-mono/pull/112))
|
|
6
|
-
|
|
7
|
-
### 🧱 Updated Dependencies
|
|
8
|
-
|
|
9
|
-
- Updated @jaw.id/core to 0.0.2
|
|
10
|
-
|
|
11
|
-
### ❤️ Thank You
|
|
12
|
-
|
|
13
|
-
- Ghadi @Ghadi8
|
|
14
|
-
|
|
15
|
-
## 0.0.2 (2026-02-19)
|
|
16
|
-
|
|
17
|
-
### 🩹 Fixes
|
|
18
|
-
|
|
19
|
-
- **ui,keys:** prevent crash when call permission selector is undefined ([#111](https://github.com/JustaName-id/jaw-mono/pull/111))
|
|
20
|
-
|
|
21
|
-
### ❤️ Thank You
|
|
22
|
-
|
|
23
|
-
- Leo Franklin @LeoFranklin015
|
package/components.json
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"$schema": "https://ui.shadcn.com/schema.json",
|
|
3
|
-
"style": "new-york",
|
|
4
|
-
"rsc": false,
|
|
5
|
-
"tsx": true,
|
|
6
|
-
"tailwind": {
|
|
7
|
-
"config": "tailwind.config.js",
|
|
8
|
-
"css": "src/styles.css",
|
|
9
|
-
"baseColor": "neutral",
|
|
10
|
-
"cssVariables": true,
|
|
11
|
-
"prefix": ""
|
|
12
|
-
},
|
|
13
|
-
"iconLibrary": "lucide",
|
|
14
|
-
"aliases": {
|
|
15
|
-
"components": "@/components",
|
|
16
|
-
"utils": "@/lib/utils",
|
|
17
|
-
"ui": "@/components/ui",
|
|
18
|
-
"lib": "@/lib",
|
|
19
|
-
"hooks": "@/hooks"
|
|
20
|
-
},
|
|
21
|
-
"registries": {}
|
|
22
|
-
}
|
package/postcss.config.cjs
DELETED
|
@@ -1,270 +0,0 @@
|
|
|
1
|
-
'use client'
|
|
2
|
-
|
|
3
|
-
import { useState, useEffect } from "react";
|
|
4
|
-
import { BadgeDollarIcon, EyeIcon, CopyIcon, CopiedIcon } from "../../icons";
|
|
5
|
-
import { useIsMobile } from "../../hooks";
|
|
6
|
-
import { DefaultDialog } from "../DefaultDialog";
|
|
7
|
-
import { Button } from "../ui/button";
|
|
8
|
-
import { ConnectDialogProps } from "./types";
|
|
9
|
-
import { getJustaNameInstance } from "../../utils/justaNameInstance";
|
|
10
|
-
|
|
11
|
-
export const ConnectDialog = ({
|
|
12
|
-
open,
|
|
13
|
-
onOpenChange,
|
|
14
|
-
appName,
|
|
15
|
-
appLogoUrl,
|
|
16
|
-
origin,
|
|
17
|
-
timestamp,
|
|
18
|
-
accountName,
|
|
19
|
-
walletAddress,
|
|
20
|
-
chainName,
|
|
21
|
-
chainId,
|
|
22
|
-
chainIcon,
|
|
23
|
-
mainnetRpcUrl,
|
|
24
|
-
onConnect,
|
|
25
|
-
onCancel,
|
|
26
|
-
showPermissions = true,
|
|
27
|
-
isProcessing,
|
|
28
|
-
}: ConnectDialogProps) => {
|
|
29
|
-
const isMobile = useIsMobile();
|
|
30
|
-
const [resolvedAddress, setResolvedAddress] = useState<string | null>(null);
|
|
31
|
-
const [isAddressCopied, setIsAddressCopied] = useState(false);
|
|
32
|
-
|
|
33
|
-
// Resolve wallet address to human-readable name
|
|
34
|
-
useEffect(() => {
|
|
35
|
-
if (walletAddress && chainId) {
|
|
36
|
-
const justaName = getJustaNameInstance(mainnetRpcUrl);
|
|
37
|
-
justaName.subnames.reverseResolve({
|
|
38
|
-
address: walletAddress as `0x${string}`,
|
|
39
|
-
chainId: chainId,
|
|
40
|
-
}).then((result) => {
|
|
41
|
-
if (result) {
|
|
42
|
-
setResolvedAddress(result);
|
|
43
|
-
}
|
|
44
|
-
}).catch(() => {
|
|
45
|
-
// Silently fail if resolution fails
|
|
46
|
-
});
|
|
47
|
-
}
|
|
48
|
-
}, [walletAddress, chainId]);
|
|
49
|
-
|
|
50
|
-
// Use resolved address, then accountName prop, then truncated address
|
|
51
|
-
const displayName = resolvedAddress || accountName;
|
|
52
|
-
|
|
53
|
-
// Format origin to display only domain (remove protocol)
|
|
54
|
-
const formatOrigin = (url: string) => {
|
|
55
|
-
try {
|
|
56
|
-
const urlObj = new URL(url.startsWith('http') ? url : `https://${url}`);
|
|
57
|
-
return urlObj.hostname.replace('www.', '');
|
|
58
|
-
} catch {
|
|
59
|
-
return origin;
|
|
60
|
-
}
|
|
61
|
-
};
|
|
62
|
-
|
|
63
|
-
const copyToClipboard = (text: string) => {
|
|
64
|
-
if (typeof window !== 'undefined' && navigator?.clipboard) {
|
|
65
|
-
navigator.clipboard.writeText(text);
|
|
66
|
-
setIsAddressCopied(true);
|
|
67
|
-
setTimeout(() => setIsAddressCopied(false), 3000);
|
|
68
|
-
}
|
|
69
|
-
};
|
|
70
|
-
|
|
71
|
-
// Format wallet address for display
|
|
72
|
-
const formatAddress = (address: string) => {
|
|
73
|
-
if (!address || address.length < 10) return address;
|
|
74
|
-
return `${address.slice(0, 6)}...${address.slice(-4)}`;
|
|
75
|
-
};
|
|
76
|
-
|
|
77
|
-
return (
|
|
78
|
-
<DefaultDialog
|
|
79
|
-
open={open}
|
|
80
|
-
handleClose={onCancel}
|
|
81
|
-
onOpenChange={!isProcessing ? onOpenChange : undefined}
|
|
82
|
-
header={
|
|
83
|
-
<div className="flex flex-col gap-2.5 p-3.5">
|
|
84
|
-
<p className="text-xs font-bold text-muted-foreground leading-[100%]">
|
|
85
|
-
{timestamp.toLocaleDateString('en-US', {
|
|
86
|
-
weekday: 'long',
|
|
87
|
-
day: 'numeric',
|
|
88
|
-
month: 'long'
|
|
89
|
-
})} at {timestamp.toLocaleTimeString('en-US', {
|
|
90
|
-
hour: '2-digit',
|
|
91
|
-
minute: '2-digit',
|
|
92
|
-
second: '2-digit',
|
|
93
|
-
timeZoneName: 'short'
|
|
94
|
-
})}
|
|
95
|
-
</p>
|
|
96
|
-
<div className="flex flex-col gap-1">
|
|
97
|
-
<div className="flex flex-row items-center gap-1">
|
|
98
|
-
<p className="text-sm leading-none text-muted-foreground">
|
|
99
|
-
Sign in as {displayName || formatAddress(walletAddress)}
|
|
100
|
-
</p>
|
|
101
|
-
{!displayName && (
|
|
102
|
-
isAddressCopied ? (
|
|
103
|
-
<CopiedIcon width={10} height={10} className="flex-shrink-0" />
|
|
104
|
-
) : (
|
|
105
|
-
<CopyIcon
|
|
106
|
-
width={10}
|
|
107
|
-
height={10}
|
|
108
|
-
onClick={() => copyToClipboard(walletAddress)}
|
|
109
|
-
className="cursor-pointer flex-shrink-0"
|
|
110
|
-
/>
|
|
111
|
-
)
|
|
112
|
-
)}
|
|
113
|
-
</div>
|
|
114
|
-
{displayName && (
|
|
115
|
-
<div className="flex flex-row items-center gap-1">
|
|
116
|
-
<p className="text-sm leading-none text-muted-foreground">
|
|
117
|
-
{formatAddress(walletAddress)}
|
|
118
|
-
</p>
|
|
119
|
-
{isAddressCopied ? (
|
|
120
|
-
<CopiedIcon width={10} height={10} className="flex-shrink-0" />
|
|
121
|
-
) : (
|
|
122
|
-
<CopyIcon
|
|
123
|
-
width={10}
|
|
124
|
-
height={10}
|
|
125
|
-
onClick={() => copyToClipboard(walletAddress)}
|
|
126
|
-
className="cursor-pointer flex-shrink-0"
|
|
127
|
-
/>
|
|
128
|
-
)}
|
|
129
|
-
</div>
|
|
130
|
-
)}
|
|
131
|
-
</div>
|
|
132
|
-
</div>
|
|
133
|
-
}
|
|
134
|
-
contentStyle={isMobile ? {
|
|
135
|
-
width: '100%',
|
|
136
|
-
height: '100%',
|
|
137
|
-
maxWidth: 'none',
|
|
138
|
-
maxHeight: 'none',
|
|
139
|
-
} : {
|
|
140
|
-
width: 'fit-content',
|
|
141
|
-
maxWidth: '500px',
|
|
142
|
-
}}
|
|
143
|
-
>
|
|
144
|
-
<div className="flex flex-col h-full gap-3 overflow-y-auto min-h-0">
|
|
145
|
-
{/* App Logo and Title */}
|
|
146
|
-
<div className="flex flex-1 flex-col p-3.5 items-center justify-center">
|
|
147
|
-
{appLogoUrl && (
|
|
148
|
-
<img
|
|
149
|
-
src={appLogoUrl}
|
|
150
|
-
alt={`${appName} logo`}
|
|
151
|
-
className="w-[72px] h-[72px] rounded-full mb-3"
|
|
152
|
-
/>
|
|
153
|
-
)}
|
|
154
|
-
<div className="flex flex-col items-center gap-1 text-foreground">
|
|
155
|
-
<p className="text-2xl font-normal leading-[133%]">
|
|
156
|
-
Connect to {appName}
|
|
157
|
-
</p>
|
|
158
|
-
<p className="text-base leading-[150%] text-muted-foreground">
|
|
159
|
-
This app wants to connect to your wallet
|
|
160
|
-
</p>
|
|
161
|
-
</div>
|
|
162
|
-
</div>
|
|
163
|
-
|
|
164
|
-
{/* Account Details Card */}
|
|
165
|
-
{/* <div className="flex-1 p-3.5 bg-secondary border border-border rounded-[6px]">
|
|
166
|
-
<div className="flex flex-col gap-2">
|
|
167
|
-
<div className="flex justify-between items-center">
|
|
168
|
-
<span className="text-xs font-bold text-foreground">Account</span>
|
|
169
|
-
<span className="text-sm font-medium text-foreground">
|
|
170
|
-
{accountName || 'Wallet'}
|
|
171
|
-
</span>
|
|
172
|
-
</div>
|
|
173
|
-
<div className="flex justify-between items-center">
|
|
174
|
-
<span className="text-xs font-bold text-foreground">Address</span>
|
|
175
|
-
<span className="text-sm font-mono font-medium text-foreground">
|
|
176
|
-
{formatAddress(walletAddress)}
|
|
177
|
-
</span>
|
|
178
|
-
</div>
|
|
179
|
-
{supportedChains && supportedChains.length > 0 && (
|
|
180
|
-
<div className="flex justify-between items-center">
|
|
181
|
-
<span className="text-xs font-bold text-foreground">Chains</span>
|
|
182
|
-
<span className="text-sm font-medium text-foreground">
|
|
183
|
-
{supportedChains.length} {supportedChains.length === 1 ? 'chain' : 'chains'}
|
|
184
|
-
</span>
|
|
185
|
-
</div>
|
|
186
|
-
)}
|
|
187
|
-
</div>
|
|
188
|
-
</div> */}
|
|
189
|
-
|
|
190
|
-
{/* Permissions Section */}
|
|
191
|
-
{showPermissions && (
|
|
192
|
-
<div className="flex flex-col gap-2">
|
|
193
|
-
<div className="flex items-center flex-row gap-2.5 p-3.5 border border-border rounded-[6px]">
|
|
194
|
-
<EyeIcon className="w-4 h-4 flex-shrink-0" />
|
|
195
|
-
<p className="text-foreground text-xs font-normal leading-[150%]">
|
|
196
|
-
Allow the app to see your addresses
|
|
197
|
-
</p>
|
|
198
|
-
</div>
|
|
199
|
-
<div className="flex items-center flex-row gap-2.5 p-3.5 border border-border rounded-[6px]">
|
|
200
|
-
<BadgeDollarIcon className="w-4 h-4 flex-shrink-0" />
|
|
201
|
-
<p className="text-foreground text-xs font-normal leading-[150%]">
|
|
202
|
-
Allow the app to propose transactions
|
|
203
|
-
</p>
|
|
204
|
-
</div>
|
|
205
|
-
<div className="flex items-center flex-row gap-2.5 p-3.5 border border-border rounded-[6px]">
|
|
206
|
-
<BadgeDollarIcon className="w-4 h-4 flex-shrink-0" />
|
|
207
|
-
<p className="text-foreground text-xs font-normal leading-[150%]">
|
|
208
|
-
The app cannot move funds without your permission
|
|
209
|
-
</p>
|
|
210
|
-
</div>
|
|
211
|
-
</div>
|
|
212
|
-
)}
|
|
213
|
-
|
|
214
|
-
{/* Network and URL Information */}
|
|
215
|
-
<div className="flex flex-row gap-4 border border-border rounded-[6px] p-2">
|
|
216
|
-
{/* Network Column */}
|
|
217
|
-
{chainName && (
|
|
218
|
-
<>
|
|
219
|
-
<div className="flex flex-col gap-1 flex-1">
|
|
220
|
-
<p className="text-xs font-bold text-foreground">Network</p>
|
|
221
|
-
<div className="flex flex-row items-center gap-2">
|
|
222
|
-
{chainIcon && (
|
|
223
|
-
<div className="w-6 h-6 min-w-4 flex items-center justify-center flex-shrink-0">
|
|
224
|
-
{chainIcon}
|
|
225
|
-
</div>
|
|
226
|
-
)}
|
|
227
|
-
<p className="text-sm font-normal text-foreground">
|
|
228
|
-
{chainName}
|
|
229
|
-
</p>
|
|
230
|
-
</div>
|
|
231
|
-
</div>
|
|
232
|
-
{/* Vertical Separator */}
|
|
233
|
-
<div className="w-[1px] bg-border min-h-[40px]"></div>
|
|
234
|
-
</>
|
|
235
|
-
)}
|
|
236
|
-
{/* URL Column */}
|
|
237
|
-
<div className="flex flex-col gap-1 flex-1">
|
|
238
|
-
<p className="text-xs font-bold text-foreground">URL</p>
|
|
239
|
-
<p className="text-sm font-normal text-foreground">
|
|
240
|
-
{formatOrigin(origin)}
|
|
241
|
-
</p>
|
|
242
|
-
</div>
|
|
243
|
-
</div>
|
|
244
|
-
|
|
245
|
-
{/* Action Buttons Section */}
|
|
246
|
-
<div className="flex mt-3 flex-shrink-0">
|
|
247
|
-
<div className="flex gap-2 w-full justify-between">
|
|
248
|
-
<Button
|
|
249
|
-
variant="outline"
|
|
250
|
-
onClick={onCancel}
|
|
251
|
-
disabled={isProcessing}
|
|
252
|
-
className="flex-1"
|
|
253
|
-
>
|
|
254
|
-
Cancel
|
|
255
|
-
</Button>
|
|
256
|
-
<Button
|
|
257
|
-
onClick={onConnect}
|
|
258
|
-
disabled={isProcessing}
|
|
259
|
-
className="flex-1"
|
|
260
|
-
>
|
|
261
|
-
{isProcessing ? 'Connecting...' : 'Connect'}
|
|
262
|
-
</Button>
|
|
263
|
-
</div>
|
|
264
|
-
</div>
|
|
265
|
-
</div>
|
|
266
|
-
</DefaultDialog>
|
|
267
|
-
)
|
|
268
|
-
}
|
|
269
|
-
|
|
270
|
-
export * from './types';
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import { JSX } from "react";
|
|
2
|
-
|
|
3
|
-
export interface ConnectDialogProps {
|
|
4
|
-
open: boolean;
|
|
5
|
-
onOpenChange: (open: boolean) => void;
|
|
6
|
-
|
|
7
|
-
// App information
|
|
8
|
-
appName: string;
|
|
9
|
-
appLogoUrl?: string;
|
|
10
|
-
origin: string;
|
|
11
|
-
timestamp: Date;
|
|
12
|
-
|
|
13
|
-
// User account information
|
|
14
|
-
accountName?: string;
|
|
15
|
-
walletAddress: string;
|
|
16
|
-
|
|
17
|
-
// Chain information
|
|
18
|
-
chainName?: string;
|
|
19
|
-
chainId?: number;
|
|
20
|
-
chainIcon?: JSX.Element;
|
|
21
|
-
|
|
22
|
-
// RPC configuration
|
|
23
|
-
mainnetRpcUrl: string;
|
|
24
|
-
|
|
25
|
-
// Actions
|
|
26
|
-
onConnect: () => Promise<void>;
|
|
27
|
-
onCancel: () => void;
|
|
28
|
-
|
|
29
|
-
// Whether to show the permission info messages (default: true)
|
|
30
|
-
showPermissions?: boolean;
|
|
31
|
-
|
|
32
|
-
// Status
|
|
33
|
-
isProcessing: boolean;
|
|
34
|
-
}
|
|
@@ -1,99 +0,0 @@
|
|
|
1
|
-
import { CloseIcon } from '../../icons';
|
|
2
|
-
import { Dialog, DialogClose, DialogContent, DialogTitle, DialogTrigger } from '../ui/dialog';
|
|
3
|
-
import { FC, ReactNode } from 'react';
|
|
4
|
-
|
|
5
|
-
export interface DefaultDialogProps {
|
|
6
|
-
open?: boolean;
|
|
7
|
-
handleClose?: () => void;
|
|
8
|
-
onOpenChange?: (open: boolean) => void;
|
|
9
|
-
children: ReactNode;
|
|
10
|
-
header?: ReactNode;
|
|
11
|
-
innerStyle?: React.CSSProperties;
|
|
12
|
-
trigger?: ReactNode;
|
|
13
|
-
fullScreen?: boolean;
|
|
14
|
-
contentStyle?: React.CSSProperties;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export const DefaultDialog: FC<DefaultDialogProps> = ({
|
|
18
|
-
onOpenChange,
|
|
19
|
-
trigger,
|
|
20
|
-
open,
|
|
21
|
-
handleClose,
|
|
22
|
-
children,
|
|
23
|
-
header,
|
|
24
|
-
fullScreen,
|
|
25
|
-
innerStyle = {},
|
|
26
|
-
contentStyle = {},
|
|
27
|
-
}) => {
|
|
28
|
-
return (
|
|
29
|
-
<Dialog modal={true} open={open} onOpenChange={onOpenChange}>
|
|
30
|
-
{trigger && <DialogTrigger asChild>{trigger}</DialogTrigger>}
|
|
31
|
-
|
|
32
|
-
<DialogContent
|
|
33
|
-
fullScreen={fullScreen}
|
|
34
|
-
onInteractOutside={(e) => {
|
|
35
|
-
// Only stop propagation for click/pointer events, NOT wheel events
|
|
36
|
-
// This allows scrolling to work inside the dialog
|
|
37
|
-
if (e.type !== 'wheel') {
|
|
38
|
-
e.stopPropagation();
|
|
39
|
-
}
|
|
40
|
-
}}
|
|
41
|
-
aria-describedby={undefined}
|
|
42
|
-
showCloseButton={false}
|
|
43
|
-
style={{
|
|
44
|
-
padding: 0,
|
|
45
|
-
transition: 'all 0.4 ease-in-out',
|
|
46
|
-
display: 'flex',
|
|
47
|
-
flexDirection: 'column',
|
|
48
|
-
borderRadius: fullScreen ? '0' : undefined,
|
|
49
|
-
boxSizing: 'content-box',
|
|
50
|
-
...contentStyle,
|
|
51
|
-
}}
|
|
52
|
-
>
|
|
53
|
-
<DialogTitle style={{ display: 'none' }}></DialogTitle>
|
|
54
|
-
|
|
55
|
-
<div onWheel={(e) => e.nativeEvent.stopPropagation()} className={`flex p-2.5 ${fullScreen ? 'rounded-none' : 'rounded-3xl'} gap-5 flex-col md:max-h-[calc(100%-45px)] flex-1 box-border overflow-auto`}
|
|
56
|
-
style={{
|
|
57
|
-
...innerStyle,
|
|
58
|
-
}}
|
|
59
|
-
>
|
|
60
|
-
<div className="flex flex-row justify-between">
|
|
61
|
-
{header}
|
|
62
|
-
|
|
63
|
-
<div
|
|
64
|
-
className="flex flex-col items-center justify-center w-[24px]">
|
|
65
|
-
{handleClose ? (
|
|
66
|
-
<CloseIcon
|
|
67
|
-
style={{
|
|
68
|
-
cursor: 'pointer',
|
|
69
|
-
}}
|
|
70
|
-
onClick={handleClose}
|
|
71
|
-
width={24}
|
|
72
|
-
/>
|
|
73
|
-
) : (
|
|
74
|
-
<DialogClose
|
|
75
|
-
style={{
|
|
76
|
-
border: '0px',
|
|
77
|
-
background: 'none',
|
|
78
|
-
padding: 0,
|
|
79
|
-
height: '24px',
|
|
80
|
-
display: 'flex',
|
|
81
|
-
placeContent: 'center',
|
|
82
|
-
}}
|
|
83
|
-
>
|
|
84
|
-
<CloseIcon
|
|
85
|
-
style={{
|
|
86
|
-
cursor: 'pointer',
|
|
87
|
-
}}
|
|
88
|
-
width={24}
|
|
89
|
-
/>
|
|
90
|
-
</DialogClose>
|
|
91
|
-
)}
|
|
92
|
-
</div>
|
|
93
|
-
</div>
|
|
94
|
-
{children}
|
|
95
|
-
</div>
|
|
96
|
-
</DialogContent>
|
|
97
|
-
</Dialog>
|
|
98
|
-
);
|
|
99
|
-
};
|