@agg-market/ui 6.0.0 → 7.0.0

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.
Files changed (81) hide show
  1. package/README.md +17 -2
  2. package/dist/{chunk-LMOJKJOY.mjs → chunk-6I474QXG.mjs} +319 -199
  3. package/dist/{chunk-5ZKPBMRK.mjs → chunk-AVHMI47G.mjs} +18 -20
  4. package/dist/{chunk-ADGL6RFX.mjs → chunk-EEQPPN7N.mjs} +1 -1
  5. package/dist/{chunk-UBBOLLOS.mjs → chunk-EERL6BZF.mjs} +2 -4
  6. package/dist/{chunk-G6YKGVQR.mjs → chunk-KQKLLL4D.mjs} +15 -54
  7. package/dist/{chunk-2ICOSP7N.mjs → chunk-L5U7RGJV.mjs} +5 -5
  8. package/dist/{chunk-HI4EEDN5.mjs → chunk-MUB7NYWZ.mjs} +799 -228
  9. package/dist/chunk-OAJBTVZT.mjs +119 -0
  10. package/dist/{chunk-JE3Z52FD.mjs → chunk-OVQVAUAI.mjs} +110 -35
  11. package/dist/{chunk-CN7GI2RJ.mjs → chunk-ZYUJ7YEJ.mjs} +68 -8
  12. package/dist/events.js +1364 -771
  13. package/dist/events.mjs +4 -5
  14. package/dist/index.js +2353 -1541
  15. package/dist/index.mjs +597 -19
  16. package/dist/modals.js +1058 -651
  17. package/dist/modals.mjs +3 -4
  18. package/dist/pages.js +1717 -1055
  19. package/dist/pages.mjs +7 -7
  20. package/dist/primitives.js +936 -336
  21. package/dist/primitives.mjs +25 -11
  22. package/dist/styles.css +1 -1
  23. package/dist/tailwind.css +1 -1
  24. package/dist/trading.js +994 -512
  25. package/dist/trading.mjs +4 -4
  26. package/dist/types/auth/connect-button-view/connect-button-view.constants.d.mts +31 -0
  27. package/dist/types/auth/connect-button-view/connect-button-view.constants.d.ts +31 -0
  28. package/dist/types/auth/connect-button-view/connect-button-view.types.d.mts +83 -0
  29. package/dist/types/auth/connect-button-view/connect-button-view.types.d.ts +83 -0
  30. package/dist/types/auth/connect-button-view/index.d.mts +7 -0
  31. package/dist/types/auth/connect-button-view/index.d.ts +7 -0
  32. package/dist/types/auth/index.d.mts +1 -1
  33. package/dist/types/auth/index.d.ts +1 -1
  34. package/dist/types/index.d.mts +1 -1
  35. package/dist/types/index.d.ts +1 -1
  36. package/dist/types/primitives/chart/chart-type-switch.d.mts +10 -0
  37. package/dist/types/primitives/chart/chart-type-switch.d.ts +10 -0
  38. package/dist/types/primitives/chart/index.d.mts +7 -1
  39. package/dist/types/primitives/chart/index.d.ts +7 -1
  40. package/dist/types/primitives/icon/index.d.mts +8 -1
  41. package/dist/types/primitives/icon/index.d.ts +8 -1
  42. package/dist/types/primitives/icon/registry.d.mts +28 -0
  43. package/dist/types/primitives/icon/registry.d.ts +28 -0
  44. package/dist/types/primitives/icon/svg/apple.d.mts +5 -0
  45. package/dist/types/primitives/icon/svg/apple.d.ts +5 -0
  46. package/dist/types/primitives/icon/svg/chart-candlestick.d.mts +5 -0
  47. package/dist/types/primitives/icon/svg/chart-candlestick.d.ts +5 -0
  48. package/dist/types/primitives/icon/svg/chart-line.d.mts +5 -0
  49. package/dist/types/primitives/icon/svg/chart-line.d.ts +5 -0
  50. package/dist/types/primitives/icon/svg/error-filled.d.mts +5 -0
  51. package/dist/types/primitives/icon/svg/error-filled.d.ts +5 -0
  52. package/dist/types/primitives/icon/svg/ethereum.d.mts +5 -0
  53. package/dist/types/primitives/icon/svg/ethereum.d.ts +5 -0
  54. package/dist/types/primitives/icon/svg/google.d.mts +5 -0
  55. package/dist/types/primitives/icon/svg/google.d.ts +5 -0
  56. package/dist/types/primitives/icon/svg/solana.d.mts +5 -0
  57. package/dist/types/primitives/icon/svg/solana.d.ts +5 -0
  58. package/dist/types/primitives/index.d.mts +1 -0
  59. package/dist/types/primitives/index.d.ts +1 -0
  60. package/dist/types/primitives/inline-alert/index.d.mts +16 -0
  61. package/dist/types/primitives/inline-alert/index.d.ts +16 -0
  62. package/dist/types/primitives/venue-logo/svg/logo-limitless.d.mts +5 -0
  63. package/dist/types/primitives/venue-logo/svg/logo-limitless.d.ts +5 -0
  64. package/dist/types/primitives/venue-logo/venue-logo.types.d.mts +1 -1
  65. package/dist/types/primitives/venue-logo/venue-logo.types.d.ts +1 -1
  66. package/dist/types/trading/types.d.mts +26 -26
  67. package/dist/types/trading/types.d.ts +26 -26
  68. package/package.json +3 -15
  69. package/dist/auth.d.mts +0 -1
  70. package/dist/auth.d.ts +0 -1
  71. package/dist/auth.js +0 -2290
  72. package/dist/auth.mjs +0 -8
  73. package/dist/chunk-INRG3D4M.mjs +0 -450
  74. package/dist/chunk-MHCHR65A.mjs +0 -165
  75. package/dist/chunk-PASXFYKQ.mjs +0 -81
  76. package/dist/types/auth/connect-button/connect-button.constants.d.mts +0 -10
  77. package/dist/types/auth/connect-button/connect-button.constants.d.ts +0 -10
  78. package/dist/types/auth/connect-button/connect-button.types.d.mts +0 -33
  79. package/dist/types/auth/connect-button/connect-button.types.d.ts +0 -33
  80. package/dist/types/auth/connect-button/index.d.mts +0 -7
  81. package/dist/types/auth/connect-button/index.d.ts +0 -7
