@orderly.network/ui-scaffold 2.8.3 → 2.8.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.d.mts CHANGED
@@ -48,6 +48,7 @@ type MainNavItem = {
48
48
  id?: string;
49
49
  testid?: string;
50
50
  name: string;
51
+ label?: string;
51
52
  href: string;
52
53
  target?: HTMLAttributeAnchorTarget;
53
54
  icon?: string | react__default.ReactElement;
package/dist/index.d.ts CHANGED
@@ -48,6 +48,7 @@ type MainNavItem = {
48
48
  id?: string;
49
49
  testid?: string;
50
50
  name: string;
51
+ label?: string;
51
52
  href: string;
52
53
  target?: HTMLAttributeAnchorTarget;
53
54
  icon?: string | react__default.ReactElement;
package/dist/index.js CHANGED
@@ -2452,8 +2452,8 @@ var LeftNavSheet = (props) => {
2452
2452
  const { state } = hooks.useAccount();
2453
2453
  const { t } = i18n.useTranslation();
2454
2454
  const { primaryMenus, secondaryMenus } = React6.useMemo(() => {
2455
- const primary = (props.menus || []).filter((m) => !m.isSecondary);
2456
- const secondary = (props.menus || []).filter((m) => m.isSecondary);
2455
+ const primary = (props?.menus || []).filter((m) => !m.isSecondary);
2456
+ const secondary = (props?.menus || []).filter((m) => m.isSecondary);
2457
2457
  return { primaryMenus: primary, secondaryMenus: secondary };
2458
2458
  }, [props.menus]);
2459
2459
  const showSubAccount = React6.useMemo(
@@ -4429,6 +4429,7 @@ var Scaffold = (props) => {
4429
4429
  };
4430
4430
 
4431
4431
  // src/components/main/mainNav.script.ts
4432
+ var NON_ROUTING_HREFS = ["/vaults"];
4432
4433
  var CampaignPositionEnum = /* @__PURE__ */ ((CampaignPositionEnum3) => {
4433
4434
  CampaignPositionEnum3["menuLeading"] = "menuLeading";
4434
4435
  CampaignPositionEnum3["menuTailing"] = "menuTailing";
@@ -4454,6 +4455,17 @@ var useMainNavScript = (props) => {
4454
4455
  setCurrent(item.map((item2) => item2.href));
4455
4456
  }
4456
4457
  const current2 = item[item.length - 1];
4458
+ const isExternalLink = typeof current2.href === "string" && (current2.href.startsWith("http://") || current2.href.startsWith("https://"));
4459
+ if (NON_ROUTING_HREFS.includes(current2.href)) {
4460
+ return;
4461
+ }
4462
+ if (current2.target) {
4463
+ window.open(current2.href, current2.target);
4464
+ return;
4465
+ } else if (isExternalLink) {
4466
+ window.location.href = current2.href;
4467
+ return;
4468
+ }
4457
4469
  const args = {
4458
4470
  href: current2.href,
4459
4471
  name: current2.name,
@@ -4689,22 +4701,6 @@ var CurrentLeverage = (props) => {
4689
4701
  }
4690
4702
  );
4691
4703
  };
4692
- var MaxLeverage = (props) => {
4693
- const { t } = i18n.useTranslation();
4694
- return /* @__PURE__ */ jsxRuntime.jsxs(
4695
- ui.Flex,
4696
- {
4697
- direction: "column",
4698
- gap: 0,
4699
- className: "oui-text-2xs",
4700
- itemAlign: "start",
4701
- children: [
4702
- /* @__PURE__ */ jsxRuntime.jsx(ui.Box, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { intensity: 54, className: "oui-whitespace-nowrap", children: t("leverage.maxLeverage") }) }),
4703
- /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { color: "primary", as: "div", children: `${props.maxLeverage ?? "--"}x` })
4704
- ]
4705
- }
4706
- );
4707
- };
4708
4704
  var UnrealPnL = (props) => {
4709
4705
  const { visible, onToggleVisibility, visibleAvailable = true } = props;
4710
4706
  const { t } = i18n.useTranslation();
@@ -4861,27 +4857,6 @@ var AccountInfoPopover = (props) => {
4861
4857
  }
4862
4858
  )
4863
4859
  ] }, key);
