@orderly.network/ui-share 3.0.4-alpha.4 → 3.1.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
+ import { i18n, useTranslation } from '@orderly.network/i18n';
1
2
  import { useEmblaCarousel, cn, Button, ChevronLeftIcon, ChevronRightIcon, registerSimpleDialog, registerSimpleSheet, Box, Flex, Text, Divider, ScrollArea, Input, CloseCircleFillIcon, toast } from '@orderly.network/ui';
2
3
  import React, { forwardRef, useImperativeHandle, useMemo, useState, useRef, useEffect, useCallback } from 'react';
3
4
  import { usePoster, useSymbolsInfo, useReferralInfo } from '@orderly.network/hooks';
4
- import { i18n, useTranslation } from '@orderly.network/i18n';
5
5
  import { EMPTY_LIST } from '@orderly.network/types';
6
6
  import { jsx, jsxs } from 'react/jsx-runtime';
7
7
  import { formatNum, Decimal } from '@orderly.network/utils';
@@ -57,6 +57,7 @@ var Poster = forwardRef((props, parentRef) => {
57
57
  ref,
58
58
  width,
59
59
  height,
60
+ dir: "ltr",
60
61
  className,
61
62
  style
62
63
  }
@@ -421,11 +422,17 @@ var NextButton = (props) => {
421
422
  };
422
423
  var CarouselBackgroundImage = (props) => {
423
424
  const { backgroundImages, selectedSnap, setSelectedSnap } = props;
425
+ const [direction, setDirection] = useState("ltr");
424
426
  const [emblaRef, emblaApi] = useEmblaCarousel({
425
427
  // loop: true,
426
428
  containScroll: "keepSnaps",
427
- dragFree: true
429
+ dragFree: true,
430
+ direction
428
431
  });
432
+ useEffect(() => {
433
+ const docDir = document?.documentElement?.dir?.toLowerCase();
434
+ setDirection(docDir === "rtl" ? "rtl" : "ltr");
435
+ }, []);
429
436
  const onPrevButtonClick = useCallback(() => {
430
437
  if (!emblaApi) {
431
438
  return;
@@ -463,7 +470,7 @@ var CarouselBackgroundImage = (props) => {
463
470
  };
464
471
  }, [emblaApi, onSelect]);
465
472
  return /* @__PURE__ */ jsxs(Flex, { mt: 4, px: 2, children: [
466
- /* @__PURE__ */ jsx(PrevButton, { onClick: onPrevButtonClick }),
473
+ direction === "rtl" ? /* @__PURE__ */ jsx(NextButton, { onClick: onNextButtonClick }) : /* @__PURE__ */ jsx(PrevButton, { onClick: onPrevButtonClick }),
467
474
  /* @__PURE__ */ jsx(
468
475
  "div",
469
476
  {
@@ -481,10 +488,9 @@ var CarouselBackgroundImage = (props) => {
481
488
  },
482
489
  mx: 2,
483
490
  my: 1,
484
- mr: 6,
485
491
  r: "base",
486
492
  className: cn(
487
- "oui-shrink-0 oui-w-[162px]",
493
+ "oui-shrink-0 oui-w-[162px] oui-me-6",
488
494
  selectedSnap === index && "oui-outline oui-outline-1 oui-outline-primary-darken"
489
495
  ),
490
496
  children: /* @__PURE__ */ jsx("img", { src: e, className: "oui-rounded-sm" })
@@ -493,7 +499,7 @@ var CarouselBackgroundImage = (props) => {
493
499
  )) })
494
500
  }
495
501
  ),
496
- /* @__PURE__ */ jsx(NextButton, { onClick: onNextButtonClick })
502
+ direction === "rtl" ? /* @__PURE__ */ jsx(PrevButton, { onClick: onPrevButtonClick }) : /* @__PURE__ */ jsx(NextButton, { onClick: onNextButtonClick })
497
503
  ] });
498
504
  };
