@orderly.network/ui-positions 2.11.2 → 2.12.0-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.mjs CHANGED
@@ -1,10 +1,10 @@
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';
1
+ import { registerSimpleDialog, registerSimpleSheet, useModal, SimpleDialog, useScreen, Flex, Text, Badge, Divider, toast, modal, CloseIcon, Button, ThrottledButton, SymbolBadge as SymbolBadge$1, 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';
5
5
  import { commifyOptional, Decimal, formatNum, getTimestamp, commify } from '@orderly.network/utils';
6
+ import { useLocalStorage, useSymbolsInfo, useMarkPrice, usePositionStream, useSubAccountMutation, useMutation, useBadgeBySymbol, useCollateral, usePositions, useAppStore, usePrivateInfiniteQuery, useBoolean, useSessionStorage, useAccount, usePrivateQuery, useTrack, usePositionClose, useSWR, fetcher, useEventEmitter, useDebouncedCallback, useGetRwaSymbolOpenStatus, useTpslPriceChecker, useConfig, findPositionTPSLFromOrders, findTPSLFromOrder, useReferralInfo, useLeverageBySymbol, utils, useMaxLeverage } from '@orderly.network/hooks';
6
7
  import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
7
- import { useLocalStorage, useSymbolsInfo, useMarkPrice, usePositionStream, useSubAccountMutation, useMutation, useCollateral, usePositions, useAppStore, usePrivateInfiniteQuery, useBoolean, useSessionStorage, useAccount, usePrivateQuery, useTrack, usePositionClose, useSWR, fetcher, useEventEmitter, useDebouncedCallback, useGetRwaSymbolOpenStatus, useTpslPriceChecker, useConfig, findPositionTPSLFromOrders, findTPSLFromOrder, useReferralInfo, useLeverageBySymbol, utils, useMaxLeverage } from '@orderly.network/hooks';
8
8
  import { useDataTap, useOrderEntryFormErrorMsg } from '@orderly.network/react-app';
9
9
  import { account, positions } from '@orderly.network/perp';
10
10
  import { AuthGuardDataTable } from '@orderly.network/ui-connector';
@@ -14,6 +14,11 @@ import { CloseToLiqPriceIcon, TPSLSheetId, TPSLDialogId, TPSLDetailSheetId, TPSL
14
14
  import { subDays, differenceInDays } from 'date-fns';
15
15
 
16
16
  // src/index.ts
17
+ var SymbolBadge = ({ symbol }) => {
18
+ const { brokerId, brokerName, brokerNameRaw } = useBadgeBySymbol(symbol);
19
+ const badge = brokerName ?? brokerId ?? void 0;
20
+ return /* @__PURE__ */ jsx(SymbolBadge$1, { badge, fullName: brokerNameRaw });
21
+ };
17
22
  var ConfirmHeader = (props) => {
18
23
  const { hideCloseIcon = false } = props;
19
24
  return /* @__PURE__ */ jsxs("div", { className: "oui-relative oui-w-full oui-border-b oui-border-line-4 oui-pb-3", children: [
@@ -170,9 +175,10 @@ var LimitConfirmDialog = (props) => {
170
175
  Text.formatted,
171
176
  {
172
177
  rule: "symbol",
173
- formatString: "base-type",
178
+ formatString: "base",
174
179
  size: "base",
175
180
  showIcon: true,
181
+ suffix: /* @__PURE__ */ jsx(SymbolBadge, { symbol: order.symbol }),
176
182
  children: order.symbol
177
183
  }
178
184
  ),
@@ -320,8 +326,10 @@ var FundingFeeHistoryUI = ({ total, symbol, start_t, end_t }) => {
320
326
  Text.formatted,
321
327
  {
322
328
  rule: "symbol",
329
+ formatString: "base",
323
330
  className: "oui-font-semibold",
324
331
  intensity: 98,
332
+ suffix: /* @__PURE__ */ jsx(SymbolBadge, { symbol }),
325
333
  children: symbol
326
334
  }
327
335
  )
@@ -404,7 +412,7 @@ var HistoryDataListView = ({ isLoading, data, loadMore }) => {
404
412
  dataIndex: "created_time",
405
413
  width: 120,
406
414
  render: (value) => {
407
- return /* @__PURE__ */ jsx(Text.formatted, { rule: "date", children: value });
415
+ return /* @__PURE__ */ jsx(Text.formatted, { rule: "date", suffix: /* @__PURE__ */ jsx(SymbolBadge, { symbol: value }), children: value });
408
416
  }
409
417
  },
410
418
  {
@@ -1116,9 +1124,10 @@ var ReversePosition = (props) => {
1116
1124
  size: "base",
1117
1125
  weight: "semibold",
1118
1126
  rule: "symbol",
1119
- formatString: "base-type",
1127
+ formatString: "base",
1120
1128
  intensity: 98,
1121
1129
  showIcon: true,
1130
+ suffix: /* @__PURE__ */ jsx(SymbolBadge, { symbol }),
1122
1131
  children: symbol
1123
1132
  }
1124
1133
  ),
@@ -2109,10 +2118,11 @@ var SymbolInfo = ({ symbol }) => {
2109
2118
  Text.formatted,
2110
2119
  {
2111
2120
  rule: "symbol",
2112
- formatString: "base-type",
2121
+ formatString: "base",
2113
2122
  size: "base",
2114
2123
  weight: "semibold",
2115
2124
  intensity: 98,
2125
+ suffix: /* @__PURE__ */ jsx(SymbolBadge, { symbol }),
2116
2126
  children: symbol
2117
2127
  }
2118
2128
  )
@@ -2291,7 +2301,16 @@ var MobileClosePosition = (props) => {
2291
2301
  const orderType = isMarketClose ? t("orderEntry.orderType.market") : t("orderEntry.orderType.limit");
2292
2302
  const orderSide = isBuy ? /* @__PURE__ */ jsx(Badge, { color: "success", size: "xs", children: t("common.buy") }) : /* @__PURE__ */ jsx(Badge, { color: "danger", size: "xs", children: t("common.sell") });
2293
2303
  const header = /* @__PURE__ */ jsxs(Flex, { width: "100%", justify: "between", children: [
2294
- /* @__PURE__ */ jsx(Text.formatted, { rule: "symbol", showIcon: true, children: position.symbol }),
2304
+ /* @__PURE__ */ jsx(
2305
+ Text.formatted,
2306
+ {
2307
+ rule: "symbol",
2308
+ formatString: "base",
2309
+ showIcon: true,
2310
+ suffix: /* @__PURE__ */ jsx(SymbolBadge, { symbol: position.symbol }),
2311
+ children: position.symbol
2312
+ }
2313
+ ),
2295
2314
  /* @__PURE__ */ jsxs(Flex, { gap: 1, children: [
2296
2315
  /* @__PURE__ */ jsx(Badge, { color: "neutral", size: "xs", children: orderType }),
2297
2316
  orderSide
@@ -3026,6 +3045,25 @@ var PartialTPSL = (props) => {
3026
3045
  ] })
3027
3046
  ] });
3028
3047
  };
3048
+ var PositionSymbolCell = (props) => {
3049
+ const { symbol, onSymbolChange, className, formatString, ...rest } = props;
3050
+ const { brokerId, brokerName, brokerNameRaw } = useBadgeBySymbol(symbol);
3051
+ return /* @__PURE__ */ jsx(
3052
+ Text.symbolBadge,
3053
+ {
3054
+ ...rest,
3055
+ className: cn(className, "oui-cursor-pointer"),
3056
+ badge: brokerName ?? brokerId ?? void 0,
3057
+ fullName: brokerNameRaw,
3058
+ onClick: (e) => {
3059
+ onSymbolChange?.({ symbol });
3060
+ e.stopPropagation();
3061
+ e.preventDefault();
3062
+ },
3063
+ children: symbol
3064
+ }
3065
+ );
3066
+ };
3029
3067
  var ReversePositionButton = (props) => {
3030
3068
  const { position } = props;
3031
3069
  return /* @__PURE__ */ jsx(
@@ -3069,6 +3107,7 @@ var useShareButtonScript = (props) => {
3069
3107
  const { position, sharePnLConfig, iconSize } = props;
3070
3108
  const { getFirstRefCode } = useReferralInfo();
3071
3109
  const symbolsInfo = useSymbolsInfo();
3110
+ const { brokerNameRaw } = useBadgeBySymbol(position.symbol);
3072
3111
  const refCode = useMemo(() => {
3073
3112
  return getFirstRefCode()?.code;
3074
3113
  }, [getFirstRefCode]);
@@ -3147,7 +3186,8 @@ var useShareButtonScript = (props) => {
3147
3186
  marginMode: position.margin_mode
3148
3187
  },
3149
3188
  refCode,
3150
- ...sharePnLConfig
3189
+ ...sharePnLConfig,
3190
+ brokerName: sharePnLConfig?.brokerName ?? brokerNameRaw
3151
3191
  }
3152
3192
  });
3153
3193
  };
@@ -3466,7 +3506,7 @@ var useColumn = (config) => {
3466
3506
  title: t("common.symbol"),
3467
3507
  dataIndex: "symbol",
3468
3508
  fixed: "left",
3469
- width: 176,
3509
+ width: 200,
3470
3510
  onSort: (r1, r2) => {
3471
3511
  return r1.symbol?.localeCompare(r2.symbol || "");
3472
3512
  },
@@ -3475,9 +3515,9 @@ var useColumn = (config) => {
3475
3515
  Box,
3476
3516
  {
3477
3517
  width: 4,
3478
- height: 20,
3518
+ height: 24,
3479
3519
  className: cn(
3480
- "oui-h-[38px] oui-rounded-[1px]",
3520
+ "oui-h-[42px] oui-rounded-[1px]",
3481
3521
  record.position_qty > 0 ? "oui-bg-trade-profit" : "oui-bg-trade-loss"
3482
3522
  )
3483
3523
  }
@@ -3485,16 +3525,10 @@ var useColumn = (config) => {
3485
3525
  /* @__PURE__ */ jsxs(Flex, { direction: "column", itemAlign: "start", gap: 1, children: [
3486
3526
  /* @__PURE__ */ jsxs(Flex, { gap: 1, itemAlign: "center", children: [
3487
3527
  /* @__PURE__ */ jsx(
3488
- Text.formatted,
3528
+ PositionSymbolCell,
3489
3529
  {
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`
3530
+ symbol: value,
3531
+ onSymbolChange
3498
3532
  }
3499
3533
  ),
3500
3534
  /* @__PURE__ */ jsx(RwaStatusTag, { symbol: value })
@@ -3785,12 +3819,13 @@ var SymbolToken = (props) => {
3785
3819
  Text.formatted,
3786
3820
  {
3787
3821
  rule: "symbol",
3788
- formatString: "base-type",
3822
+ formatString: "base",
3789
3823
  size: "2xs",
3790
3824
  showIcon: true,
3791
3825
  onClick: () => {
3792
3826
  props.onSymbolChange?.({ symbol: item.symbol });
3793
3827
  },
3828
+ suffix: /* @__PURE__ */ jsx(SymbolBadge, { symbol: item.symbol }),
3794
3829
  children: item.symbol
3795
3830
  }
3796
3831
  ),
@@ -4447,7 +4482,7 @@ var usePositionHistoryColumn = (props) => {
4447
4482
  title: t("common.symbol"),
4448
4483
  dataIndex: "symbol",
4449
4484
  fixed: "left",
4450
- width: 210,
4485
+ width: 250,
4451
4486
  onSort: (r1, r2) => {
4452
4487
  return r1.symbol?.localeCompare(r2.symbol || "");
4453
4488
  },
@@ -4677,16 +4712,10 @@ var SymbolInfo2 = (props) => {
4677
4712
  ),
4678
4713
  /* @__PURE__ */ jsxs(Flex, { direction: "column", itemAlign: "start", gap: 1, children: [
4679
4714
  /* @__PURE__ */ jsx(
4680
- Text.formatted,
4715
+ PositionSymbolCell,
4681
4716
  {
4682
- formatString: "base-type",
4683
- className: "oui-cursor-pointer",
4684
- onClick: (e) => {
4685
- onSymbolChange?.({ symbol: record.symbol });
4686
- e.stopPropagation();
4687
- e.preventDefault();
4688
- },
4689
- children: `${record.symbol.split("_")[1]}-PERP`
4717
+ symbol: record.symbol,
4718
+ onSymbolChange
4690
4719
  }
4691
4720
  ),
4692
4721
  /* @__PURE__ */ jsx(Flex, { gap: 1, wrap: "wrap", children: tags })
@@ -5020,9 +5049,10 @@ var SymbolToken2 = (props) => {
5020
5049
  {
5021
5050
  intensity: 80,
5022
5051
  rule: "symbol",
5023
- formatString: "base-type",
5052
+ formatString: "base",
5024
5053
  size: "sm",
5025
5054
  prefix: /* @__PURE__ */ jsx(Badge, { color: isBuy ? "success" : "danger", size: "xs", children: isBuy ? t("common.buy") : t("common.sell") }),
5055
+ suffix: /* @__PURE__ */ jsx(SymbolBadge, { symbol }),
5026
5056
  onClick: () => {
5027
5057
  props.onSymbolChange?.({ symbol });
5028
5058
  },
@@ -5330,7 +5360,7 @@ var Header = (props) => {
5330
5360
  ]
5331
5361
  }
5332
5362
  ),
5333
- /* @__PURE__ */ jsxs(Flex, { direction: "column", itemAlign: "end", className: "oui-flex-1", children: [
5363
+ /* @__PURE__ */ jsxs(Flex, { direction: "column", itemAlign: "end", children: [
5334
5364
  /* @__PURE__ */ jsx(Text, { size: "2xs", intensity: 36, children: t("positions.history.column.netPnl") }),
5335
5365
  /* @__PURE__ */ jsxs(Flex, { gapX: 1, children: [
5336
5366
  /* @__PURE__ */ jsx("button", { onClick: showAlert, children: /* @__PURE__ */ jsx(Text.numeral, { size: "xs", coloring: true, children: props.item.netPnL ?? "--" }) }),
@@ -5568,16 +5598,8 @@ var useLiquidationColumn = (props) => {
5568
5598
  {
5569
5599
  title: t("common.symbol"),
5570
5600
  dataIndex: "Symbol",
5571
- // width: 202,
5572
- render: (_, record) => /* @__PURE__ */ jsx(Flex, { direction: "column", itemAlign: "start", children: record.positions_by_perp?.map((item) => /* @__PURE__ */ jsx(
5573
- Text.formatted,
5574
- {
5575
- rule: "symbol",
5576
- formatString: "base-quote",
5577
- children: item.symbol
5578
- },
5579
- item.symbol
5580
- )) })
5601
+ width: 120,
5602
+ render: (_, record) => /* @__PURE__ */ jsx(Flex, { direction: "column", itemAlign: "start", children: record.positions_by_perp?.map((item) => /* @__PURE__ */ jsx(PositionSymbolCell, { symbol: item.symbol }, item.symbol)) })
5581
5603
  },
5582
5604
  // Price (USDC)
5583
5605
  {
@@ -5745,9 +5767,15 @@ var Header2 = (props) => {
5745
5767
  Text.formatted,
5746
5768
  {
5747
5769
  rule: "symbol",
5748
- formatString: "base-quote",
5770
+ formatString: "base",
5749
5771
  size: "xs",
5750
5772
  intensity: 80,
5773
+ suffix: /* @__PURE__ */ jsx(
5774
+ SymbolBadge,
5775
+ {
5776
+ symbol: props.item.positions_by_perp?.[0]?.symbol || ""
5777
+ }
5778
+ ),
5751
5779
  children: props.item.positions_by_perp?.[0]?.symbol || ""
5752
5780
  }
5753
5781
  ) }) }) }),