@orderly.network/ui-scaffold 2.12.0 → 2.12.1
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.d.mts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +104 -64
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +106 -66
- package/dist/index.mjs.map +1 -1
- package/dist/styles.css +1 -1
- package/package.json +11 -11
package/dist/index.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React7, { forwardRef, createContext, useCallback, useRef, useEffect, useMemo, useState, cloneElement, useContext, isValidElement } from 'react';
|
|
2
2
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
3
|
-
import { installExtension, ExtensionPositionEnum, tv, Flex, Text, Tooltip, useScreen, Button, cn, modal, toast, DropdownMenuRoot, DropdownMenuTrigger, DropdownMenuPortal, DropdownMenuContent, DropdownMenuGroup, EVMAvatar, Divider, DropdownMenuItem, ChevronDownIcon, Box, PopoverRoot, PopoverAnchor, PopoverContent, SimpleDialog, Checkbox, useObserverElement, SimpleSheet, Logo, VectorIcon, PeopleIcon, SwapHorizIcon, Sheet, SheetContent, ChevronLeftIcon, Dialog, DialogContent, DialogHeader, DialogTitle, DialogBody, Spinner, ChainIcon, ScrollArea, formatAddress, Popover, Grid,
|
|
4
|
-
import { useTranslation, i18n,
|
|
3
|
+
import { installExtension, ExtensionPositionEnum, tv, Flex, Text, Tooltip, useScreen, Button, cn, modal, toast, DropdownMenuRoot, DropdownMenuTrigger, DropdownMenuPortal, DropdownMenuContent, DropdownMenuGroup, EVMAvatar, Divider, DropdownMenuItem, ChevronDownIcon, Box, PopoverRoot, PopoverAnchor, PopoverContent, SimpleDialog, Checkbox, useObserverElement, SimpleSheet, Logo, VectorIcon, PeopleIcon, SwapHorizIcon, Sheet, SheetContent, ChevronLeftIcon, Dialog, DialogContent, DialogHeader, DialogTitle, DialogBody, Spinner, ChainIcon, ScrollArea, formatAddress, CopyIcon, Popover, Grid, TextField, inputFormatter, ExtensionSlot, EyeIcon, EyeCloseIcon, SimpleDialogFooter, TooltipProvider, TooltipRoot, TooltipTrigger, BellIcon, TooltipContent, PopoverTrigger, PopupUnionIcon, CloseRoundFillIcon, SpotIcon, PerpsIcon, SelectedChoicesFillIcon } from '@orderly.network/ui';
|
|
4
|
+
import { useTranslation, i18n, useLanguageContext, Trans } from '@orderly.network/i18n';
|
|
5
5
|
import { useWalletConnector, useAccount, useChains, useLocalStorage, useConfig, useTrack, WsNetworkStatus, useIndexPricesStream, useWsStatus, useSubAccountQuery, OrderlyContext, useMemoizedFn, useCollateral, usePositionStream, useMarginRatio, useLeverage, useMaintenanceStatus, useEventEmitter } from '@orderly.network/hooks';
|
|
6
6
|
import { useAppContext, useAppConfig } from '@orderly.network/react-app';
|
|
7
7
|
import { AccountStatusEnum, ABSTRACT_CHAIN_ID_MAP, EMPTY_LIST, TrackerEventName, EMPTY_OBJECT } from '@orderly.network/types';
|
|
@@ -1232,7 +1232,7 @@ var useLanguageSwitcherScript = (options) => {
|
|
|
1232
1232
|
const [open2, setOpen] = useState(false);
|
|
1233
1233
|
const [loading, setLoading] = useState(false);
|
|
1234
1234
|
const [selectedLang, setSelectedLang] = useState(i18n.language);
|
|
1235
|
-
const { languages, onLanguageBeforeChanged, onLanguageChanged, popup } =
|
|
1235
|
+
const { languages, onLanguageBeforeChanged, onLanguageChanged, popup } = useLanguageContext();
|
|
1236
1236
|
const { track, setIdentify } = useTrack();
|
|
1237
1237
|
const { isMobile } = useScreen();
|
|
1238
1238
|
const onOpenChange = useCallback(
|
|
@@ -2332,19 +2332,15 @@ var EditIcon = forwardRef((props, ref) => {
|
|
|
2332
2332
|
}
|
|
2333
2333
|
);
|
|
2334
2334
|
});
|
|
2335
|
+
function splitAccountIdForDisplay(accountId) {
|
|
2336
|
+
return {
|
|
2337
|
+
leading: accountId.slice(0, 6),
|
|
2338
|
+
middle: accountId.slice(6, -4),
|
|
2339
|
+
trailing: accountId.slice(-4)
|
|
2340
|
+
};
|
|
2341
|
+
}
|
|
2335
2342
|
var AccountIdForCopy = (props) => {
|
|
2336
|
-
const
|
|
2337
|
-
const info = useMemo(() => {
|
|
2338
|
-
return {
|
|
2339
|
-
leading: props.accountId.slice(0, 6),
|
|
2340
|
-
middle: props.accountId.slice(6, -4),
|
|
2341
|
-
trailing: props.accountId.slice(-4)
|
|
2342
|
-
};
|
|
2343
|
-
}, [props.accountId]);
|
|
2344
|
-
const copy = useCallback(() => {
|
|
2345
|
-
navigator.clipboard.writeText(props.accountId);
|
|
2346
|
-
toast.success(t("common.copy.copied"));
|
|
2347
|
-
}, [props.accountId]);
|
|
2343
|
+
const info = splitAccountIdForDisplay(props.accountId);
|
|
2348
2344
|
return /* @__PURE__ */ jsxs(
|
|
2349
2345
|
Flex,
|
|
2350
2346
|
{
|
|
@@ -2361,7 +2357,7 @@ var AccountIdForCopy = (props) => {
|
|
|
2361
2357
|
/* @__PURE__ */ jsx(
|
|
2362
2358
|
CopyIcon,
|
|
2363
2359
|
{
|
|
2364
|
-
onClick:
|
|
2360
|
+
onClick: props.onCopy,
|
|
2365
2361
|
className: "oui-cursor-pointer oui-text-base-contrast-36 hover:oui-text-base-contrast"
|
|
2366
2362
|
}
|
|
2367
2363
|
)
|
|
@@ -2371,7 +2367,44 @@ var AccountIdForCopy = (props) => {
|
|
|
2371
2367
|
};
|
|
2372
2368
|
var AccountItem = (props) => {
|
|
2373
2369
|
const { t } = useTranslation();
|
|
2374
|
-
|
|
2370
|
+
const { isMobile } = useScreen();
|
|
2371
|
+
const {
|
|
2372
|
+
isMainAccount,
|
|
2373
|
+
accountId,
|
|
2374
|
+
description,
|
|
2375
|
+
userAddress,
|
|
2376
|
+
isCurrent,
|
|
2377
|
+
onSwitch,
|
|
2378
|
+
accountValue,
|
|
2379
|
+
onEdit
|
|
2380
|
+
} = props;
|
|
2381
|
+
const copyAccountId = useCallback(
|
|
2382
|
+
(event) => {
|
|
2383
|
+
event.stopPropagation();
|
|
2384
|
+
navigator.clipboard.writeText(accountId);
|
|
2385
|
+
toast.success(t("common.copy.copied"));
|
|
2386
|
+
},
|
|
2387
|
+
[accountId, t]
|
|
2388
|
+
);
|
|
2389
|
+
const handleSwitch = useCallback(() => {
|
|
2390
|
+
if (isCurrent) return;
|
|
2391
|
+
onSwitch?.(accountId);
|
|
2392
|
+
}, [isCurrent, onSwitch, accountId]);
|
|
2393
|
+
const handleEdit = useCallback(
|
|
2394
|
+
(event) => {
|
|
2395
|
+
event.stopPropagation();
|
|
2396
|
+
event.preventDefault();
|
|
2397
|
+
onEdit?.({
|
|
2398
|
+
accountId,
|
|
2399
|
+
description: description ?? ""
|
|
2400
|
+
});
|
|
2401
|
+
},
|
|
2402
|
+
[onEdit, accountId, description]
|
|
2403
|
+
);
|
|
2404
|
+
const stopPropagation = useCallback((event) => {
|
|
2405
|
+
event.stopPropagation();
|
|
2406
|
+
}, []);
|
|
2407
|
+
return /* @__PURE__ */ jsxs(
|
|
2375
2408
|
Flex,
|
|
2376
2409
|
{
|
|
2377
2410
|
justify: "between",
|
|
@@ -2380,69 +2413,76 @@ var AccountItem = (props) => {
|
|
|
2380
2413
|
className: cn(
|
|
2381
2414
|
"oui-relative oui-cursor-pointer oui-rounded-[6px] oui-bg-base-6 oui-px-3 oui-py-4",
|
|
2382
2415
|
"oui-border oui-border-base-6",
|
|
2383
|
-
|
|
2384
|
-
!
|
|
2416
|
+
isCurrent && "oui-border-[rgb(var(--oui-gradient-brand-start))]",
|
|
2417
|
+
!isCurrent && "hover:oui-border-base-contrast-16"
|
|
2385
2418
|
),
|
|
2386
2419
|
children: [
|
|
2387
2420
|
/* @__PURE__ */ jsx(
|
|
2388
2421
|
"div",
|
|
2389
2422
|
{
|
|
2390
|
-
className: "oui-absolute oui-inset-0 oui-z-0
|
|
2391
|
-
onClick:
|
|
2392
|
-
if (props.isCurrent) {
|
|
2393
|
-
return;
|
|
2394
|
-
}
|
|
2395
|
-
props.onSwitch?.(props.accountId);
|
|
2396
|
-
}
|
|
2423
|
+
className: "oui-absolute oui-inset-0 oui-z-0",
|
|
2424
|
+
onClick: handleSwitch
|
|
2397
2425
|
}
|
|
2398
2426
|
),
|
|
2399
|
-
|
|
2427
|
+
isCurrent && /* @__PURE__ */ jsx(
|
|
2400
2428
|
"div",
|
|
2401
2429
|
{
|
|
2402
2430
|
className: cn(
|
|
2403
2431
|
"oui-absolute -oui-right-[1px] -oui-top-[1px] oui-leading-3",
|
|
2404
2432
|
"oui-text-[10px] oui-font-semibold oui-text-base-10",
|
|
2405
|
-
"oui-rounded-[6px] oui-rounded-br-none oui-rounded-tl-none oui-bg-[rgb(var(--oui-gradient-brand-start))] oui-py-0.5 oui-pl-1
|
|
2433
|
+
"oui-rounded-[6px] oui-rounded-br-none oui-rounded-tl-none oui-bg-[rgb(var(--oui-gradient-brand-start))] oui-py-0.5 oui-pl-1 oui-pr-[5px]"
|
|
2406
2434
|
),
|
|
2407
2435
|
children: t("subAccount.modal.current")
|
|
2408
2436
|
}
|
|
2409
2437
|
),
|
|
2410
|
-
/* @__PURE__ */ jsxs(
|
|
2411
|
-
|
|
2412
|
-
|
|
2413
|
-
|
|
2414
|
-
|
|
2415
|
-
|
|
2416
|
-
|
|
2417
|
-
|
|
2418
|
-
|
|
2419
|
-
|
|
2420
|
-
{
|
|
2421
|
-
|
|
2422
|
-
|
|
2423
|
-
|
|
2424
|
-
|
|
2425
|
-
|
|
2426
|
-
|
|
2427
|
-
|
|
2428
|
-
|
|
2429
|
-
|
|
2430
|
-
|
|
2431
|
-
|
|
2432
|
-
|
|
2433
|
-
|
|
2434
|
-
|
|
2435
|
-
|
|
2436
|
-
}
|
|
2437
|
-
|
|
2438
|
-
|
|
2438
|
+
/* @__PURE__ */ jsxs(Flex, { direction: "column", itemAlign: "start", gap: 1, className: "oui-z-[2]", children: [
|
|
2439
|
+
isMainAccount ? /* @__PURE__ */ jsx(Text, { className: "oui-text-xs oui-leading-3 oui-text-base-contrast", children: formatAddress(userAddress ?? "") }) : /* @__PURE__ */ jsxs(
|
|
2440
|
+
Flex,
|
|
2441
|
+
{
|
|
2442
|
+
justify: "start",
|
|
2443
|
+
itemAlign: "center",
|
|
2444
|
+
className: "oui-cursor-pointer oui-gap-[2px] oui-fill-base-contrast-54 hover:oui-fill-base-contrast",
|
|
2445
|
+
onClick: handleEdit,
|
|
2446
|
+
children: [
|
|
2447
|
+
/* @__PURE__ */ jsx(Text, { className: "oui-text-xs oui-leading-3 oui-text-base-contrast", children: description }),
|
|
2448
|
+
/* @__PURE__ */ jsx(EditIcon, { className: "oui-fill-base-contrast-54 hover:oui-fill-base-contrast" })
|
|
2449
|
+
]
|
|
2450
|
+
}
|
|
2451
|
+
),
|
|
2452
|
+
isMobile ? /* @__PURE__ */ jsxs(
|
|
2453
|
+
Flex,
|
|
2454
|
+
{
|
|
2455
|
+
justify: "start",
|
|
2456
|
+
itemAlign: "center",
|
|
2457
|
+
gap: 1,
|
|
2458
|
+
className: "oui-w-full",
|
|
2459
|
+
onClick: stopPropagation,
|
|
2460
|
+
children: [
|
|
2461
|
+
/* @__PURE__ */ jsxs(Text, { className: "oui-text-2xs oui-leading-3 oui-text-base-contrast-36", children: [
|
|
2462
|
+
"ID: ",
|
|
2463
|
+
formatAddress(accountId)
|
|
2464
|
+
] }),
|
|
2465
|
+
/* @__PURE__ */ jsx(
|
|
2466
|
+
CopyIcon,
|
|
2467
|
+
{
|
|
2468
|
+
size: 12,
|
|
2469
|
+
onClick: copyAccountId,
|
|
2470
|
+
className: "oui-shrink-0 oui-cursor-pointer oui-text-base-contrast-36 hover:oui-text-base-contrast"
|
|
2471
|
+
}
|
|
2472
|
+
)
|
|
2473
|
+
]
|
|
2474
|
+
}
|
|
2475
|
+
) : /* @__PURE__ */ jsx(
|
|
2476
|
+
Tooltip,
|
|
2477
|
+
{
|
|
2478
|
+
content: /* @__PURE__ */ jsx(AccountIdForCopy, { accountId, onCopy: copyAccountId }),
|
|
2479
|
+
children: /* @__PURE__ */ jsxs(Text, { className: "oui-text-2xs oui-leading-3 oui-text-base-contrast-36 hover:oui-text-base-contrast", children: [
|
|
2439
2480
|
"ID: ",
|
|
2440
|
-
formatAddress(
|
|
2441
|
-
] })
|
|
2442
|
-
|
|
2443
|
-
|
|
2444
|
-
|
|
2445
|
-
),
|
|
2481
|
+
formatAddress(accountId)
|
|
2482
|
+
] })
|
|
2483
|
+
}
|
|
2484
|
+
)
|
|
2485
|
+
] }),
|
|
2446
2486
|
/* @__PURE__ */ jsxs(
|
|
2447
2487
|
Flex,
|
|
2448
2488
|
{
|
|
@@ -2450,14 +2490,14 @@ var AccountItem = (props) => {
|
|
|
2450
2490
|
itemAlign: "end",
|
|
2451
2491
|
gap: 1,
|
|
2452
2492
|
children: [
|
|
2453
|
-
/* @__PURE__ */ jsx(Text.numeral, { rule: "price", dp: 2, children:
|
|
2493
|
+
/* @__PURE__ */ jsx(Text.numeral, { rule: "price", dp: 2, children: accountValue ?? 0 }),
|
|
2454
2494
|
/* @__PURE__ */ jsx(Text, { children: "USDC" })
|
|
2455
2495
|
]
|
|
2456
2496
|
}
|
|
2457
2497
|
)
|
|
2458
2498
|
]
|
|
2459
2499
|
}
|
|
2460
|
-
)
|
|
2500
|
+
);
|
|
2461
2501
|
};
|
|
2462
2502
|
var NickNameTextField = (props) => {
|
|
2463
2503
|
const { t } = useTranslation();
|
|
@@ -2741,7 +2781,7 @@ function SubAccountUI(props) {
|
|
|
2741
2781
|
if (!props.subAccounts?.length) {
|
|
2742
2782
|
return noSubAccount;
|
|
2743
2783
|
}
|
|
2744
|
-
return /* @__PURE__ */ jsx(ScrollArea, { className: "oui-custom-scrollbar oui-max-h-[
|
|
2784
|
+
return /* @__PURE__ */ jsx(ScrollArea, { className: "oui-custom-scrollbar oui-max-h-[205px] oui-w-full oui-overflow-y-auto", children: /* @__PURE__ */ jsx(Flex, { direction: "column", gap: 2, itemAlign: "start", width: "100%", children: props.subAccounts.map((subAccount) => /* @__PURE__ */ jsx(
|
|
2745
2785
|
AccountItem,
|
|
2746
2786
|
{
|
|
2747
2787
|
accountId: subAccount.id,
|