@orderly.network/trading 2.8.5-alpha.0 → 2.8.6-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 CHANGED
@@ -5,8 +5,8 @@ var React11 = require('react');
5
5
  var reactApp = require('@orderly.network/react-app');
6
6
  var types = require('@orderly.network/types');
7
7
  var uiOrders = require('@orderly.network/ui-orders');
8
- var ui = require('@orderly.network/ui');
9
8
  var i18n = require('@orderly.network/i18n');
9
+ var ui = require('@orderly.network/ui');
10
10
  var jsxRuntime = require('react/jsx-runtime');
11
11
  var uiPositions = require('@orderly.network/ui-positions');
12
12
  var utils = require('@orderly.network/utils');
@@ -186,6 +186,113 @@ var init_setting_ui = __esm({
186
186
  Setting = (props) => {
187
187
  const [open, setOpen] = React11.useState(false);
188
188
  const { t } = i18n.useTranslation();
189
+ const { isMobile } = ui.useScreen();
190
+ const SettingsContent = React11.useMemo(() => {
191
+ return () => /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
192
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "oui-flex oui-flex-col oui-text-sm", children: [
193
+ /* @__PURE__ */ jsxRuntime.jsx(
194
+ ui.Flex,
195
+ {
196
+ itemAlign: "center",
197
+ justify: isMobile ? "center" : "start",
198
+ className: "oui-w-full",
199
+ children: /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "oui-text-base oui-pb-3", children: t("trading.portfolioSettings") })
200
+ }
201
+ ),
202
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Divider, {}),
203
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "oui-pb-3 oui-text-base-contrast-54 oui-mt-2", children: t("trading.portfolioSettings.decimalPrecision") }),
204
+ /* @__PURE__ */ jsxRuntime.jsx(
205
+ DecimalPrecisionCheckbox,
206
+ {
207
+ value: props.pnlNotionalDecimalPrecision,
208
+ onValueChange: (e) => {
209
+ props.setPnlNotionalDecimalPrecision(e);
210
+ setOpen(false);
211
+ }
212
+ }
213
+ ),
214
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Divider, { className: "oui-my-3" }),
215
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "oui-pb-3 oui-text-base-contrast-54 oui-mt-2", children: t("trading.portfolioSettings.unrealPnlPriceBasis") }),
216
+ /* @__PURE__ */ jsxRuntime.jsx(
217
+ UnPnlPriceBasisCheckBox,
218
+ {
219
+ value: props.unPnlPriceBasis,
220
+ onValueChange: (e) => {
221
+ props.setUnPnlPriceBasic(e);
222
+ setOpen(false);
223
+ }
224
+ }
225
+ )
226
+ ] }),
227
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Divider, { className: "oui-my-3" }),
228
+ /* @__PURE__ */ jsxRuntime.jsxs(ui.Flex, { itemAlign: "center", gap: 1, justify: "between", children: [
229
+ /* @__PURE__ */ jsxRuntime.jsxs(ui.Flex, { gap: 1, itemAlign: "center", children: [
230
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "sm", intensity: 54, children: t("trading.portfolioSettings.reversePosition") }),
231
+ isMobile ? /* @__PURE__ */ jsxRuntime.jsx(
232
+ ui.ExclamationFillIcon,
233
+ {
234
+ size: 14,
235
+ className: "oui-text-base-contrast-54 hover:oui-text-base-contrast-80 oui-cursor-pointer",
236
+ onClick: () => {
237
+ ui.modal.alert({
238
+ title: t("common.tips"),
239
+ message: t(
240
+ "trading.portfolioSettings.reversePosition.tooltip"
241
+ )
242
+ });
243
+ }
244
+ }
245
+ ) : /* @__PURE__ */ jsxRuntime.jsx(
246
+ ui.Tooltip,
247
+ {
248
+ content: t("trading.portfolioSettings.reversePosition.tooltip"),
249
+ className: "oui-max-w-[300px]",
250
+ children: /* @__PURE__ */ jsxRuntime.jsx(
251
+ ui.ExclamationFillIcon,
252
+ {
253
+ size: 14,
254
+ className: "oui-text-base-contrast-54 hover:oui-text-base-contrast-80 oui-cursor-pointer"
255
+ }
256
+ )
257
+ }
258
+ )
259
+ ] }),
260
+ /* @__PURE__ */ jsxRuntime.jsx(
261
+ ui.Switch,
262
+ {
263
+ checked: props.reversePosition,
264
+ onCheckedChange: (checked) => {
265
+ props.setReversePosition(checked);
266
+ }
267
+ }
268
+ )
269
+ ] })
270
+ ] });
271
+ }, [
272
+ t,
273
+ isMobile,
274
+ props.pnlNotionalDecimalPrecision,
275
+ props.unPnlPriceBasis,
276
+ props.reversePosition
277
+ ]);
278
+ const triggerButton = /* @__PURE__ */ jsxRuntime.jsx(
279
+ ui.Button,
280
+ {
281
+ size: "xs",
282
+ type: "button",
283
+ variant: "contained",
284
+ className: "oui-bg-transparent hover:oui-bg-transparent",
285
+ children: /* @__PURE__ */ jsxRuntime.jsx(
286
+ ui.SettingFillIcon,
287
+ {
288
+ size: 16,
289
+ color: "white",
290
+ opacity: 1,
291
+ className: "oui-text-white/[.36] hover:oui-text-white/80"
292
+ }
293
+ )
294
+ }
295
+ );
189
296
  return /* @__PURE__ */ jsxRuntime.jsxs(ui.Flex, { gap: 0, children: [
190
297
  /* @__PURE__ */ jsxRuntime.jsxs(ui.Flex, { gap: 1, children: [
191
298
  /* @__PURE__ */ jsxRuntime.jsx(
@@ -208,58 +315,26 @@ var init_setting_ui = __esm({
208
315
  }
209
316
  )
210
317
  ] }),
211
- /* @__PURE__ */ jsxRuntime.jsxs(ui.DropdownMenuRoot, { open, onOpenChange: setOpen, children: [
212
- /* @__PURE__ */ jsxRuntime.jsx(ui.DropdownMenuTrigger, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(
213
- ui.Button,
318
+ isMobile ? /* @__PURE__ */ jsxRuntime.jsxs(ui.Sheet, { open, onOpenChange: setOpen, children: [
319
+ /* @__PURE__ */ jsxRuntime.jsx(ui.SheetTrigger, { asChild: true, children: triggerButton }),
320
+ /* @__PURE__ */ jsxRuntime.jsx(ui.SheetContent, { side: "bottom", className: "oui-px-5 oui-pt-3", children: /* @__PURE__ */ jsxRuntime.jsx(
321
+ "div",
214
322
  {
215
- size: "xs",
216
- type: "button",
217
- variant: "contained",
218
- className: "oui-bg-transparent hover:oui-bg-transparent",
219
- children: /* @__PURE__ */ jsxRuntime.jsx(
220
- ui.SettingFillIcon,
221
- {
222
- size: 16,
223
- color: "white",
224
- opacity: 1,
225
- className: "oui-text-white/[.36] hover:oui-text-white/80"
226
- }
227
- )
323
+ style: {
324
+ paddingBottom: `max(32px, calc(12px + env(safe-area-inset-bottom)))`
325
+ },
326
+ children: /* @__PURE__ */ jsxRuntime.jsx(SettingsContent, {})
228
327
  }
229
- ) }),
328
+ ) })
329
+ ] }) : /* @__PURE__ */ jsxRuntime.jsxs(ui.DropdownMenuRoot, { open, onOpenChange: setOpen, children: [
330
+ /* @__PURE__ */ jsxRuntime.jsx(ui.DropdownMenuTrigger, { asChild: true, children: triggerButton }),
230
331
  /* @__PURE__ */ jsxRuntime.jsx(
231
332
  ui.DropdownMenuContent,
232
333
  {
233
334
  className: "oui-px-5 oui-py-3 oui-w-[360px]",
234
335
  alignOffset: 2,
235
336
  align: "end",
236
- children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "oui-flex oui-flex-col oui-text-sm", children: [
237
- /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "oui-text-base oui-pb-3", children: t("trading.portfolioSettings") }),
238
- /* @__PURE__ */ jsxRuntime.jsx(ui.Divider, {}),
239
- /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "oui-pb-3 oui-text-base-contrast-54 oui-mt-2", children: t("trading.portfolioSettings.decimalPrecision") }),
240
- /* @__PURE__ */ jsxRuntime.jsx(
241
- DecimalPrecisionCheckbox,
242
- {
243
- value: props.pnlNotionalDecimalPrecision,
244
- onValueChange: (e) => {
245
- props.setPnlNotionalDecimalPrecision(e);
246
- setOpen(false);
247
- }
248
- }
249
- ),
250
- /* @__PURE__ */ jsxRuntime.jsx(ui.Divider, { className: "oui-my-3" }),
251
- /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "oui-pb-3 oui-text-base-contrast-54 oui-mt-2", children: t("trading.portfolioSettings.unrealPnlPriceBasis") }),
252
- /* @__PURE__ */ jsxRuntime.jsx(
253
- UnPnlPriceBasisCheckBox,
254
- {
255
- value: props.unPnlPriceBasis,
256
- onValueChange: (e) => {
257
- props.setUnPnlPriceBasic(e);
258
- setOpen(false);
259
- }
260
- }
261
- )
262
- ] })
337
+ children: /* @__PURE__ */ jsxRuntime.jsx(SettingsContent, {})
263
338
  }
264
339
  )
265
340
  ] })
