@orderly.network/ui-tradingview 2.12.4 → 3.0.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,7 +1,7 @@
1
1
  import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
2
2
  import React3, { forwardRef, useRef, useState, useMemo, useEffect, useCallback } from 'react';
3
3
  import { useTranslation, Trans, useLocaleCode, i18n } from '@orderly.network/i18n';
4
- import { cn, Flex, Divider, Box, useScreen, useOrderlyTheme, useThemeAttribute, toast, modal, DropdownMenuRoot, DropdownMenuTrigger, DropdownMenuPortal, DropdownMenuContent, Text, Switch } from '@orderly.network/ui';
4
+ import { injectable, cn, Flex, Divider, useScreen, useOrderlyTheme, Box, useThemeAttribute, toast, modal, DropdownMenuRoot, DropdownMenuTrigger, DropdownMenuPortal, DropdownMenuContent, Text, Switch } from '@orderly.network/ui';
5
5
  import { useMediaQuery, useConfig, useAccount, useSymbolsInfo, useLocalStorage, useOrderEntry_deprecated, useMarginModeBySymbol, useWS, usePositionStream, useOrderStream, useEventEmitter } from '@orderly.network/hooks';
6
6
  import { MEDIA_TABLET, OrderSide, TradingviewFullscreenKey, OrderType, AccountStatusEnum, OrderStatus, ORDER_ENTRY_EST_LIQ_PRICE_CHANGE, MarginMode } from '@orderly.network/types';
7
7
  import { Decimal, commify, getTrailingStopPrice, getPrecisionByNumber } from '@orderly.network/utils';
@@ -4767,9 +4767,25 @@ var NoTradingview = () => {
4767
4767
  ] }) });
4768
4768
  };
4769
4769
  var TopBar = (props) => {
4770
- return /* @__PURE__ */ jsx("div", { className: "top-toolbar oui-flex oui-h-[44px] oui-justify-between md:oui-justify-start oui-items-center oui-p-2 md:oui-px-3 md:oui-pt-3 md:oui-pb-[14px]", children: props.children });
4770
+ return /* @__PURE__ */ jsx("div", { className: "top-toolbar oui-flex oui-h-[44px] oui-justify-between md:oui-justify-start oui-items-center oui-p-2 md:oui-px-3 md:oui-pt-3 md:oui-pb-[14px] oui-w-full", children: props.children });
4771
4771
  };
4772
4772
  var topBar_default = TopBar;
4773
+ var TradingviewChart = ({ chartRef }) => {
4774
+ return /* @__PURE__ */ jsx(
4775
+ "div",
4776
+ {
4777
+ "data-testid": "tradingview-chart",
4778
+ ref: chartRef,
4779
+ className: "oui-size-full oui-overflow-hidden"
4780
+ }
4781
+ );
4782
+ };
4783
+
4784
+ // src/components/tradingview.injectable.tsx
4785
+ var InjectableTradingviewDesktop = injectable(
4786
+ TradingviewChart,
4787
+ "TradingView.Desktop"
4788
+ );
4773
4789
  var LazyLineType = React3.lazy(() => Promise.resolve().then(() => (init_lineType(), lineType_exports)));
4774
4790
  var LazyTimeInterval = React3.lazy(
4775
4791
  () => Promise.resolve().then(() => (init_timeInterval(), timeInterval_exports)).then((mod) => ({ default: mod.TimeInterval }))
@@ -4784,6 +4800,98 @@ var LazyDesktopDisplayControl = React3.lazy(
4784
4800
  default: mod.DesktopDisplayControl
4785
4801
  }))
4786
4802
  );