package/dist/auth.mjs DELETED
@@ -1,8 +0,0 @@
1
- import {
2
- ConnectButton
3
- } from "./chunk-INRG3D4M.mjs";
4
- import "./chunk-PASXFYKQ.mjs";
5
- import "./chunk-HI4EEDN5.mjs";
6
- export {
7
- ConnectButton
8
- };
@@ -1,450 +0,0 @@
1
- import {
2
- LoadingIcon
3
- } from "./chunk-PASXFYKQ.mjs";
4
- import {
5
- AGG_ROOT_CLASS_NAME,
6
- Button,
7
- Icon,
8
- VenueLogo,
9
- __spreadProps,
10
- __spreadValues,
11
- cn,
12
- formatUsd,
13
- getMotionClassName,
14
- shortenAddress
15
- } from "./chunk-HI4EEDN5.mjs";
16
-
17
- // src/auth/connect-button/index.tsx
18
- import { useEffect, useMemo, useRef, useState } from "react";
19
- import * as DropdownMenu from "@radix-ui/react-dropdown-menu";
20
- import { isAddress } from "viem";
21
- import { useAccount, useConnect, useDisconnect, useSignMessage } from "wagmi";
22
- import {
23
- getWalletAddressFromUserProfile,
24
- useAggAuth,
25
- useAggBalanceState,
26
- useLabels,
27
- useSdkUiConfig
28
- } from "@agg-market/hooks";
29
-
30
- // src/auth/connect-button/connect-button.constants.ts
31
- var connectButtonContainerClassName = cn(
32
- "inline-flex flex-col items-start gap-2 font-agg-sans"
33
- );
34
- var connectedButtonsRowClassName = cn("inline-flex h-10 items-center gap-2");
35
- var connectedBalanceChipClassName = cn(
36
- "inline-flex h-10 items-center gap-3 rounded-agg-full border border-agg-separator bg-agg-secondary pl-3 pr-12 font-agg-sans"
37
- );
38
- var connectedProfileChipClassName = cn(
39
- "-ml-12",
40
- "inline-flex h-10 items-center gap-3 rounded-agg-full border border-agg-separator bg-agg-secondary pl-2 pr-3 font-agg-sans",
41
- "cursor-pointer hover:bg-agg-secondary-hover",
42
- "focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-agg-primary-hover focus-visible:ring-offset-2 focus-visible:ring-offset-agg-secondary"
43
- );
44
- var profileMenuContentClassName = cn(
45
- "z-50 w-64 overflow-hidden rounded-agg-xl font-agg-sans",
46
- "border border-agg-separator bg-agg-secondary",
47
- "shadow-agg-popover"
48
- );
49
- var profileMenuSectionClassName = cn("flex w-full flex-col gap-5 px-5 py-5");
50
- var profileMenuSeparatorClassName = cn("h-px w-full bg-agg-separator");
51
- var profileMenuActionItemClassName = cn(
52
- "flex w-full items-center gap-3 px-5 py-4 font-agg-sans text-agg-sm leading-agg-5 text-agg-foreground",
53
- "outline-none",
54
- "hover:bg-agg-secondary-hover focus:bg-agg-secondary-hover"
55
- );
56
- var avatarRootClassName = cn(
57
- "inline-flex size-6 shrink-0 items-center justify-center rounded-agg-full bg-agg-separator"
58
- );
59
- var avatarIconClassName = cn("h-[66%] w-[66%] text-agg-muted-foreground");
60
-
61
- // src/auth/connect-button/index.tsx
62
- import { Fragment, jsx, jsxs } from "react/jsx-runtime";
63
- var venueLogoNameSet = /* @__PURE__ */ new Set([
64
- "polymarket",
65
- "kalshi",
66
- "opinion",
67
- "probable"
68
- ]);
69
- var toVenueLogoName = (value) => {
70
- if (!venueLogoNameSet.has(value))
71
- return null;
72
- return value;
73
- };
74
- function WalletAvatar({ className }) {
75
- return /* @__PURE__ */ jsx("span", { "aria-hidden": "true", className: cn(avatarRootClassName, className), children: /* @__PURE__ */ jsx(Icon, { className: avatarIconClassName, name: "wallet-avatar" }) });
76
- }
77
- var ConnectButton = ({
78
- autoSignInOnConnect = true,
79
- buttonProps,
80
- classNames,
81
- disabled,
82
- onConnect,
83
- onDepositClick,
84
- onDisconnect,
85
- onProfileClick,
86
- onViewAllBalancesClick,
87
- onWithdrawClick
88
- }) => {
89
- var _a, _b;
90
- const [isProfileMenuOpen, setIsProfileMenuOpen] = useState(false);
91
- const autoSignInAttemptRef = useRef(null);
92
- const { enableAnimations, rootClassName } = useSdkUiConfig();
93
- const labels = useLabels();
94
- const { address: walletAddress, chainId, isConnected: isWalletConnected } = useAccount();
95
- const { connect, connectors, isPending: isConnectPending } = useConnect();
96
- const { disconnect } = useDisconnect();
97
- const { signMessageAsync } = useSignMessage();
98
- const {
99
- totalBalance,
100
- balanceBreakdown,
101
- connectedVenues,
102
- isLoading: isBalanceLoading,
103
- error: balanceError
104
- } = useAggBalanceState();
105
- const preferredConnector = useMemo(() => {
106
- var _a2;
107
- return (_a2 = connectors.find((connector) => connector.name === "MetaMask")) != null ? _a2 : connectors[0];
108
- }, [connectors]);
109
- const signInStatement = labels.auth.signInStatement;
110
- const { signIn, signOut, isAuthenticated, user, isLoading, error } = useAggAuth({
111
- signMessage: (message) => signMessageAsync({ message }),
112
- address: walletAddress != null ? walletAddress : "",
113
- chainId
114
- });
115
- const resolvedWalletAddress = (_b = (_a = getWalletAddressFromUserProfile(user)) != null ? _a : walletAddress) != null ? _b : "";
116
- const resolvedAddressLabel = shortenAddress(resolvedWalletAddress);
117
- const resolvedProfileLabel = resolvedAddressLabel;
118
- const resolvedBalanceRows = useMemo(() => {
119
- const balancesByVenue = /* @__PURE__ */ new Map();
120
- for (const balanceItem of balanceBreakdown) {
121
- balancesByVenue.set(balanceItem.venue, balanceItem.balance);
122
- }
123
- for (const venue of connectedVenues) {
124
- if (!balancesByVenue.has(venue)) {
125
- balancesByVenue.set(venue, 0);
126
- }
127
- }
128
- return Array.from(balancesByVenue.entries()).map(([venue, balanceValue]) => {
129
- var _a2;
130
- return {
131
- key: venue,
132
- label: (_a2 = labels.venues[venue]) != null ? _a2 : venue,
133
- amountLabel: formatUsd(balanceValue),
134
- venue: toVenueLogoName(venue)
135
- };
136
- });
137
- }, [balanceBreakdown, connectedVenues, labels.venues]);
138
- const errorText = error ? `Error: ${error.message}` : null;
139
- const balanceErrorText = balanceError ? `Error: ${balanceError.message}` : null;
140
- const resolvedErrorText = errorText != null ? errorText : balanceErrorText;
141
- const normalizedWalletAddress = (walletAddress != null ? walletAddress : "").toLowerCase();
142
- const hasWalletAddress = isAddress(walletAddress != null ? walletAddress : "");
143
- const isConnectDisabled = disabled || isConnectPending || !preferredConnector;
144
- const dropdownMenuItemClassName = cn(
145
- "cursor-pointer",
146
- profileMenuActionItemClassName,
147
- getMotionClassName(enableAnimations, "transition-colors"),
148
- disabled ? "pointer-events-none opacity-50" : null,
149
- classNames == null ? void 0 : classNames.profileMenuActionItem
150
- );
151
- useEffect(() => {
152
- if (!autoSignInOnConnect) {
153
- autoSignInAttemptRef.current = null;
154
- return;
155
- }
156
- if (!isWalletConnected || isAuthenticated || isLoading || !hasWalletAddress) {
157
- if (!isWalletConnected || isAuthenticated) {
158
- autoSignInAttemptRef.current = null;
159
- }
160
- return;
161
- }
162
- const attemptKey = `${normalizedWalletAddress}:${chainId != null ? chainId : "unknown"}`;
163
- if (autoSignInAttemptRef.current === attemptKey)
164
- return;
165
- autoSignInAttemptRef.current = attemptKey;
166
- void signIn(signInStatement).catch(() => void 0);
167
- }, [
168
- autoSignInOnConnect,
169
- chainId,
170
- hasWalletAddress,
171
- isAuthenticated,
172
- isLoading,
173
- isWalletConnected,
174
- normalizedWalletAddress,
175
- signIn,
176
- signInStatement
177
- ]);
178
- const handleConnectClick = () => {
179
- if (isConnectDisabled || !preferredConnector)
180
- return;
181
- connect({ connector: preferredConnector });
182
- if (!onConnect)
183
- return;
184
- void Promise.resolve(onConnect());
185
- };
186
- const handleSignInClick = () => {
187
- if (disabled || isLoading || !hasWalletAddress)
188
- return;
189
- void signIn(signInStatement);
190
- };
191
- const handleDepositClick = () => {
192
- if (disabled)
193
- return;
194
- if (!onDepositClick)
195
- return;
196
- void Promise.resolve(onDepositClick());
197
- };
198
- const handleProfileItemClick = () => {
199
- if (disabled)
200
- return;
201
- if (!onProfileClick)
202
- return;
203
- void Promise.resolve(onProfileClick());
204
- };
205
- const handleWithdrawClick = () => {
206
- if (disabled)
207
- return;
208
- if (!onWithdrawClick)
209
- return;
210
- void Promise.resolve(onWithdrawClick());
211
- };
212
- const handleViewAllBalancesClick = () => {
213
- if (disabled)
214
- return;
215
- if (!onViewAllBalancesClick)
216
- return;
217
- void Promise.resolve(onViewAllBalancesClick());
218
- };
219
- const handleDisconnectClick = () => {
220
- if (disabled)
221
- return;
222
- signOut();
223
- disconnect();
224
- if (!onDisconnect)
225
- return;
226
- void Promise.resolve(onDisconnect());
227
- };
228
- const handleProfileMenuOpenChange = (open) => {
229
- if (disabled)
230
- return;
231
- setIsProfileMenuOpen(open);
232
- };
233
- if (resolvedErrorText) {
234
- console.error({ resolvedErrorText });
235
- }
236
- if (!isWalletConnected) {
237
- return /* @__PURE__ */ jsx("div", { className: cn(connectButtonContainerClassName, classNames == null ? void 0 : classNames.root), children: /* @__PURE__ */ jsx(
238
- Button,
239
- __spreadProps(__spreadValues({
240
- variant: "primary",
241
- size: "large",
242
- className: classNames == null ? void 0 : classNames.connectButton,
243
- onClick: handleConnectClick,
244
- disabled: isConnectDisabled,
245
- "aria-label": labels.auth.connect(preferredConnector == null ? void 0 : preferredConnector.name)
246
- }, buttonProps), {
247
- children: labels.auth.connect(preferredConnector == null ? void 0 : preferredConnector.name)
248
- })
249
- ) });
250
- }
251
- if (!isAuthenticated) {
252
- return /* @__PURE__ */ jsx("div", { className: cn(connectButtonContainerClassName, classNames == null ? void 0 : classNames.root), children: /* @__PURE__ */ jsx(
253
- Button,
254
- __spreadProps(__spreadValues({
255
- variant: "primary",
256
- size: "large",
257
- className: classNames == null ? void 0 : classNames.signInButton,
258
- onClick: handleSignInClick,
259
- disabled: disabled || !hasWalletAddress,
260
- isLoading,
261
- "aria-label": isLoading ? labels.auth.signingIn : labels.auth.signIn
262
- }, buttonProps), {
263
- children: isLoading ? labels.auth.signingIn : labels.auth.signIn
264
- })
265
- ) });
266
- }
267
- return /* @__PURE__ */ jsx("div", { className: cn(connectButtonContainerClassName, classNames == null ? void 0 : classNames.root), children: /* @__PURE__ */ jsxs("div", { className: cn(connectedButtonsRowClassName, classNames == null ? void 0 : classNames.connectedRow), children: [
268
- /* @__PURE__ */ jsxs("div", { className: cn(connectedBalanceChipClassName, classNames == null ? void 0 : classNames.balanceChip), children: [
269
- /* @__PURE__ */ jsx(
270
- Button,
271
- {
272
- variant: "primary",
273
- size: "small",
274
- className: cn("h-6 px-3 text-agg-xs leading-agg-4", classNames == null ? void 0 : classNames.depositButton),
275
- onClick: handleDepositClick,
276
- disabled,
277
- "aria-label": labels.auth.deposit,
278
- children: labels.auth.deposit
279
- }
280
- ),
281
- /* @__PURE__ */ jsx("p", { className: cn("agg-type-label text-agg-foreground", classNames == null ? void 0 : classNames.balanceText), children: isBalanceLoading ? /* @__PURE__ */ jsx(LoadingIcon, { size: "small" }) : formatUsd(totalBalance) })
282
- ] }),
283
- /* @__PURE__ */ jsxs(DropdownMenu.Root, { open: isProfileMenuOpen, onOpenChange: handleProfileMenuOpenChange, children: [
284
- /* @__PURE__ */ jsx(DropdownMenu.Trigger, { asChild: true, children: /* @__PURE__ */ jsxs(
285
- "button",
286
- {
287
- type: "button",
288
- className: cn(
289
- connectedProfileChipClassName,
290
- getMotionClassName(enableAnimations, "transition-colors"),
291
- classNames == null ? void 0 : classNames.profileTrigger
292
- ),
293
- disabled,
294
- "aria-label": labels.auth.walletMenuFor(resolvedProfileLabel),
295
- children: [
296
- /* @__PURE__ */ jsx(WalletAvatar, {}),
297
- /* @__PURE__ */ jsx(
298
- "span",
299
- {
300
- className: cn(
301
- "agg-type-body-strong text-agg-foreground",
302
- classNames == null ? void 0 : classNames.profileTriggerLabel
303
- ),
304
- children: resolvedProfileLabel
305
- }
306
- ),
307
- /* @__PURE__ */ jsx(
308
- Icon,
309
- {
310
- name: isProfileMenuOpen ? "chevron-up" : "chevron-down",
311
- size: "small",
312
- className: "h-3.5 w-3.5 text-agg-foreground",
313
- "aria-hidden": "true"
314
- }
315
- )
316
- ]
317
- }
318
- ) }),
319
- /* @__PURE__ */ jsx(DropdownMenu.Portal, { children: /* @__PURE__ */ jsxs(
320
- DropdownMenu.Content,
321
- {
322
- className: cn(
323
- AGG_ROOT_CLASS_NAME,
324
- rootClassName,
325
- profileMenuContentClassName,
326
- classNames == null ? void 0 : classNames.profileMenuContent
327
- ),
328
- "data-agg-animations": enableAnimations ? "true" : "false",
329
- sideOffset: 4,
330
- align: "end",
331
- children: [
332
- /* @__PURE__ */ jsx(
333
- "div",
334
- {
335
- className: cn(
336
- profileMenuSectionClassName,
337
- "cursor-pointer",
338
- classNames == null ? void 0 : classNames.profileMenuSection
339
- ),
340
- onClick: handleProfileItemClick,
341
- children: /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-3", children: [
342
- /* @__PURE__ */ jsx(WalletAvatar, { className: "size-11" }),
343
- /* @__PURE__ */ jsxs("div", { className: "flex flex-col items-start gap-0.5", children: [
344
- /* @__PURE__ */ jsx("p", { className: "text-agg-lg font-agg-bold leading-agg-7 text-agg-foreground", children: resolvedProfileLabel }),
345
- /* @__PURE__ */ jsx("p", { className: "text-agg-sm font-agg-normal leading-agg-5 text-agg-muted-foreground", children: resolvedAddressLabel })
346
- ] })
347
- ] })
348
- }
349
- ),
350
- /* @__PURE__ */ jsx(
351
- "div",
352
- {
353
- className: cn(profileMenuSeparatorClassName, classNames == null ? void 0 : classNames.profileMenuSeparator)
354
- }
355
- ),
356
- /* @__PURE__ */ jsxs("div", { className: cn(profileMenuSectionClassName, classNames == null ? void 0 : classNames.profileMenuSection), children: [
357
- isBalanceLoading ? /* @__PURE__ */ jsxs("p", { className: "flex flex-col gap-2 items-center justify-center text-agg-sm font-agg-normal leading-agg-5 text-agg-muted-foreground", children: [
358
- /* @__PURE__ */ jsx(LoadingIcon, {}),
359
- labels.auth.loadingBalances
360
- ] }) : /* @__PURE__ */ jsx(Fragment, { children: resolvedBalanceRows.length === 0 ? /* @__PURE__ */ jsxs("p", { className: "flex flex-col gap-2 items-center justify-center text-agg-sm font-agg-normal leading-agg-5 text-agg-muted-foreground", children: [
361
- /* @__PURE__ */ jsx(Icon, { name: "warning", className: "text-agg-primary" }),
362
- labels.auth.noBalances
363
- ] }) : /* @__PURE__ */ jsxs("div", { className: "flex w-full items-center justify-between", children: [
364
- /* @__PURE__ */ jsx("p", { className: "text-agg-xs font-agg-bold uppercase leading-agg-4 tracking-agg-normal text-agg-muted-foreground", children: labels.auth.balances }),
365
- /* @__PURE__ */ jsx(
366
- Button,
367
- {
368
- variant: "tertiary",
369
- size: "small",
370
- className: "h-6 px-3 text-agg-xs leading-agg-4",
371
- onClick: handleViewAllBalancesClick,
372
- children: labels.auth.viewAll
373
- }
374
- )
375
- ] }) }),
376
- !isBalanceLoading ? resolvedBalanceRows.map((row) => /* @__PURE__ */ jsxs("div", { className: "flex w-full items-center justify-between", children: [
377
- /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-1.5", children: [
378
- row.venue ? /* @__PURE__ */ jsx(VenueLogo, { venue: row.venue, size: "small" }) : null,
379
- /* @__PURE__ */ jsx("p", { className: "text-agg-sm font-agg-normal leading-agg-5 text-agg-foreground", children: row.label })
380
- ] }),
381
- /* @__PURE__ */ jsx("p", { className: "text-agg-sm font-agg-bold leading-agg-5 text-agg-foreground", children: row.amountLabel })
382
- ] }, row.key)) : null
383
- ] }),
384
- /* @__PURE__ */ jsx(
385
- "div",
386
- {
387
- className: cn(profileMenuSeparatorClassName, classNames == null ? void 0 : classNames.profileMenuSeparator)
388
- }
389
- ),
390
- /* @__PURE__ */ jsxs("div", { className: "flex w-full flex-col py-2", children: [
391
- /* @__PURE__ */ jsxs(
392
- DropdownMenu.Item,
393
- {
394
- className: dropdownMenuItemClassName,
395
- onSelect: handleProfileItemClick,
396
- disabled,
397
- children: [
398
- /* @__PURE__ */ jsx(Icon, { name: "profile", size: "small", className: "text-agg-foreground" }),
399
- /* @__PURE__ */ jsx("span", { children: labels.auth.myProfile })
400
- ]
401
- }
402
- ),
403
- /* @__PURE__ */ jsxs(
404
- DropdownMenu.Item,
405
- {
406
- className: dropdownMenuItemClassName,
407
- onSelect: handleDepositClick,
408
- disabled,
409
- children: [
410
- /* @__PURE__ */ jsx(Icon, { name: "download", size: "small", className: "text-agg-foreground" }),
411
- /* @__PURE__ */ jsx("span", { children: labels.auth.deposit })
412
- ]
413
- }
414
- ),
415
- /* @__PURE__ */ jsxs(
416
- DropdownMenu.Item,
417
- {
418
- className: dropdownMenuItemClassName,
419
- onSelect: handleWithdrawClick,
420
- disabled,
421
- children: [
422
- /* @__PURE__ */ jsx(Icon, { name: "upload", size: "small", className: "text-agg-foreground" }),
423
- /* @__PURE__ */ jsx("span", { children: labels.auth.withdraw })
424
- ]
425
- }
426
- ),
427
- /* @__PURE__ */ jsxs(
428
- DropdownMenu.Item,
429
- {
430
- className: dropdownMenuItemClassName,
431
- onSelect: handleDisconnectClick,
432
- disabled,
433
- children: [
434
- /* @__PURE__ */ jsx(Icon, { name: "disconnect", size: "small", className: "text-agg-foreground" }),
435
- /* @__PURE__ */ jsx("span", { children: labels.auth.disconnect })
436
- ]
437
- }
438
- )
439
- ] })
440
- ]
441
- }
442
- ) })
443
- ] })
444
- ] }) });
445
- };
446
- ConnectButton.displayName = "ConnectButton";
447
-
448
- export {
449
- ConnectButton
450
- };
@@ -1,165 +0,0 @@
1
- import {
2
- Icon,
3
- cn,
4
- getMotionClassName
5
- } from "./chunk-HI4EEDN5.mjs";
6
-
7
- // src/primitives/select/index.tsx
8
- import { useCallback, useEffect, useRef, useState } from "react";
9
- import { useLabels, useSdkUiConfig } from "@agg-market/hooks";
10
- import { jsx, jsxs } from "react/jsx-runtime";
11
- var Select = ({
12
- items,
13
- value,
14
- onChange,
15
- ariaLabel,
16
- className,
17
- disabled = false
18
- }) => {
19
- var _a;
20
- const labels = useLabels();
21
- const { enableAnimations } = useSdkUiConfig();
22
- const hasEnabledItems = items.some((item) => !item.disabled);
23
- const hasAnyIcon = items.some((item) => item.iconUrl);
24
- const [isOpen, setIsOpen] = useState(false);
25
- const containerRef = useRef(null);
26
- const close = useCallback(() => setIsOpen(false), []);
27
- useEffect(() => {
28
- if (!isOpen)
29
- return;
30
- const handlePointerDown = (e) => {
31
- if (containerRef.current && !containerRef.current.contains(e == null ? void 0 : e.target)) {
32
- close();
33
- }
34
- };
35
- document.addEventListener("mousedown", handlePointerDown);
36
- return () => document.removeEventListener("mousedown", handlePointerDown);
37
- }, [isOpen, close]);
38
- useEffect(() => {
39
- if (!isOpen)
40
- return;
41
- const handleKey = (e) => {
42
- if ((e == null ? void 0 : e.key) === "Escape")
43
- close();
44
- };
45
- document.addEventListener("keydown", handleKey);
46
- return () => document.removeEventListener("keydown", handleKey);
47
- }, [isOpen, close]);
48
- const isDisabled = disabled || !hasEnabledItems;
49
- const selectedItem = items.find((item) => item.value === value);
50
- if (!hasAnyIcon) {
51
- return /* @__PURE__ */ jsxs("label", { className: cn("group/agg-select", "relative inline-flex w-full", className), children: [
52
- /* @__PURE__ */ jsx(
53
- "select",
54
- {
55
- "aria-label": ariaLabel != null ? ariaLabel : labels.common.selectAria,
56
- className: cn(
57
- "w-full appearance-none rounded-agg-md border border-agg-separator bg-agg-secondary px-4 py-2 pr-10 font-agg-sans text-agg-sm leading-agg-5 text-agg-foreground outline-none",
58
- getMotionClassName(
59
- enableAnimations,
60
- "transition-[border-color,box-shadow] duration-200 ease-in-out"
61
- ),
62
- "focus:border-agg-primary focus:ring-2 focus:ring-agg-primary/15",
63
- "disabled:cursor-not-allowed disabled:opacity-60"
64
- ),
65
- disabled: isDisabled,
66
- value,
67
- onChange: (event) => onChange(event.target.value),
68
- children: items.map((item) => /* @__PURE__ */ jsx("option", { value: item.value, disabled: item.disabled, children: item.label }, item.value))
69
- }
70
- ),
71
- /* @__PURE__ */ jsx("span", { className: "pointer-events-none absolute inset-y-0 right-3 inline-flex items-center justify-center text-agg-muted-foreground", children: /* @__PURE__ */ jsx(Icon, { name: "chevron-down", size: "small", color: "currentColor" }) })
72
- ] });
73
- }
74
- return /* @__PURE__ */ jsxs(
75
- "div",
76
- {
77
- ref: containerRef,
78
- className: cn("group/agg-select", "relative inline-flex w-full", className),
79
- children: [
80
- /* @__PURE__ */ jsxs(
81
- "button",
82
- {
83
- type: "button",
84
- "aria-label": ariaLabel != null ? ariaLabel : labels.common.selectAria,
85
- "aria-expanded": isOpen,
86
- "aria-haspopup": "listbox",
87
- disabled: isDisabled,
88
- className: cn(
89
- "w-full rounded-agg-md border border-agg-separator bg-agg-secondary px-4 py-2 pr-10 font-agg-sans text-agg-sm leading-agg-5 text-agg-foreground outline-none",
90
- "flex items-center gap-2 text-left",
91
- getMotionClassName(
92
- enableAnimations,
93
- "transition-[border-color,box-shadow] duration-200 ease-in-out"
94
- ),
95
- "focus:border-agg-primary focus:ring-2 focus:ring-agg-primary/15",
96
- "disabled:cursor-not-allowed disabled:opacity-60"
97
- ),
98
- onClick: () => setIsOpen((prev) => !prev),
99
- children: [
100
- (selectedItem == null ? void 0 : selectedItem.iconUrl) ? /* @__PURE__ */ jsx(
101
- "img",
102
- {
103
- src: selectedItem.iconUrl,
104
- alt: "",
105
- className: "h-4 w-4 shrink-0 rounded-sm object-contain"
106
- }
107
- ) : null,
108
- /* @__PURE__ */ jsx("span", { className: "flex-1 truncate", children: (_a = selectedItem == null ? void 0 : selectedItem.label) != null ? _a : "" })
109
- ]
110
- }
111
- ),
112
- /* @__PURE__ */ jsx("span", { className: "pointer-events-none absolute inset-y-0 right-3 inline-flex items-center justify-center text-agg-muted-foreground", children: /* @__PURE__ */ jsx(Icon, { name: "chevron-down", size: "small", color: "currentColor" }) }),
113
- isOpen ? /* @__PURE__ */ jsx(
114
- "div",
115
- {
116
- role: "listbox",
117
- "aria-label": ariaLabel != null ? ariaLabel : labels.common.selectAria,
118
- className: "absolute top-full left-0 z-50 mt-1 w-full overflow-hidden rounded-agg-md border border-agg-separator bg-agg-secondary shadow-lg",
119
- children: items.map((item) => {
120
- const isSelected = item.value === value;
121
- return /* @__PURE__ */ jsxs(
122
- "button",
123
- {
124
- type: "button",
125
- role: "option",
126
- "aria-selected": isSelected,
127
- disabled: item.disabled,
128
- className: cn(
129
- "flex w-full items-center gap-2 px-4 py-2 text-left text-agg-sm leading-agg-5 outline-none",
130
- "hover:bg-agg-secondary-hover focus-visible:bg-agg-secondary-hover",
131
- isSelected ? "font-agg-bold text-agg-primary" : "font-agg-normal text-agg-foreground",
132
- item.disabled && "cursor-not-allowed opacity-60"
133
- ),
134
- onClick: () => {
135
- if (!item.disabled) {
136
- onChange(item.value);
137
- close();
138
- }
139
- },
140
- children: [
141
- item.iconUrl ? /* @__PURE__ */ jsx(
142
- "img",
143
- {
144
- src: item.iconUrl,
145
- alt: "",
146
- className: "h-4 w-4 shrink-0 rounded-sm object-contain"
147
- }
148
- ) : null,
149
- /* @__PURE__ */ jsx("span", { className: "truncate", children: item.label })
150
- ]
151
- },
152
- item.value
153
- );
154
- })
155
- }
156
- ) : null
157
- ]
158
- }
159
- );
160
- };
161
- Select.displayName = "Select";
162
-
163
- export {
164
- Select
165
- };