4864
- case "maxLeverage":
4865
- return /* @__PURE__ */ jsxRuntime.jsxs(DropdownMenu, { onSetTop: onSetToTop("maxLeverage"), children: [
4866
- /* @__PURE__ */ jsxRuntime.jsxs(ui.Flex, { className: "oui-text-base-contrast-54", gapX: 2, children: [
4867
- /* @__PURE__ */ jsxRuntime.jsx(
4868
- IdentityButton,
4869
- {
4870
- active: keys.includes("maxLeverage"),
4871
- onClick: () => props.onToggleItemByKey("maxLeverage")
4872
- }
4873
- ),
4874
- /* @__PURE__ */ jsxRuntime.jsx("span", { children: t("leverage.maxLeverage") })
4875
- ] }),
4876
- /* @__PURE__ */ jsxRuntime.jsx(
4877
- ui.Text,
4878
- {
4879
- className: "group-hover:-oui-translate-x-5 oui-transition-transform",
4880
- color: "primary",
4881
- children: `${props.maxLeverage ?? "-"}x`
4882
- }
4883
- )
4884
- ] }, key);
4885
4860
  default:
4886
4861
  return null;
4887
4862
  }
@@ -5029,10 +5004,6 @@ var AccountSummary = (props) => {
5029
5004
  canToggleIndex++;
5030
5005
  return /* @__PURE__ */ jsxRuntime.jsx(CurrentLeverage, { currentLeverage: props.currentLeverage });
5031
5006
  }
5032
- case "maxLeverage": {
5033
- canToggleIndex++;
5034
- return /* @__PURE__ */ jsxRuntime.jsx(MaxLeverage, { maxLeverage: props.maxLeverage });
5035
- }
5036
5007
  case "totalValue":
5037
5008
  default:
