@orderly.network/ui-order-entry 3.0.4-alpha.2 → 3.0.4-alpha.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/dist/index.js +85 -29
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +87 -31
- package/dist/index.mjs.map +1 -1
- package/dist/styles.css +1 -1
- package/package.json +13 -13
package/dist/index.mjs
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import React3, { memo, forwardRef, useState, useImperativeHandle, useEffect, createContext, useMemo, useRef, useCallback, useContext, useId } from 'react';
|
|
2
2
|
import { useLocalStorage, utils, useGetEstLiqPrice, useOrderlyContext, useMemoizedFn, ERROR_MSG_CODES, usePositionStream, useFeeState, useRwaSymbolsInfoStore, useMarkets, MarketsType, useMarginModes, useMarginModeBySymbol, useBadgeBySymbol, useEventEmitter, useDebouncedCallback, useHoldingStream, useAppStore, useIndexPricesStream, useComputedLTV, useBoolean, useFeatureFlag, FlagKeys, useQuery, useAccount, useOrderEntry, useMarginRatio, useTpslPriceChecker, useTrack } from '@orderly.network/hooks';
|
|
3
|
-
import { i18n, useTranslation } from '@orderly.network/i18n';
|
|
3
|
+
import { i18n, useTranslation, Trans } from '@orderly.network/i18n';
|
|
4
4
|
import { useOrderEntryFormErrorMsg, useCanTrade } from '@orderly.network/react-app';
|
|
5
5
|
import { OrderSide, EMPTY_LIST, DistributionType, TrailingCallbackType, OrderType, MarginMode, PositionType, BBOOrderType, ORDER_ENTRY_EST_LIQ_PRICE_CHANGE, OrderLevel, TrackerEventName } from '@orderly.network/types';
|
|
6
|
-
import { registerSimpleDialog, SimpleDialog, ExclamationFillIcon, modal, Text, Tooltip, TooltipTrigger, Flex, Input, cn, inputFormatter, Box, Slider, textVariants, injectable, Button, ThrottledButton, registerSimpleSheet, Select, Grid, Checkbox, SettingFillIcon, useScreen, InfoCircleIcon, AddCircleIcon, useModal, toast, Divider, Switch, SimpleSheet, Badge, TokenIcon, DataTable, IconButton, CloseIcon, CloseCircleFillIcon, ChevronRightIcon, SymbolBadge as SymbolBadge$1, EditIcon as EditIcon$1, SimpleDropdownMenu, CaretDownIcon, DotStatus, PopoverRoot, PopoverTrigger, PopoverContent } from '@orderly.network/ui';
|
|
6
|
+
import { registerSimpleDialog, SimpleDialog, ExclamationFillIcon, modal, Text, Tooltip, TooltipTrigger, Flex, Input, cn, inputFormatter, Box, Slider, textVariants, injectable, Button, ThrottledButton, registerSimpleSheet, Select, Grid, Checkbox, SettingFillIcon, useScreen, Tips, InfoCircleIcon, AddCircleIcon, useModal, toast, Divider, Switch, SimpleSheet, Badge, TokenIcon, DataTable, IconButton, CloseIcon, CloseCircleFillIcon, ChevronRightIcon, SymbolBadge as SymbolBadge$1, EditIcon as EditIcon$1, SimpleDropdownMenu, CaretDownIcon, DotStatus, PopoverRoot, PopoverTrigger, PopoverContent } from '@orderly.network/ui';
|
|
7
7
|
import { TPSLPositionTypeWidget, TPSLAdvancedWidget } from '@orderly.network/ui-tpsl';
|
|
8
8
|
import { Decimal, zero, formatSymbol, removeTrailingZeros, todpIfNeed, getBBOType } from '@orderly.network/utils';
|
|
9
9
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
@@ -1712,33 +1712,38 @@ function AssetInfo(props) {
|
|
|
1712
1712
|
symbol,
|
|
1713
1713
|
side: props.side
|
|
1714
1714
|
});
|
|
1715
|
+
const estLiqTipsContent = /* @__PURE__ */ jsxs("div", { className: "oui-min-w-[204px] oui-max-w-[280px] oui-text-2xs oui-leading-normal oui-text-base-contrast-80", children: [
|
|
1716
|
+
/* @__PURE__ */ jsx("div", { className: "oui-text-pretty", children: t("common.liquidationPrice.tooltip") }),
|
|
1717
|
+
/* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsx(
|
|
1718
|
+
"a",
|
|
1719
|
+
{
|
|
1720
|
+
href: "https://orderly.network/docs/introduction/trade-on-orderly/perpetual-futures/liquidations",
|
|
1721
|
+
target: "_blank",
|
|
1722
|
+
rel: "noopener noreferrer",
|
|
1723
|
+
className: "oui-text-primary oui-underline",
|
|
1724
|
+
children: t("common.liquidationPrice.tooltip.learnMore")
|
|
1725
|
+
}
|
|
1726
|
+
) })
|
|
1727
|
+
] });
|
|
1715
1728
|
return /* @__PURE__ */ jsxs(
|
|
1716
1729
|
"div",
|
|
1717
1730
|
{
|
|
1718
1731
|
className: "oui-orderEntry-assetInfo oui-space-y-[2px] xl:oui-space-y-1",
|
|
1719
1732
|
children: [
|
|
1720
1733
|
/* @__PURE__ */ jsxs(Flex, { justify: "between", className: "oui-orderEntry-estLiqPrice", children: [
|
|
1721
|
-
|
|
1722
|
-
|
|
1734
|
+
/* @__PURE__ */ jsx(
|
|
1735
|
+
Tips,
|
|
1723
1736
|
{
|
|
1724
|
-
|
|
1725
|
-
|
|
1726
|
-
|
|
1727
|
-
"a",
|
|
1728
|
-
{
|
|
1729
|
-
href: "https://orderly.network/docs/introduction/trade-on-orderly/perpetual-futures/liquidations",
|
|
1730
|
-
target: "_blank",
|
|
1731
|
-
rel: "noopener noreferrer",
|
|
1732
|
-
className: "oui-text-primary oui-underline",
|
|
1733
|
-
children: t("common.liquidationPrice.tooltip.learnMore")
|
|
1734
|
-
}
|
|
1735
|
-
) })
|
|
1736
|
-
] }),
|
|
1737
|
-
children: /* @__PURE__ */ jsx(
|
|
1737
|
+
title: t("common.tips"),
|
|
1738
|
+
content: estLiqTipsContent,
|
|
1739
|
+
trigger: /* @__PURE__ */ jsx(
|
|
1738
1740
|
Text,
|
|
1739
1741
|
{
|
|
1740
1742
|
size: "2xs",
|
|
1741
|
-
className:
|
|
1743
|
+
className: cn(
|
|
1744
|
+
"oui-estLiqPrice-label oui-cursor-pointer",
|
|
1745
|
+
"oui-border-b oui-border-dashed oui-border-line-12"
|
|
1746
|
+
),
|
|
1742
1747
|
children: t("orderEntry.estLiqPrice")
|
|
1743
1748
|
}
|
|
1744
1749
|
)
|
|
@@ -1848,6 +1853,7 @@ var LTVRiskTooltipUI = (props) => {
|
|
|
1848
1853
|
threshold: isThresholdLoading ? "-" : ltv_threshold,
|
|
1849
1854
|
usdcThreshold: isThresholdLoading ? "-" : negative_usdc_threshold
|
|
1850
1855
|
}) }),
|
|
1856
|
+
marginMode === MarginMode.ISOLATED ? /* @__PURE__ */ jsx(Text, { className: "oui-pb-2", intensity: 54, size: "2xs", children: t("transfer.LTV.isolatedMarginOrderHint") }) : null,
|
|
1851
1857
|
/* @__PURE__ */ jsx(
|
|
1852
1858
|
Button,
|
|
1853
1859
|
{
|
|
@@ -1877,6 +1883,7 @@ var useConvertThreshold = () => {
|
|
|
1877
1883
|
};
|
|
1878
1884
|
};
|
|
1879
1885
|
var useLTVTooltipScript = (marginMode) => {
|
|
1886
|
+
const { isMobile } = useScreen();
|
|
1880
1887
|
const { data: holdingList = [], isLoading: isHoldingLoading } = useHoldingStream();
|
|
1881
1888
|
const {
|
|
1882
1889
|
ltv_threshold,
|
|
@@ -1908,8 +1915,8 @@ var useLTVTooltipScript = (marginMode) => {
|
|
|
1908
1915
|
});
|
|
1909
1916
|
const currentLtv = useComputedLTV();
|
|
1910
1917
|
const onConvert = useCallback(async () => {
|
|
1911
|
-
return modal.show("ConvertDialogId");
|
|
1912
|
-
}, []);
|
|
1918
|
+
return modal.show(isMobile ? "ConvertSheetId" : "ConvertDialogId");
|
|
1919
|
+
}, [isMobile]);
|
|
1913
1920
|
return {
|
|
1914
1921
|
holdingData,
|
|
1915
1922
|
isHoldingLoading,
|
|
@@ -1934,6 +1941,13 @@ var Available = (props) => {
|
|
|
1934
1941
|
const showLTV = useMemo(() => {
|
|
1935
1942
|
return typeof currentLtv === "number" && !Number.isNaN(currentLtv) && currentLtv > 0;
|
|
1936
1943
|
}, [currentLtv]);
|
|
1944
|
+
const availableTooltip = useMemo(() => {
|
|
1945
|
+
return marginMode === MarginMode.ISOLATED ? t("transfer.LTV.isolatedModeUsdcOnly") : t("transfer.LTV.availableCrossMarginHint");
|
|
1946
|
+
}, [marginMode, t]);
|
|
1947
|
+
const availableTipsContent = useMemo(
|
|
1948
|
+
() => /* @__PURE__ */ jsx("div", { className: "oui-text-pretty oui-text-2xs oui-leading-normal oui-text-base-contrast-80", children: availableTooltip }),
|
|
1949
|
+
[availableTooltip]
|
|
1950
|
+
);
|
|
1937
1951
|
return /* @__PURE__ */ jsxs(
|
|
1938
1952
|
Flex,
|
|
1939
1953
|
{
|
|
@@ -1941,14 +1955,31 @@ var Available = (props) => {
|
|
|
1941
1955
|
justify: "between",
|
|
1942
1956
|
className: "oui-orderEntry-available",
|
|
1943
1957
|
children: [
|
|
1944
|
-
|
|
1958
|
+
/* @__PURE__ */ jsx(
|
|
1959
|
+
Tips,
|
|
1960
|
+
{
|
|
1961
|
+
title: t("common.tips"),
|
|
1962
|
+
content: availableTipsContent,
|
|
1963
|
+
trigger: /* @__PURE__ */ jsx(
|
|
1964
|
+
Text,
|
|
1965
|
+
{
|
|
1966
|
+
size: "2xs",
|
|
1967
|
+
className: cn(
|
|
1968
|
+
"oui-available-label oui-cursor-pointer",
|
|
1969
|
+
"oui-border-b oui-border-dashed oui-border-line-12"
|
|
1970
|
+
),
|
|
1971
|
+
children: t("common.available")
|
|
1972
|
+
}
|
|
1973
|
+
)
|
|
1974
|
+
}
|
|
1975
|
+
),
|
|
1945
1976
|
/* @__PURE__ */ jsxs(Flex, { itemAlign: "center", justify: "center", gap: 1, children: [
|
|
1946
1977
|
showLTV && /* @__PURE__ */ jsx(
|
|
1947
|
-
|
|
1978
|
+
Tips,
|
|
1948
1979
|
{
|
|
1949
|
-
|
|
1980
|
+
title: t("common.tips"),
|
|
1950
1981
|
content: /* @__PURE__ */ jsx(LTVRiskTooltipWidget, { marginMode }),
|
|
1951
|
-
|
|
1982
|
+
trigger: /* @__PURE__ */ jsx(
|
|
1952
1983
|
InfoCircleIcon,
|
|
1953
1984
|
{
|
|
1954
1985
|
className: "oui-cursor-pointer oui-text-warning oui-opacity-80"
|
|
@@ -2594,19 +2625,26 @@ var MarginModeSwitch = (props) => {
|
|
|
2594
2625
|
var OptionCard = (props) => {
|
|
2595
2626
|
const { t } = useTranslation();
|
|
2596
2627
|
const title = props.mode === MarginMode.CROSS ? t("marginMode.crossMargin") : t("marginMode.isolatedMargin");
|
|
2597
|
-
const desc = props.mode === MarginMode.CROSS ? t("marginMode.crossMarginDescription") : t("marginMode.isolatedMarginDescription");
|
|
2598
2628
|
return /* @__PURE__ */ jsxs(
|
|
2599
|
-
"
|
|
2629
|
+
"div",
|
|
2600
2630
|
{
|
|
2601
|
-
|
|
2631
|
+
role: "button",
|
|
2632
|
+
tabIndex: props.disabled ? -1 : 0,
|
|
2602
2633
|
className: cn(
|
|
2603
2634
|
"oui-relative oui-w-full oui-rounded-md oui-p-2",
|
|
2604
2635
|
"oui-bg-base-6",
|
|
2605
2636
|
"oui-text-left",
|
|
2606
|
-
props.disabled ? "oui-cursor-not-allowed oui-opacity-50 oui-border oui-border-transparent" : props.selected ? "oui-border oui-border-[#38e2fe]" : "oui-border oui-border-transparent hover:oui-border-line-12"
|
|
2637
|
+
props.disabled ? "oui-cursor-not-allowed oui-opacity-50 oui-border oui-border-transparent" : props.selected ? "oui-border oui-border-[#38e2fe]" : "oui-border oui-border-transparent hover:oui-border-line-12",
|
|
2638
|
+
!props.disabled && "oui-cursor-pointer"
|
|
2607
2639
|
),
|
|
2608
2640
|
onClick: props.disabled ? void 0 : props.onClick,
|
|
2609
|
-
|
|
2641
|
+
onKeyDown: (e) => {
|
|
2642
|
+
if (props.disabled) return;
|
|
2643
|
+
if (e.key === "Enter" || e.key === " ") {
|
|
2644
|
+
e.preventDefault();
|
|
2645
|
+
props.onClick();
|
|
2646
|
+
}
|
|
2647
|
+
},
|
|
2610
2648
|
"aria-disabled": props.disabled,
|
|
2611
2649
|
"data-testid": `oui-testid-marginModeSwitch-option-${props.mode}`,
|
|
2612
2650
|
children: [
|
|
@@ -2619,7 +2657,25 @@ var OptionCard = (props) => {
|
|
|
2619
2657
|
children: title
|
|
2620
2658
|
}
|
|
2621
2659
|
),
|
|
2622
|
-
/* @__PURE__ */ jsx(Text, { className: "oui-text-2xs oui-leading-[15px] oui-text-base-contrast-36 oui-font-semibold oui-tracking-[0.03em]", children:
|
|
2660
|
+
props.mode === MarginMode.ISOLATED ? /* @__PURE__ */ jsx(Text, { className: "oui-text-2xs oui-leading-[15px] oui-text-base-contrast-36 oui-font-semibold oui-tracking-[0.03em]", children: /* @__PURE__ */ jsx(
|
|
2661
|
+
Trans,
|
|
2662
|
+
{
|
|
2663
|
+
i18nKey: "marginMode.isolatedMarginDescription",
|
|
2664
|
+
components: [
|
|
2665
|
+
/* @__PURE__ */ jsx(
|
|
2666
|
+
"a",
|
|
2667
|
+
{
|
|
2668
|
+
href: "https://orderly.network/docs/introduction/trade-on-orderly/perpetual-futures/isolated-margin",
|
|
2669
|
+
target: "_blank",
|
|
2670
|
+
rel: "noopener noreferrer",
|
|
2671
|
+
className: "whitespace-nowrap oui-font-semibold oui-text-warning oui-underline oui-underline-offset-2 hover:oui-text-warning/90",
|
|
2672
|
+
onClick: (e) => e.stopPropagation()
|
|
2673
|
+
},
|
|
2674
|
+
"isolated-margin-doc"
|
|
2675
|
+
)
|
|
2676
|
+
]
|
|
2677
|
+
}
|
|
2678
|
+
) }) : /* @__PURE__ */ jsx(Text, { className: "oui-text-2xs oui-leading-[15px] oui-text-base-contrast-36 oui-font-semibold oui-tracking-[0.03em]", children: t("marginMode.crossMarginDescription") })
|
|
2623
2679
|
] }),
|
|
2624
2680
|
props.isCurrent ? /* @__PURE__ */ jsx(
|
|
2625
2681
|
"div",
|