4803
+ var MobileTopBar = ({
4804
+ interval,
4805
+ changeInterval,
4806
+ displayControlState,
4807
+ changeDisplaySetting,
4808
+ openChartIndicators
4809
+ }) => {
4810
+ return /* @__PURE__ */ jsxs(
4811
+ Flex,
4812
+ {
4813
+ gapX: 2,
4814
+ width: "100%",
4815
+ justify: "between",
4816
+ className: "oui-hide-scrollbar oui-overflow-x-scroll",
4817
+ children: [
4818
+ /* @__PURE__ */ jsx(React3.Suspense, { fallback: null, children: /* @__PURE__ */ jsx(
4819
+ LazyTimeInterval,
4820
+ {
4821
+ interval: interval ?? "15",
4822
+ changeInterval
4823
+ }
4824
+ ) }),
4825
+ /* @__PURE__ */ jsx(OperateButton, { onClick: openChartIndicators, children: /* @__PURE__ */ jsx(IndicatorsIcon, {}) }),
4826
+ /* @__PURE__ */ jsx(React3.Suspense, { fallback: null, children: /* @__PURE__ */ jsx(
4827
+ LazyMobileDisplayControl,
4828
+ {
4829
+ displayControlState,
4830
+ changeDisplayControlState: changeDisplaySetting
4831
+ }
4832
+ ) })
4833
+ ]
4834
+ }
4835
+ );
4836
+ };
4837
+ var DesktopTopBar = ({
4838
+ interval,
4839
+ changeInterval,
4840
+ displayControlState,
4841
+ changeDisplaySetting,
4842
+ openChartIndicators,
4843
+ lineType,
4844
+ changeLineType,
4845
+ openChartSetting,
4846
+ fullscreen,
4847
+ onFullScreenChange
4848
+ }) => {
4849
+ return /* @__PURE__ */ jsxs(Flex, { justify: "between", itemAlign: "center", width: "100%", children: [
4850
+ /* @__PURE__ */ jsxs(Flex, { children: [
4851
+ /* @__PURE__ */ jsx(React3.Suspense, { fallback: null, children: /* @__PURE__ */ jsx(
4852
+ LazyTimeInterval,
4853
+ {
4854
+ interval: interval ?? "1",
4855
+ changeInterval
4856
+ }
4857
+ ) }),
4858
+ /* @__PURE__ */ jsx(
4859
+ Divider,
4860
+ {
4861
+ direction: "vertical",
4862
+ className: "oui-h-4",
4863
+ mx: 2,
4864
+ intensity: 8
4865
+ }
4866
+ ),
4867
+ /* @__PURE__ */ jsxs(Flex, { justify: "start", itemAlign: "center", gap: 2, children: [
4868
+ /* @__PURE__ */ jsx(React3.Suspense, { fallback: null, children: /* @__PURE__ */ jsx(
4869
+ LazyDesktopDisplayControl,
4870
+ {
4871
+ displayControlState,
4872
+ changeDisplayControlState: changeDisplaySetting
4873
+ }
4874
+ ) }),
4875
+ /* @__PURE__ */ jsx(OperateButton, { onClick: openChartIndicators, children: /* @__PURE__ */ jsx(IndicatorsIcon, {}) }),
4876
+ /* @__PURE__ */ jsx(React3.Suspense, { fallback: null, children: /* @__PURE__ */ jsx(LazyLineType, { lineType, changeLineType }) }),
4877
+ /* @__PURE__ */ jsx(OperateButton, { onClick: openChartSetting, children: /* @__PURE__ */ jsx(SettingIcon, {}) })
4878
+ ] })
4879
+ ] }),
4880
+ /* @__PURE__ */ jsx(Flex, { children: fullscreen ? /* @__PURE__ */ jsx(
4881
+ ZoomOutIcon,
4882
+ {
4883
+ className: "oui-text-base-contrast-54 hover:oui-text-base-contrast oui-cursor-pointer",
4884
+ onClick: onFullScreenChange
4885
+ }
4886
+ ) : /* @__PURE__ */ jsx(
4887
+ ZoomInIcon,
4888
+ {
4889
+ className: "oui-text-base-contrast-54 hover:oui-text-base-contrast oui-cursor-pointer",
4890
+ onClick: onFullScreenChange
4891
+ }
4892
+ ) })
4893
+ ] });
4894
+ };
4787
4895
  var OperateButton = ({ children, onClick }) => {
4788
4896
  return /* @__PURE__ */ jsx(
4789
4897
  Box,
@@ -4853,83 +4961,31 @@ var TradingviewUI = forwardRef((props, ref) => {
4853
4961
  props.classNames?.content
4854
4962
  ),
4855
4963
  children: [
4856
- /* @__PURE__ */ jsx(topBar_default, { children: isMobile ? /* @__PURE__ */ jsxs(
4857
- Flex,
4964
+ /* @__PURE__ */ jsx(topBar_default, { children: isMobile ? /* @__PURE__ */ jsx(
4965
+ MobileTopBar,
4858
4966
  {
4859
- gapX: 2,
4860
- width: "100%",
4861
- justify: "between",
4862
- className: "oui-hide-scrollbar oui-overflow-x-scroll",
4863
- children: [
4864
- /* @__PURE__ */ jsx(React3.Suspense, { fallback: null, children: /* @__PURE__ */ jsx(
4865
- LazyTimeInterval,
4866
- {
4867
- interval: interval ?? "15",
4868
- changeInterval
4869
- }
4870
- ) }),
4871
- /* @__PURE__ */ jsx(OperateButton, { onClick: openChartIndicators, children: /* @__PURE__ */ jsx(IndicatorsIcon, {}) }),
4872
- /* @__PURE__ */ jsx(React3.Suspense, { fallback: null, children: /* @__PURE__ */ jsx(
4873
- LazyMobileDisplayControl,
4874
- {
4875
- displayControlState,
4876
- changeDisplayControlState: changeDisplaySetting
4877
- }
4878
- ) })
4879
- ]
4967
+ interval,
4968
+ changeInterval,
4969
+ displayControlState,
4970
+ changeDisplaySetting,
4971
+ openChartIndicators
4880
4972
  }
4881
- ) : /* @__PURE__ */ jsxs(Flex, { justify: "between", itemAlign: "center", width: "100%", children: [
4882
- /* @__PURE__ */ jsxs(Flex, { children: [
4883
- /* @__PURE__ */ jsx(React3.Suspense, { fallback: null, children: /* @__PURE__ */ jsx(
4884
- LazyTimeInterval,
4885
- {
4886
- interval: interval ?? "1",
4887
- changeInterval
4888
- }
4889
- ) }),
4890
- /* @__PURE__ */ jsx(
4891
- Divider,
4892
- {
4893
- direction: "vertical",
4894
- className: "oui-h-4",
4895
- mx: 2,
4896
- intensity: 8
4897
- }
4898
- ),
4899
- /* @__PURE__ */ jsxs(Flex, { justify: "start", itemAlign: "center", gap: 2, children: [
4900
- /* @__PURE__ */ jsx(React3.Suspense, { fallback: null, children: /* @__PURE__ */ jsx(
4901
- LazyDesktopDisplayControl,
4902
- {
4903
- displayControlState,
4904
- changeDisplayControlState: changeDisplaySetting
4905
- }
4906
- ) }),
4907
- /* @__PURE__ */ jsx(OperateButton, { onClick: openChartIndicators, children: /* @__PURE__ */ jsx(IndicatorsIcon, {}) }),
4908
- /* @__PURE__ */ jsx(React3.Suspense, { fallback: null, children: /* @__PURE__ */ jsx(
4909
- LazyLineType,
4910
- {
4911
- lineType,
4912
- changeLineType
4913
- }
4914
- ) }),
4915
- /* @__PURE__ */ jsx(OperateButton, { onClick: openChartSetting, children: /* @__PURE__ */ jsx(SettingIcon, {}) })
4916
- ] })
4917
- ] }),
4918
- /* @__PURE__ */ jsx(Flex, { children: props.fullscreen ? /* @__PURE__ */ jsx(
4919
- ZoomOutIcon,
4920
- {
4921
- className: "oui-text-base-contrast-54 hover:oui-text-base-contrast oui-cursor-pointer",
4922
- onClick: onFullScreenChange
4923
- }
4924
- ) : /* @__PURE__ */ jsx(
4925
- ZoomInIcon,
4926
- {
4927
- className: "oui-text-base-contrast-54 hover:oui-text-base-contrast oui-cursor-pointer",
4928
- onClick: onFullScreenChange
4929
- }
4930
- ) })
4931
- ] }) }),
4932
- /* @__PURE__ */ jsx("div", { ref: chartRef, className: "oui-size-full oui-overflow-hidden" })
4973
+ ) : /* @__PURE__ */ jsx(
4974
+ DesktopTopBar,
4975
+ {
4976
+ interval,
4977
+ changeInterval,
4978
+ displayControlState,
4979
+ changeDisplaySetting,
4980
+ openChartIndicators,
4981
+ lineType,
4982
+ changeLineType,
4983
+ openChartSetting,
4984
+ fullscreen: props.fullscreen,
4985
+ onFullScreenChange
4986
+ }
4987
+ ) }),
4988
+ /* @__PURE__ */ jsx(InjectableTradingviewDesktop, { ...props })
4933
4989
  ]
4934
4990
  }
4935
4991
  )
@@ -4938,9 +4994,9 @@ var TradingviewUI = forwardRef((props, ref) => {
4938
4994
  });
4939
4995
  var TradingviewWidget = forwardRef((props, ref) => {
4940
4996
  const state = useTradingviewScript(props);
4941
- return /* @__PURE__ */ jsx(TradingviewUI, { ...state, ref });
4997
+ return /* @__PURE__ */ jsx(TradingviewUI, { ...state });
4942
4998
  });
4943
4999
 
4944
- export { TradingviewUI, TradingviewWidget, useTradingviewScript };
5000
+ export { InjectableTradingviewDesktop, TradingviewUI, TradingviewWidget, useTradingviewScript };
4945
5001
  //# sourceMappingURL=index.mjs.map
4946
5002
  //# sourceMappingURL=index.mjs.map