5038
5009
  return /* @__PURE__ */ jsxRuntime.jsx(
@@ -5056,7 +5027,6 @@ var AccountSummary = (props) => {
5056
5027
  {
5057
5028
  totalValue: rest.totalValue,
5058
5029
  freeCollateral: props.freeCollateral,
5059
- maxLeverage: props.maxLeverage,
5060
5030
  currentLeverage: props.currentLeverage,
5061
5031
  unrealized_pnl_ROI: props.unrealized_pnl_ROI,
5062
5032
  unrealPnL: props.unrealPnL,
@@ -5159,7 +5129,7 @@ var AccountSummaryWidget = () => {
5159
5129
  );
5160
5130
  };
5161
5131
  var MessageCenter = (props) => {
5162
- const { maintenanceDialogInfo, messages, showAnnouncement } = props;
5132
+ const { maintenanceDialogInfo, messages, showAnnouncement, closeTips } = props;
5163
5133
  const { routerAdapter } = useScaffoldContext();
5164
5134
  const { t } = i18n.useTranslation();
5165
5135
  const messageSize = React6.useMemo(() => messages.length, [messages]);
@@ -5192,7 +5162,12 @@ var MessageCenter = (props) => {
5192
5162
  ui.Popover,
5193
5163
  {
5194
5164
  open: popoverOpen,
5195
- onOpenChange: setPopoverOpen,
5165
+ onOpenChange: (open2) => {
5166
+ setPopoverOpen(open2);
5167
+ if (open2) {
5168
+ closeTips();
5169
+ }
5170
+ },
5196
5171
  arrow: true,
5197
5172
  content: /* @__PURE__ */ jsxRuntime.jsx(
5198
5173
  uiNotification.AnnouncementCenterUI,
@@ -5231,7 +5206,8 @@ var MessageCenterWidget = () => {
5231
5206
  {
5232
5207
  messages: announcementState.tips,
5233
5208
  maintenanceDialogInfo: announcementState.maintenanceDialogInfo,
5234
- showAnnouncement: announcementState.showAnnouncement
5209
+ showAnnouncement: announcementState.showAnnouncement,
5210
+ closeTips: announcementState.closeTips
5235
5211
  }
5236
5212
  );
5237
5213
  };
@@ -5325,6 +5301,7 @@ var NavItem2 = (props) => {
5325
5301
  "data-actived": isActive,
5326
5302
  className: ui.cn(
5327
5303
  "oui-group oui-relative oui-h-[32px] oui-rounded oui-px-3 oui-py-1 oui-text-sm oui-text-base-contrast-36 hover:oui-bg-base-7",
5304
+ item.className,
5328
5305
  classNames?.navItem
5329
5306
  ),
5330
5307
  onClick: onClickHandler,
@@ -5337,7 +5314,7 @@ var NavItem2 = (props) => {
5337
5314
  color: isActive ? "brand" : "inherit",
5338
5315
  angle: 45,
5339
5316
  className: "oui-whitespace-nowrap oui-break-normal",
5340
- children: item.name
5317
+ children: item.label ?? item.name
5341
5318
  }
5342
5319
  ),
5343
5320
  hasSubMenu && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "oui-ml-1 group-data-[open=true]:oui-rotate-180", children: isActive ? /* @__PURE__ */ jsxRuntime.jsx(ActiveIcon, {}) : /* @__PURE__ */ jsxRuntime.jsx(ui.ChevronDownIcon, { size: 12, color: "white" }) })
@@ -5449,7 +5426,7 @@ var SubMenus = (props) => {
5449
5426
  }
5450
5427
  },
5451
5428
  className: ui.cn(
5452
- customSubMenuRender ? "oui-w-auto oui-p-0 oui-border-0 oui-rounded-lg" : "oui-w-[260px] oui-space-y-[2px] oui-border oui-border-line-6 oui-p-1",
5429
+ customSubMenuRender ? "oui-w-auto oui-p-0 oui-border-0 oui-rounded-lg" : "oui-w-[200px] oui-space-y-[2px] oui-border oui-border-line-6 oui-p-1",
5453
5430
  className
5454
5431
  ),
5455
5432
  children: customSubMenuRender ? customSubMenuRender() : items.map((item, index) => {
@@ -5509,24 +5486,21 @@ var SubMenu = (props) => {
5509
5486
  };
5510
5487
  var SubMenuTitle = (props) => {
5511
5488
  const { item, isActive } = props;
5512
- return /* @__PURE__ */ jsxRuntime.jsxs(ui.Flex, { itemAlign: "center", width: "100%", position: "relative", children: [
5513
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "oui-flex oui-flex-1", children: [
5514
- /* @__PURE__ */ jsxRuntime.jsx(
5515
- ui.Text.gradient,
5516
- {
5517
- color: isActive ? "brand" : "inherit",
5518
- size: "xs",
5519
- as: "div",
5520
- intensity: 80,
5521
- weight: "semibold",
5522
- className: "oui-whitespace-nowrap oui-break-normal",
5523
- children: item.name
5524
- }
5525
- ),
5526
- typeof item.tag !== "undefined" && /* @__PURE__ */ jsxRuntime.jsx(Tag, { item })
5527
- ] }),
5528
- item.target === "_blank" && /* @__PURE__ */ jsxRuntime.jsx(OutlinkIcon, {})
5529
- ] });
5489
+ return /* @__PURE__ */ jsxRuntime.jsx(ui.Flex, { itemAlign: "center", width: "100%", position: "relative", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "oui-flex oui-flex-1", children: [
5490
+ /* @__PURE__ */ jsxRuntime.jsx(
5491
+ ui.Text.gradient,
5492
+ {
5493
+ color: isActive ? "brand" : "inherit",
5494
+ size: "xs",
5495
+ as: "div",
5496
+ intensity: 80,
5497
+ weight: "semibold",
5498
+ className: "oui-whitespace-nowrap oui-break-normal",
5499
+ children: item.name
5500
+ }
5501
+ ),
5502
+ typeof item.tag !== "undefined" && /* @__PURE__ */ jsxRuntime.jsx(Tag, { item })
5503
+ ] }) });
5530
5504
  };
5531
5505
  var Tag = (props) => {
5532
5506
  return /* @__PURE__ */ jsxRuntime.jsx(
@@ -5583,64 +5557,6 @@ var ItemIcon = (props) => {
5583
5557
  )
5584
5558
  ] });
5585
5559
  };