499
505
  var Checkbox = (props) => {
@@ -565,7 +571,7 @@ var Message = (props) => {
565
571
  /* @__PURE__ */ jsx(
566
572
  "div",
567
573
  {
568
- className: "oui-text-xs oui-text-base-contrast-54 oui-ml-1 hover:oui-cursor-pointer",
574
+ className: "oui-text-xs oui-text-base-contrast-54 oui-ms-1 hover:oui-cursor-pointer",
569
575
  onClick: () => {
570
576
  setCheck(!props.check);
571
577
  },
@@ -586,7 +592,7 @@ var Message = (props) => {
586
592
  suffix: focus && /* @__PURE__ */ jsx(
587
593
  "button",
588
594
  {
589
- className: "oui-mr-3 oui-cursor-pointer",
595
+ className: "oui-me-3 oui-cursor-pointer",
590
596
  onMouseDown: (e) => {
591
597
  setMessage("");
592
598
  setTimeout(() => {
@@ -710,7 +716,7 @@ var PnlFormatView = (props) => {
710
716
  size: "xs",
711
717
  intensity: 54,
712
718
  className: cn(
713
- "oui-ml-2 "
719
+ "oui-ms-2 "
714
720
  // isSelected && "oui-text-base-contrast"
715
721
  ),
716
722
  children: text
@@ -791,6 +797,7 @@ var DesktopSharePnLContent = (props) => {
791
797
  backgroundImages: []
792
798
  };
793
799
  const [domain, setDomain] = useState("");
800
+ const direction = "ltr";
794
801
  const posterRef = useRef(null);
795
802
  useEffect(() => {
796
803
  const currentDomain = window.location.hostname;
@@ -850,6 +857,7 @@ var DesktopSharePnLContent = (props) => {
850
857
  height: 310,
851
858
  data: {
852
859
  backgroundImg: curBgImg,
860
+ direction,
853
861
  ...resetOptions,
854
862
  data: posterData
855
863
  },
@@ -1072,7 +1080,7 @@ var CarouselItem = React.forwardRef((originalProps, ref) => {
1072
1080
  "aria-roledescription": "slide",
1073
1081
  className: cn(
1074
1082
  "oui-min-w-0 oui-shrink-0 oui-grow-0 oui-basis-full",
1075
- orientation === "horizontal" ? "oui-pl-4" : "oui-pt-4",
1083
+ orientation === "horizontal" ? "oui-ps-4" : "oui-pt-4",
1076
1084
  className
1077
1085
  ),
1078
1086
  ...props,
@@ -1096,7 +1104,7 @@ var CarouselPrevious = React.forwardRef((originalProps, ref) => {
1096
1104
  variant,
1097
1105
  className: cn(
1098
1106
  "oui-absolute oui-size-8 oui-rounded-full",
1099
- orientation === "horizontal" ? "oui--left-12 oui-top-1/2 oui--translate-y-1/2" : "oui--top-12 oui-left-1/2 oui--translate-x-1/2 oui-rotate-90",
1107
+ orientation === "horizontal" ? "oui--start-12 oui-top-1/2 oui--translate-y-1/2" : "oui--top-12 oui-start-1/2 oui--translate-x-1/2 oui-rotate-90",
1100
1108
  className
1101
1109
  ),
1102
1110
  disabled: !canScrollPrev,
@@ -1125,7 +1133,7 @@ var CarouselNext = React.forwardRef((originalProps, ref) => {
1125
1133
  variant,
1126
1134
  className: cn(
1127
1135
  "oui-absolute oui-size-8 oui-rounded-full",
1128
- orientation === "horizontal" ? "oui--right-12 oui-top-1/2 oui--translate-y-1/2" : "oui--bottom-12 oui-left-1/2 oui--translate-x-1/2 oui-rotate-90",
1136
+ orientation === "horizontal" ? "oui--end-12 oui-top-1/2 oui--translate-y-1/2" : "oui--bottom-12 oui-start-1/2 oui--translate-x-1/2 oui-rotate-90",
1129
1137
  className
1130
1138
  ),
1131
1139
  disabled: !canScrollNext,
@@ -1196,6 +1204,7 @@ var MobileSharePnLContent = (props) => {
1196
1204
  backgroundImages: []
1197
1205
  };
1198
1206
  const [domain, setDomain] = useState("");
1207
+ const direction = "ltr";
1199
1208
  const posterRefs = shareOptions?.backgroundImages?.map(
1200
1209
  () => useRef(null)
1201
1210
  );
@@ -1282,6 +1291,7 @@ var MobileSharePnLContent = (props) => {
1282
1291
  height: 310,
1283
1292
  data: {
1284
1293
  backgroundImg: item,
1294
+ direction,
1285
1295
  ...resetOptions,
1286
1296
  data: posterData
1287
1297
  },
@@ -1349,7 +1359,7 @@ var MobileSharePnLContent = (props) => {
1349
1359
  suffix: focus && /* @__PURE__ */ jsx(
1350
1360
  "button",
1351
1361
  {
1352
- className: "oui-mr-3 oui-cursor-pointer",
1362
+ className: "oui-me-3 oui-cursor-pointer",
1353
1363
  onMouseDown: (e) => {
1354
1364
  setMessage("");
1355
1365
  setTimeout(() => {
@@ -1392,7 +1402,7 @@ var PnlFormatView2 = (props) => {
1392
1402
  case "pnl":
1393
1403
  return t("share.pnl.displayFormat.pnl");
1394
1404
  }
1395
- }, [type]);
1405
+ }, [t, type]);
1396
1406
  const isSelected = type === curType;
1397
1407
  return /* @__PURE__ */ jsx(
1398
1408
  "div",
@@ -1570,6 +1580,8 @@ var SharePnLDialogWidget = (props) => {
1570
1580
  });
1571
1581
  return /* @__PURE__ */ jsx(DesktopSharePnL, { ...state });
1572
1582
  };
1583
+
1584
+ // src/index.ts
1573
1585
  var SharePnLDialogId = "sharePnLDialog";
1574
1586
  var SharePnLBottomSheetId = "sharePnLBottomSheet";
1575
1587
  registerSimpleDialog(SharePnLDialogId, SharePnLDialogWidget, {
@@ -1578,7 +1590,7 @@ registerSimpleDialog(SharePnLDialogId, SharePnLDialogWidget, {
1578
1590
  }
1579
1591
  });
1580
1592
  registerSimpleSheet(SharePnLBottomSheetId, SharePnLBottomSheetWidget, {
1581
- title: i18n.t("share.pnl.sharePnl"),
1593
+ title: () => i18n.t("share.pnl.sharePnl"),
1582
1594
  classNames: {
1583
1595
  body: "oui-pb-4 oui-pt-0"
1584
1596
  }