@orderly.network/ui-positions 2.11.1 → 2.11.2-alpha.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.
- package/dist/index.js +106 -75
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +107 -76
- package/dist/index.mjs.map +1 -1
- package/package.json +13 -13
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { registerSimpleDialog, registerSimpleSheet, useModal, SimpleDialog, useScreen, Flex, Text, Badge, Divider, toast, modal, CloseIcon, Button, ThrottledButton, ArrowDownShortIcon, ArrowUpShortIcon, IconButton, TokenIcon, cn, Input, inputFormatter, Slider, Statistic, Grid, ExclamationFillIcon, Tooltip, DataTable, ListView, SimpleSheet, usePagination, DataFilter, PopoverRoot, PopoverTrigger, PopoverContent, Checkbox, formatAddress, Box, HoverCard, AddCircleIcon, ChevronRightIcon, ArrowLeftRightIcon, capitalizeFirstLetter, ShareIcon, EditIcon, Select
|
|
1
|
+
import { registerSimpleDialog, registerSimpleSheet, useModal, SimpleDialog, useScreen, Flex, Text, Badge, Divider, toast, modal, CloseIcon, Button, ThrottledButton, ArrowDownShortIcon, ArrowUpShortIcon, IconButton, TokenIcon, cn, Input, inputFormatter, Slider, Statistic, Grid, ExclamationFillIcon, Tooltip, DataTable, ListView, SimpleSheet, usePagination, DataFilter, PopoverRoot, PopoverTrigger, PopoverContent, Checkbox, formatAddress, Box, HoverCard, AddCircleIcon, Tips, ChevronRightIcon, ArrowLeftRightIcon, capitalizeFirstLetter, ShareIcon, EditIcon, Select } from '@orderly.network/ui';
|
|
2
2
|
import React2, { createContext, useMemo, useState, useCallback, useContext, useEffect, useRef } from 'react';
|
|
3
3
|
import { i18n, useTranslation } from '@orderly.network/i18n';
|
|
4
4
|
import { OrderSide, MarginMode, OrderType, EMPTY_LIST, AccountStatusEnum, TrackerEventName, OrderStatus, AlgoOrderRootType, PositionType, AlgoOrderType } from '@orderly.network/types';
|
|
@@ -1587,16 +1587,19 @@ var RwaStatusTag = ({ symbol }) => {
|
|
|
1587
1587
|
return null;
|
|
1588
1588
|
}
|
|
1589
1589
|
return /* @__PURE__ */ jsx(
|
|
1590
|
-
|
|
1590
|
+
Tips,
|
|
1591
1591
|
{
|
|
1592
|
-
|
|
1593
|
-
|
|
1594
|
-
|
|
1595
|
-
|
|
1596
|
-
|
|
1597
|
-
|
|
1598
|
-
|
|
1599
|
-
|
|
1592
|
+
title: t("common.tips"),
|
|
1593
|
+
content: /* @__PURE__ */ jsx(Text, { color: open ? "success" : "danger", children: open ? t("trading.rwa.marketHours") : t("trading.rwa.outsideMarketHours") }),
|
|
1594
|
+
trigger: /* @__PURE__ */ jsx(Box, { p: 2, className: "oui-flex oui-cursor-pointer oui-items-center", children: /* @__PURE__ */ jsx(
|
|
1595
|
+
Box,
|
|
1596
|
+
{
|
|
1597
|
+
width: 4,
|
|
1598
|
+
height: 4,
|
|
1599
|
+
r: "full",
|
|
1600
|
+
className: cn(open ? "oui-bg-success" : "oui-bg-danger")
|
|
1601
|
+
}
|
|
1602
|
+
) })
|
|
1600
1603
|
}
|
|
1601
1604
|
);
|
|
1602
1605
|
};
|
|
@@ -3463,11 +3466,11 @@ var useColumn = (config) => {
|
|
|
3463
3466
|
title: t("common.symbol"),
|
|
3464
3467
|
dataIndex: "symbol",
|
|
3465
3468
|
fixed: "left",
|
|
3466
|
-
width:
|
|
3469
|
+
width: 176,
|
|
3467
3470
|
onSort: (r1, r2) => {
|
|
3468
3471
|
return r1.symbol?.localeCompare(r2.symbol || "");
|
|
3469
3472
|
},
|
|
3470
|
-
render: (value, record) => /* @__PURE__ */ jsxs(Flex, { gap: 2, children: [
|
|
3473
|
+
render: (value, record) => /* @__PURE__ */ jsxs(Flex, { gap: 2, className: "oui-py-1", children: [
|
|
3471
3474
|
/* @__PURE__ */ jsx(
|
|
3472
3475
|
Box,
|
|
3473
3476
|
{
|
|
@@ -3479,32 +3482,32 @@ var useColumn = (config) => {
|
|
|
3479
3482
|
)
|
|
3480
3483
|
}
|
|
3481
3484
|
),
|
|
3482
|
-
/* @__PURE__ */ jsxs(Flex, { direction: "column", itemAlign: "start", children: [
|
|
3483
|
-
/* @__PURE__ */
|
|
3484
|
-
Text.formatted,
|
|
3485
|
-
{
|
|
3486
|
-
formatString: "base-type",
|
|
3487
|
-
className: "oui-cursor-pointer",
|
|
3488
|
-
onClick: (e) => {
|
|
3489
|
-
onSymbolChange?.({ symbol: value });
|
|
3490
|
-
e.stopPropagation();
|
|
3491
|
-
e.preventDefault();
|
|
3492
|
-
},
|
|
3493
|
-
children: `${value.split("_")[1]}-PERP`
|
|
3494
|
-
}
|
|
3495
|
-
),
|
|
3496
|
-
/* @__PURE__ */ jsxs(Flex, { gap: 1, children: [
|
|
3485
|
+
/* @__PURE__ */ jsxs(Flex, { direction: "column", itemAlign: "start", gap: 1, children: [
|
|
3486
|
+
/* @__PURE__ */ jsxs(Flex, { gap: 1, itemAlign: "center", children: [
|
|
3497
3487
|
/* @__PURE__ */ jsx(
|
|
3498
|
-
|
|
3488
|
+
Text.formatted,
|
|
3499
3489
|
{
|
|
3500
|
-
|
|
3501
|
-
|
|
3502
|
-
|
|
3503
|
-
|
|
3490
|
+
formatString: "base-type",
|
|
3491
|
+
className: "oui-cursor-pointer",
|
|
3492
|
+
onClick: (e) => {
|
|
3493
|
+
onSymbolChange?.({ symbol: value });
|
|
3494
|
+
e.stopPropagation();
|
|
3495
|
+
e.preventDefault();
|
|
3496
|
+
},
|
|
3497
|
+
children: `${value.split("_")[1]}-PERP`
|
|
3504
3498
|
}
|
|
3505
3499
|
),
|
|
3506
3500
|
/* @__PURE__ */ jsx(RwaStatusTag, { symbol: value })
|
|
3507
|
-
] })
|
|
3501
|
+
] }),
|
|
3502
|
+
/* @__PURE__ */ jsx(Flex, { gap: 1, wrap: "wrap", children: /* @__PURE__ */ jsx(
|
|
3503
|
+
LeverageBadge,
|
|
3504
|
+
{
|
|
3505
|
+
symbol: value,
|
|
3506
|
+
leverage: record.leverage,
|
|
3507
|
+
modalId: SymbolLeverageDialogId,
|
|
3508
|
+
marginMode: record.margin_mode
|
|
3509
|
+
}
|
|
3510
|
+
) })
|
|
3508
3511
|
] })
|
|
3509
3512
|
] })
|
|
3510
3513
|
},
|
|
@@ -3776,31 +3779,36 @@ var SymbolToken = (props) => {
|
|
|
3776
3779
|
const { item } = props;
|
|
3777
3780
|
const isBuy = item.position_qty > 0;
|
|
3778
3781
|
const { t } = useTranslation();
|
|
3779
|
-
return /* @__PURE__ */
|
|
3780
|
-
|
|
3781
|
-
|
|
3782
|
-
|
|
3783
|
-
|
|
3784
|
-
|
|
3785
|
-
|
|
3786
|
-
|
|
3787
|
-
|
|
3788
|
-
|
|
3789
|
-
|
|
3790
|
-
|
|
3791
|
-
|
|
3792
|
-
|
|
3793
|
-
|
|
3794
|
-
|
|
3795
|
-
|
|
3796
|
-
|
|
3797
|
-
|
|
3798
|
-
|
|
3799
|
-
|
|
3800
|
-
|
|
3801
|
-
|
|
3802
|
-
|
|
3803
|
-
|
|
3782
|
+
return /* @__PURE__ */ jsxs(Flex, { direction: "column", itemAlign: "start", gap: 1, children: [
|
|
3783
|
+
/* @__PURE__ */ jsxs(Flex, { gap: 1, itemAlign: "center", children: [
|
|
3784
|
+
/* @__PURE__ */ jsx(
|
|
3785
|
+
Text.formatted,
|
|
3786
|
+
{
|
|
3787
|
+
rule: "symbol",
|
|
3788
|
+
formatString: "base-type",
|
|
3789
|
+
size: "2xs",
|
|
3790
|
+
showIcon: true,
|
|
3791
|
+
onClick: () => {
|
|
3792
|
+
props.onSymbolChange?.({ symbol: item.symbol });
|
|
3793
|
+
},
|
|
3794
|
+
children: item.symbol
|
|
3795
|
+
}
|
|
3796
|
+
),
|
|
3797
|
+
/* @__PURE__ */ jsx(RwaStatusTag, { symbol: item.symbol })
|
|
3798
|
+
] }),
|
|
3799
|
+
/* @__PURE__ */ jsxs(Flex, { gap: 1, itemAlign: "center", wrap: "wrap", children: [
|
|
3800
|
+
/* @__PURE__ */ jsx(Badge, { color: isBuy ? "success" : "danger", size: "xs", children: isBuy ? t("common.long") : t("common.short") }),
|
|
3801
|
+
/* @__PURE__ */ jsx(
|
|
3802
|
+
LeverageBadge,
|
|
3803
|
+
{
|
|
3804
|
+
symbol: item.symbol,
|
|
3805
|
+
leverage: item.leverage,
|
|
3806
|
+
modalId: SymbolLeverageSheetId,
|
|
3807
|
+
marginMode: item.margin_mode
|
|
3808
|
+
}
|
|
3809
|
+
)
|
|
3810
|
+
] })
|
|
3811
|
+
] });
|
|
3804
3812
|
};
|
|
3805
3813
|
var UnrealPnL = (props) => {
|
|
3806
3814
|
const { item } = props;
|
|
@@ -4439,7 +4447,7 @@ var usePositionHistoryColumn = (props) => {
|
|
|
4439
4447
|
title: t("common.symbol"),
|
|
4440
4448
|
dataIndex: "symbol",
|
|
4441
4449
|
fixed: "left",
|
|
4442
|
-
width:
|
|
4450
|
+
width: 210,
|
|
4443
4451
|
onSort: (r1, r2) => {
|
|
4444
4452
|
return r1.symbol?.localeCompare(r2.symbol || "");
|
|
4445
4453
|
},
|
|
@@ -4630,6 +4638,19 @@ var SymbolInfo2 = (props) => {
|
|
|
4630
4638
|
)
|
|
4631
4639
|
);
|
|
4632
4640
|
}
|
|
4641
|
+
if (record.margin_mode != null) {
|
|
4642
|
+
list.push(
|
|
4643
|
+
/* @__PURE__ */ jsx(
|
|
4644
|
+
Badge,
|
|
4645
|
+
{
|
|
4646
|
+
color: "neutral",
|
|
4647
|
+
size: "xs",
|
|
4648
|
+
children: record.margin_mode === MarginMode.ISOLATED ? t("marginMode.isolated") : t("marginMode.cross")
|
|
4649
|
+
},
|
|
4650
|
+
`margin-mode-${record.margin_mode}`
|
|
4651
|
+
)
|
|
4652
|
+
);
|
|
4653
|
+
}
|
|
4633
4654
|
list.push(
|
|
4634
4655
|
/* @__PURE__ */ jsx(
|
|
4635
4656
|
LeverageBadge2,
|
|
@@ -4642,7 +4663,7 @@ var SymbolInfo2 = (props) => {
|
|
|
4642
4663
|
);
|
|
4643
4664
|
return list;
|
|
4644
4665
|
}, [record, t]);
|
|
4645
|
-
return /* @__PURE__ */ jsxs(Flex, { gap: 2,
|
|
4666
|
+
return /* @__PURE__ */ jsxs(Flex, { gap: 2, className: "oui-py-1", children: [
|
|
4646
4667
|
/* @__PURE__ */ jsx(
|
|
4647
4668
|
Box,
|
|
4648
4669
|
{
|
|
@@ -4654,7 +4675,7 @@ var SymbolInfo2 = (props) => {
|
|
|
4654
4675
|
)
|
|
4655
4676
|
}
|
|
4656
4677
|
),
|
|
4657
|
-
/* @__PURE__ */ jsxs(Flex, { direction: "column", itemAlign: "start", children: [
|
|
4678
|
+
/* @__PURE__ */ jsxs(Flex, { direction: "column", itemAlign: "start", gap: 1, children: [
|
|
4658
4679
|
/* @__PURE__ */ jsx(
|
|
4659
4680
|
Text.formatted,
|
|
4660
4681
|
{
|
|
@@ -4668,7 +4689,7 @@ var SymbolInfo2 = (props) => {
|
|
|
4668
4689
|
children: `${record.symbol.split("_")[1]}-PERP`
|
|
4669
4690
|
}
|
|
4670
4691
|
),
|
|
4671
|
-
/* @__PURE__ */ jsx(Flex, { gap: 1, children: tags })
|
|
4692
|
+
/* @__PURE__ */ jsx(Flex, { gap: 1, wrap: "wrap", children: tags })
|
|
4672
4693
|
] })
|
|
4673
4694
|
] });
|
|
4674
4695
|
};
|
|
@@ -4780,6 +4801,15 @@ var areDatesEqual = (date1, date2) => {
|
|
|
4780
4801
|
};
|
|
4781
4802
|
|
|
4782
4803
|
// src/components/positionHistory/positionHistory.script.tsx
|
|
4804
|
+
var normalizeMarginMode = (value) => {
|
|
4805
|
+
if (value === 1 || value === MarginMode.ISOLATED) {
|
|
4806
|
+
return MarginMode.ISOLATED;
|
|
4807
|
+
}
|
|
4808
|
+
if (value === 0 || value === MarginMode.CROSS) {
|
|
4809
|
+
return MarginMode.CROSS;
|
|
4810
|
+
}
|
|
4811
|
+
return void 0;
|
|
4812
|
+
};
|
|
4783
4813
|
var usePositionHistoryScript = (props) => {
|
|
4784
4814
|
const {
|
|
4785
4815
|
onSymbolChange,
|
|
@@ -4799,20 +4829,16 @@ var usePositionHistoryScript = (props) => {
|
|
|
4799
4829
|
symbol ? `/v1/position_history?symbol=${symbol}&limit=1000` : "/v1/position_history?limit=1000",
|
|
4800
4830
|
{
|
|
4801
4831
|
formatter(data2) {
|
|
4802
|
-
return (data2.rows ?? null)?.map(
|
|
4803
|
-
|
|
4804
|
-
|
|
4805
|
-
|
|
4806
|
-
|
|
4807
|
-
|
|
4808
|
-
|
|
4809
|
-
margin_mode: item.margin_mode === 1 || item.margin_mode === MarginMode.ISOLATED ? MarginMode.ISOLATED : MarginMode.CROSS,
|
|
4810
|
-
netPnL
|
|
4811
|
-
};
|
|
4812
|
-
}
|
|
4813
|
-
return item;
|
|
4832
|
+
return (data2.rows ?? null)?.map((item) => {
|
|
4833
|
+
const result = {
|
|
4834
|
+
...item,
|
|
4835
|
+
margin_mode: normalizeMarginMode(item.margin_mode)
|
|
4836
|
+
};
|
|
4837
|
+
if (item.realized_pnl != null && item.accumulated_funding_fee != null && item.trading_fee != null) {
|
|
4838
|
+
result.netPnL = item.realized_pnl - item.accumulated_funding_fee - item.trading_fee;
|
|
4814
4839
|
}
|
|
4815
|
-
|
|
4840
|
+
return result;
|
|
4841
|
+
});
|
|
4816
4842
|
},
|
|
4817
4843
|
revalidateOnFocus: true
|
|
4818
4844
|
}
|
|
@@ -5083,8 +5109,13 @@ var PositionHistoryType = (props) => {
|
|
|
5083
5109
|
)
|
|
5084
5110
|
);
|
|
5085
5111
|
}
|
|
5112
|
+
if (record.margin_mode != null) {
|
|
5113
|
+
list.push(
|
|
5114
|
+
/* @__PURE__ */ jsx(Badge, { color: "neutral", size: "xs", children: record.margin_mode === MarginMode.ISOLATED ? t("marginMode.isolated") : t("marginMode.cross") }, `margin-${record.margin_mode}`)
|
|
5115
|
+
);
|
|
5116
|
+
}
|
|
5086
5117
|
return list;
|
|
5087
|
-
}, [record]);
|
|
5118
|
+
}, [record, t]);
|
|
5088
5119
|
return /* @__PURE__ */ jsx(Flex, { gap: 1, children: tags });
|
|
5089
5120
|
};
|
|
5090
5121
|
var ClosedQty = (props) => {
|