5586
- var OutlinkIcon = () => {
5587
- return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
5588
- /* @__PURE__ */ jsxRuntime.jsx(
5589
- "svg",
5590
- {
5591
- width: "20",
5592
- height: "20",
5593
- viewBox: "0 0 20 20",
5594
- fill: "none",
5595
- xmlns: "http://www.w3.org/2000/svg",
5596
- className: "oui-absolute oui-right-0 oui-top-0 group-hover:oui-invisible",
5597
- children: /* @__PURE__ */ jsxRuntime.jsx(
5598
- "path",
5599
- {
5600
- d: "M14.159 17.492a3.333 3.333 0 0 0 3.333-3.333V5.826a3.333 3.333 0 0 0-3.333-3.334H5.826a3.333 3.333 0 0 0-3.334 3.334v8.333a3.333 3.333 0 0 0 3.334 3.333zm-6.667-4.166a.85.85 0 0 1-.599-.235.86.86 0 0 1 0-1.198l3.333-3.333-1.9-1.901h5v5l-1.901-1.9L8.09 13.09a.84.84 0 0 1-.599.235",
5601
- fill: "#fff",
5602
- fillOpacity: ".2"
5603
- }
5604
- )
5605
- }
5606
- ),
5607
- /* @__PURE__ */ jsxRuntime.jsxs(
5608
- "svg",
5609
- {
5610
- width: "20",
5611
- height: "20",
5612
- viewBox: "0 0 20 20",
5613
- fill: "none",
5614
- xmlns: "http://www.w3.org/2000/svg",
5615
- className: "oui-invisible oui-absolute oui-right-0 oui-top-0 group-hover:oui-visible",
5616
- children: [
5617
- /* @__PURE__ */ jsxRuntime.jsx(
5618
- "path",
5619
- {
5620
- d: "M14.159 17.492a3.333 3.333 0 0 0 3.333-3.333V5.826a3.333 3.333 0 0 0-3.333-3.334H5.826a3.333 3.333 0 0 0-3.334 3.334v8.333a3.333 3.333 0 0 0 3.334 3.333zm-6.667-4.166a.85.85 0 0 1-.599-.235.86.86 0 0 1 0-1.198l3.333-3.333-1.9-1.901h5v5l-1.901-1.9L8.09 13.09a.84.84 0 0 1-.599.235",
5621
- fill: "url(#outlineIcon)"
5622
- }
5623
- ),
5624
- /* @__PURE__ */ jsxRuntime.jsx("defs", { children: /* @__PURE__ */ jsxRuntime.jsxs(
5625
- "linearGradient",
5626
- {
5627
- id: "outlineIcon",
5628
- x1: "17.492",
5629
- y1: "9.992",
5630
- x2: "2.492",
5631
- y2: "9.992",
5632
- gradientUnits: "userSpaceOnUse",
5633
- children: [
5634
- /* @__PURE__ */ jsxRuntime.jsx("stop", { stopColor: "rgb(var(--oui-gradient-brand-end))" }),
5635
- /* @__PURE__ */ jsxRuntime.jsx("stop", { offset: "1", stopColor: "rgb(var(--oui-gradient-brand-start))" })
5636
- ]
5637
- }
5638
- ) })
5639
- ]
5640
- }
5641
- )
5642
- ] });
5643
- };
5644
5560
  var CampaignButton = (props) => {
5645
5561
  return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: /* @__PURE__ */ jsxRuntime.jsx(
5646
5562
  NavItem2,
@@ -5663,7 +5579,8 @@ var MainNavMenus = (props) => {
5663
5579
  {
5664
5580
  item,
5665
5581
  currentPath: props.current,
5666
- onClick: props.onItemClick
5582
+ onClick: props.onItemClick,
5583
+ classNames
5667
5584
  },
5668
5585
  index
5669
5586
  )) });
@@ -5775,7 +5692,7 @@ var MainNav = (props) => {
5775
5692
  px: 3,
5776
5693
  gapX: 3,
5777
5694
  className: ui.cn(
5778
- "oui-main-nav oui-font-semibold",
5695
+ "oui-main-nav oui-font-semibold oui-border-0 lg:oui-border-b-white/[0.12] lg:oui-border-b",
5779
5696
  className,
5780
5697
  classNames?.root
5781
5698
  ),