@@ -385,14 +460,15 @@ var init_setting_ui = __esm({
385
460
  };
386
461
  }
387
462
  });
388
-
389
- // src/components/desktop/dataList/setting/setting.script.tsx
390
463
  var useSettingScript;
391
464
  var init_setting_script = __esm({
392
465
  "src/components/desktop/dataList/setting/setting.script.tsx"() {
393
466
  useSettingScript = (props) => {
467
+ const { isEnabled, setEnabled } = uiPositions.useReversePositionEnabled();
394
468
  return {
395
- ...props
469
+ ...props,
470
+ reversePosition: isEnabled,
471
+ setReversePosition: setEnabled
396
472
  };
397
473
  };
398
474
  }
@@ -424,6 +500,7 @@ var init_setting = __esm({
424
500
  var PositionHeader, MobileLayout, DesktopLayout, UnrealPnL, Notional;
425
501
  var init_positionHeader_ui = __esm({
426
502
  "src/components/base/positionHeader/positionHeader.ui.tsx"() {
503
+ init_setting();
427
504
  PositionHeader = (props) => {
428
505
  const { isMobile } = ui.useScreen();
429
506
  return isMobile ? /* @__PURE__ */ jsxRuntime.jsx(MobileLayout, { ...props }) : /* @__PURE__ */ jsxRuntime.jsx(DesktopLayout, { ...props });
@@ -470,27 +547,19 @@ var init_positionHeader_ui = __esm({
470
547
  justify: "between",
471
548
  width: "100%",
472
549
  children: [
473
- /* @__PURE__ */ jsxRuntime.jsxs(ui.Flex, { children: [
474
- /* @__PURE__ */ jsxRuntime.jsx(
475
- ui.Checkbox,
476
- {
477
- id: "oui-checkbox-hideOtherSymbols",
478
- color: "white",
479
- checked: !props.showAllSymbol,
480
- onCheckedChange: (checked) => {
481
- props.setShowAllSymbol(!checked);
482
- }
483
- }
484
- ),
485
- /* @__PURE__ */ jsxRuntime.jsx(
486
- "label",
487
- {
488
- className: "oui-cursor-pointer oui-text-2xs oui-text-base-contrast-54 oui-ml-1",
489
- htmlFor: "oui-checkbox-hideOtherSymbols",
490
- children: t("trading.hideOtherSymbols")
550
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Flex, { children: /* @__PURE__ */ jsxRuntime.jsx(
551
+ SettingWidget,
552
+ {
553
+ pnlNotionalDecimalPrecision: props.pnlNotionalDecimalPrecision,
554
+ setPnlNotionalDecimalPrecision: props.setPnlNotionalDecimalPrecision,
555
+ unPnlPriceBasis: props.unPnlPriceBasis,
556
+ setUnPnlPriceBasic: props.setUnPnlPriceBasic,
557
+ hideOtherSymbols: !props.showAllSymbol,
558
+ setHideOtherSymbols: (value) => {
559
+ props.setShowAllSymbol(!value);
491
560
  }
492
- )
493
- ] }),
561
+ }
562
+ ) }),
494
563
  /* @__PURE__ */ jsxRuntime.jsx(uiPositions.CloseAllPositionsWidget, { symbol: props.symbol })
495
564
  ]
496
565
  }
@@ -567,7 +636,13 @@ var init_positionHeader_script = __esm({
567
636
  "src/components/base/positionHeader/positionHeader.script.tsx"() {
568
637
  init_hooks();
569
638
  usePositionHeaderScript = (inputs) => {
570
- const { pnlNotionalDecimalPrecision, unPnlPriceBasis, symbol } = inputs;
639
+ const {
640
+ pnlNotionalDecimalPrecision,
641
+ setPnlNotionalDecimalPrecision,
642
+ unPnlPriceBasis,
643
+ setUnPnlPriceBasic,
644
+ symbol
645
+ } = inputs;
571
646
  const calcMode = unPnlPriceBasis;
572
647
  const [data] = hooks.usePositionStream(symbol, {
573
648
  calcMode
@@ -584,7 +659,10 @@ var init_positionHeader_script = __esm({
584
659
  notional,
585
660
  showAllSymbol,
586
661
  setShowAllSymbol,
587
- symbol
662
+ symbol,
663
+ setPnlNotionalDecimalPrecision,
664
+ unPnlPriceBasis,
665
+ setUnPnlPriceBasic
588
666
  };
589
667
  };
590
668
  }
@@ -632,8 +710,10 @@ var init_dataList_ui = __esm({
632
710
  /* @__PURE__ */ jsxRuntime.jsx(React11__default.default.Suspense, { fallback: null, children: /* @__PURE__ */ jsxRuntime.jsx(
633
711
  LazyPositionHeaderWidget,
634
712
  {
713
+ setPnlNotionalDecimalPrecision: props.setPnlNotionalDecimalPrecision,
635
714
  pnlNotionalDecimalPrecision: props.pnlNotionalDecimalPrecision,
636
715
  symbol: !!props.showAllSymbol ? void 0 : props.symbol,
716
+ setUnPnlPriceBasic: props.setUnPnlPriceBasic,
637
717
  unPnlPriceBasis: props.unPnlPriceBasis
638
718
  }
639
719
  ) }),
@@ -5180,8 +5260,10 @@ var init_dataList_ui2 = __esm({
5180
5260
  LazyPositionHeaderWidget2,
5181
5261
  {
5182
5262
  pnlNotionalDecimalPrecision: props.pnlNotionalDecimalPrecision,
5263
+ setPnlNotionalDecimalPrecision: props.setPnlNotionalDecimalPrecision,
5183
5264
  symbol: props.showAllSymbol ? void 0 : props.symbol,
5184
- unPnlPriceBasis: props.unPnlPriceBasis
5265
+ unPnlPriceBasis: props.unPnlPriceBasis,
5266
+ setUnPnlPriceBasic: props.setUnPnlPriceBasic
5185
5267
  }
5186
5268
  ) }),
5187
5269
  /* @__PURE__ */ jsxRuntime.jsx(React11__default.default.Suspense, { fallback: null, children: /* @__PURE__ */ jsxRuntime.jsx(