@loafmarkets/ui 0.1.386 → 0.1.387

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
@@ -5036,13 +5036,7 @@ function useIsNarrow(maxWidthPx = 768) {
5036
5036
  }, [query]);
5037
5037
  return narrow;
5038
5038
  }
5039
- var DEFAULT_TRADE_PATH = "/trade";
5040
5039
  var DEFAULT_HOME_PATH = "/";
5041
- var DEFAULT_ABOUT_PATH = "/about";
5042
- var DEFAULT_LEARN_PATH = "/learn";
5043
- var DEFAULT_API_PATH = "/api";
5044
- var DEFAULT_PROPERTY_MAP_PATH = "/map";
5045
- var DEFAULT_PORTFOLIO_PATH = "/portfolio";
5046
5040
  var DEFAULT_LOAF_LIQUIDITY_PATH = "/loaf-liquidity";
5047
5041
  var DEFAULT_AUTH_RETURN_PARAM = "returnTo";
5048
5042
  var LOGIN_POPUP_EVENT = "loaf:open-login-popup";
@@ -5050,19 +5044,13 @@ var Header = ({
5050
5044
  currentUser,
5051
5045
  isAuthenticated = false,
5052
5046
  locationPath = DEFAULT_HOME_PATH,
5053
- activeTab,
5047
+ navItems,
5048
+ activeKey,
5054
5049
  onNavigate,
5055
5050
  onLogout,
5056
5051
  onSignInClick,
5057
5052
  loginPopupComponent: LoginPopupComponent,
5058
- tradePath = DEFAULT_TRADE_PATH,
5059
5053
  homePath = DEFAULT_HOME_PATH,
5060
- aboutPath = DEFAULT_ABOUT_PATH,
5061
- learnPath = DEFAULT_LEARN_PATH,
5062
- apiPath = DEFAULT_API_PATH,
5063
- offeringsPath,
5064
- propertyMapPath = DEFAULT_PROPERTY_MAP_PATH,
5065
- portfolioPath = DEFAULT_PORTFOLIO_PATH,
5066
5054
  loafLiquidityPath = DEFAULT_LOAF_LIQUIDITY_PATH,
5067
5055
  authLoginUrl,
5068
5056
  authReturnParam = DEFAULT_AUTH_RETURN_PARAM,
@@ -5070,12 +5058,10 @@ var Header = ({
5070
5058
  logoHref,
5071
5059
  onLogoClick,
5072
5060
  onLoafLiquidityClick,
5073
- onTradeClick,
5074
5061
  onProfileNavigate: _onProfileNavigate,
5075
5062
  onOrdersNavigate: _onOrdersNavigate,
5076
5063
  onWalletNavigate: _onWalletNavigate,
5077
5064
  onSettingsClick,
5078
- showTradeTab = true,
5079
5065
  portfolioSummary,
5080
5066
  fundsPending = false,
5081
5067
  transparentOnTop = false
@@ -5219,10 +5205,6 @@ var Header = ({
5219
5205
  window.location.href = path;
5220
5206
  }
5221
5207
  };
5222
- const handleNavigation = (path) => {
5223
- closeMenus();
5224
- performNavigation(path);
5225
- };
5226
5208
  const handleLogoNavigation = (event) => {
5227
5209
  event.preventDefault();
5228
5210
  closeMenus();
@@ -5240,16 +5222,19 @@ var Header = ({
5240
5222
  }
5241
5223
  performNavigation(resolvedLoafLiquidityPath);
5242
5224
  };
5243
- const handleTradeNavigation = () => {
5244
- if (!showTradeTab) {
5225
+ const handleNavItem = (item) => {
5226
+ closeMenus();
5227
+ if (item.onSelect) {
5228
+ item.onSelect();
5245
5229
  return;
5246
5230
  }
5247
- closeMenus();
5248
- if (onTradeClick) {
5249
- onTradeClick();
5231
+ if (item.external) {
5232
+ if (typeof window !== "undefined") {
5233
+ window.open(item.path, "_blank", "noopener,noreferrer");
5234
+ }
5250
5235
  return;
5251
5236
  }
5252
- performNavigation(resolvedTradePath);
5237
+ performNavigation(item.path);
5253
5238
  };
5254
5239
  const handleLogoutClick = async (event) => {
5255
5240
  event?.preventDefault();
@@ -5327,36 +5312,23 @@ var Header = ({
5327
5312
  setShowLoginPopup(false);
5328
5313
  setLoginPopupInitialView(void 0);
5329
5314
  }, []);
5330
- const resolvedTradePath = tradePath ?? DEFAULT_TRADE_PATH;
5331
5315
  const resolvedHomePath = homePath ?? DEFAULT_HOME_PATH;
5332
- const resolvedAboutPath = aboutPath ?? DEFAULT_ABOUT_PATH;
5333
- const resolvedLearnPath = learnPath ?? DEFAULT_LEARN_PATH;
5334
- const resolvedApiPath = apiPath ?? DEFAULT_API_PATH;
5335
- const resolvedOfferingsPath = offeringsPath ?? void 0;
5336
- const offeringsHref = resolvedOfferingsPath ?? resolvedHomePath;
5337
- const resolvedPropertyMapPath = propertyMapPath ?? DEFAULT_PROPERTY_MAP_PATH;
5338
- const resolvedPortfolioPath = portfolioPath ?? DEFAULT_PORTFOLIO_PATH;
5339
5316
  const resolvedLoafLiquidityPath = loafLiquidityPath ?? DEFAULT_LOAF_LIQUIDITY_PATH;
5340
- const inferredActiveTab = (() => {
5341
- if (showTradeTab && locationPath === resolvedTradePath) return "trade";
5342
- if (locationPath === resolvedHomePath) return "home";
5343
- if (locationPath === resolvedAboutPath) return "about";
5344
- if (locationPath === resolvedLearnPath) return "learn";
5345
- if (locationPath === resolvedApiPath) return "api";
5346
- if (resolvedOfferingsPath && locationPath.startsWith(resolvedOfferingsPath)) return "offerings";
5347
- if (locationPath === resolvedPropertyMapPath) return "propertyMap";
5348
- if (locationPath === resolvedPortfolioPath) return "portfolio";
5349
- return null;
5350
- })();
5351
- const resolvedActiveTab = activeTab ?? inferredActiveTab;
5352
- const tradeActive = showTradeTab && resolvedActiveTab === "trade";
5353
- const homeActive = resolvedActiveTab === "home";
5354
- const offeringsActive = resolvedActiveTab === "offerings";
5355
- const propertyMapActive = resolvedActiveTab === "propertyMap";
5356
- const aboutActive = resolvedActiveTab === "about";
5357
- const portfolioActive = resolvedActiveTab === "portfolio";
5358
- const learnActive = resolvedActiveTab === "learn";
5359
- const apiActive = resolvedActiveTab === "api";
5317
+ const inferredActiveKey = navItems.find(
5318
+ (item) => item.external ? false : item.match === "prefix" ? locationPath.startsWith(item.path) : locationPath === item.path
5319
+ )?.key ?? null;
5320
+ const resolvedActiveKey = activeKey ?? inferredActiveKey;
5321
+ const primaryItems = navItems.filter((item) => (item.group ?? "primary") === "primary");
5322
+ const moreItems = navItems.filter((item) => item.group === "more");
5323
+ const moreActive = moreItems.some((item) => item.key === resolvedActiveKey);
5324
+ const navLinkClick = (item) => (event) => {
5325
+ if (item.external) {
5326
+ closeMenus();
5327
+ return;
5328
+ }
5329
+ event.preventDefault();
5330
+ handleNavItem(item);
5331
+ };
5360
5332
  return /* @__PURE__ */ jsxs(Fragment, { children: [
5361
5333
  /* @__PURE__ */ jsx(SafeAreaCover, {}),
5362
5334
  /* @__PURE__ */ jsx(Overlay, { $isOpen: isMobileMenuOpen, onClick: () => setIsMobileMenuOpen(false) }),
@@ -5373,111 +5345,44 @@ var Header = ({
5373
5345
  style: { display: "flex", flexDirection: "row", alignItems: "center", height: "56px" },
5374
5346
  className: "desktop-nav",
5375
5347
  children: [
5376
- /* @__PURE__ */ jsx(
5377
- NavLink,
5378
- {
5379
- href: resolvedHomePath,
5380
- className: homeActive ? "active" : "",
5381
- onClick: (event) => {
5382
- event.preventDefault();
5383
- handleNavigation(resolvedHomePath);
5384
- },
5385
- children: "Home"
5386
- }
5387
- ),
5388
- /* @__PURE__ */ jsx(
5389
- NavLink,
5390
- {
5391
- href: resolvedPortfolioPath,
5392
- className: portfolioActive ? "active" : "",
5393
- onClick: (event) => {
5394
- event.preventDefault();
5395
- handleNavigation(resolvedPortfolioPath);
5396
- },
5397
- children: "Portfolio"
5398
- }
5399
- ),
5400
- showTradeTab && /* @__PURE__ */ jsx(
5401
- NavLink,
5402
- {
5403
- href: resolvedTradePath,
5404
- className: tradeActive ? "active" : "",
5405
- onClick: (event) => {
5406
- event.preventDefault();
5407
- handleTradeNavigation();
5408
- },
5409
- children: "Trade"
5410
- }
5411
- ),
5412
- /* @__PURE__ */ jsx(
5413
- NavLink,
5414
- {
5415
- href: offeringsHref,
5416
- className: offeringsActive ? "active" : "",
5417
- onClick: (event) => {
5418
- event.preventDefault();
5419
- handleNavigation(offeringsHref);
5420
- },
5421
- children: "Initial Offerings"
5422
- }
5423
- ),
5424
- /* @__PURE__ */ jsx(
5348
+ primaryItems.map((item) => /* @__PURE__ */ jsx(
5425
5349
  NavLink,
5426
5350
  {
5427
- href: resolvedPropertyMapPath,
5428
- className: propertyMapActive ? "active" : "",
5429
- onClick: (event) => {
5430
- event.preventDefault();
5431
- handleNavigation(resolvedPropertyMapPath);
5432
- },
5433
- children: "Property Map"
5434
- }
5435
- ),
5436
- /* @__PURE__ */ jsx(
5437
- NavLink,
5438
- {
5439
- href: resolvedLearnPath,
5440
- className: learnActive ? "active" : "",
5441
- onClick: (event) => {
5442
- event.preventDefault();
5443
- handleNavigation(resolvedLearnPath);
5444
- },
5445
- children: "Learn"
5446
- }
5447
- ),
5448
- /* @__PURE__ */ jsx(
5449
- NavLink,
5450
- {
5451
- href: resolvedAboutPath,
5452
- className: aboutActive ? "active" : "",
5453
- onClick: (event) => {
5454
- event.preventDefault();
5455
- handleNavigation(resolvedAboutPath);
5456
- },
5457
- children: "About"
5458
- }
5459
- ),
5460
- /* @__PURE__ */ jsx(
5461
- NavLink,
5462
- {
5463
- href: resolvedApiPath,
5464
- className: apiActive ? "active" : "",
5465
- onClick: (event) => {
5466
- event.preventDefault();
5467
- handleNavigation(resolvedApiPath);
5351
+ href: item.path,
5352
+ ...item.external ? { target: "_blank", rel: "noopener noreferrer" } : {},
5353
+ className: item.key === resolvedActiveKey ? "active" : "",
5354
+ onClick: navLinkClick(item),
5355
+ children: item.label
5356
+ },
5357
+ item.key
5358
+ )),
5359
+ moreItems.length > 0 && /* @__PURE__ */ jsxs(MoreMenu, { className: "more-menu", children: [
5360
+ /* @__PURE__ */ jsxs(
5361
+ MoreTrigger,
5362
+ {
5363
+ type: "button",
5364
+ className: `${isMoreMenuOpen ? "open" : ""} ${moreActive ? "active" : ""}`,
5365
+ "aria-haspopup": "true",
5366
+ "aria-expanded": isMoreMenuOpen,
5367
+ onClick: () => setIsMoreMenuOpen((open) => !open),
5368
+ children: [
5369
+ "More",
5370
+ /* @__PURE__ */ jsx("svg", { viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2.5", "aria-hidden": "true", children: /* @__PURE__ */ jsx("path", { d: "M6 9l6 6 6-6", strokeLinecap: "round", strokeLinejoin: "round" }) })
5371
+ ]
5372
+ }
5373
+ ),
5374
+ isMoreMenuOpen && /* @__PURE__ */ jsx(MoreDropdown, { children: moreItems.map((item) => /* @__PURE__ */ jsx(
5375
+ MoreItem,
5376
+ {
5377
+ href: item.path,
5378
+ ...item.external ? { target: "_blank", rel: "noopener noreferrer" } : {},
5379
+ className: item.key === resolvedActiveKey ? "active" : "",
5380
+ onClick: navLinkClick(item),
5381
+ children: item.label
5468
5382
  },
5469
- children: "API"
5470
- }
5471
- ),
5472
- /* @__PURE__ */ jsx(
5473
- NavLink,
5474
- {
5475
- href: "https://docs.loafmarkets.com/en/",
5476
- target: "_blank",
5477
- rel: "noopener noreferrer",
5478
- children: "Docs"
5479
- }
5480
- ),
5383
+ item.key
5384
+ )) })
5385
+ ] }),
5481
5386
  /* @__PURE__ */ jsx("div", { style: { marginLeft: "auto", display: "flex", alignItems: "center" }, children: /* @__PURE__ */ jsx(
5482
5387
  "div",
5483
5388
  {
@@ -5499,29 +5404,7 @@ var Header = ({
5499
5404
  ),
5500
5405
  /* @__PURE__ */ jsxs("div", { className: "mobile-menu-content", children: [
5501
5406
  /* @__PURE__ */ jsx(MobileMenuHeader, { children: /* @__PURE__ */ jsx(MobileMenuClose, { onClick: () => setIsMobileMenuOpen(false), "aria-label": "Close menu", children: /* @__PURE__ */ jsx("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ jsx("path", { d: "M19 6.41 17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z" }) }) }) }),
5502
- /* @__PURE__ */ jsx(MobileNavItem, { onClick: () => handleNavigation(resolvedHomePath), children: "Home" }),
5503
- /* @__PURE__ */ jsx(
5504
- MobileNavItem,
5505
- {
5506
- onClick: () => handleNavigation(resolvedPortfolioPath),
5507
- children: "Portfolio"
5508
- }
5509
- ),
5510
- showTradeTab && /* @__PURE__ */ jsx(
5511
- MobileNavItem,
5512
- {
5513
- onClick: () => {
5514
- handleTradeNavigation();
5515
- },
5516
- children: "Trade"
5517
- }
5518
- ),
5519
- /* @__PURE__ */ jsx(MobileNavItem, { onClick: () => handleNavigation(offeringsHref), children: "Initial Offerings" }),
5520
- /* @__PURE__ */ jsx(MobileNavItem, { onClick: () => handleNavigation(resolvedPropertyMapPath), children: "Property Map" }),
5521
- /* @__PURE__ */ jsx(MobileNavItem, { onClick: () => handleNavigation(resolvedLearnPath), children: "Learn" }),
5522
- /* @__PURE__ */ jsx(MobileNavItem, { onClick: () => handleNavigation(resolvedAboutPath), children: "About" }),
5523
- /* @__PURE__ */ jsx(MobileNavItem, { onClick: () => handleNavigation(resolvedApiPath), children: "API" }),
5524
- /* @__PURE__ */ jsx(MobileNavItem, { onClick: () => window.open("https://docs.loafmarkets.com/en/", "_blank", "noopener,noreferrer"), children: "Docs" }),
5407
+ navItems.map((item) => /* @__PURE__ */ jsx(MobileNavItem, { onClick: () => handleNavItem(item), children: item.label }, item.key)),
5525
5408
  /* @__PURE__ */ jsx("div", { style: { borderTop: "1px solid #2b3139", margin: "8px 0" } }),
5526
5409
  /* @__PURE__ */ jsx(
5527
5410
  MobileNavItem,
@@ -6035,6 +5918,77 @@ var NavLink = styled10.a`
6035
5918
  }
6036
5919
  }
6037
5920
  `;
5921
+ var MoreMenu = styled10.div`
5922
+ position: relative;
5923
+ display: flex;
5924
+ align-items: center;
5925
+ height: 56px;
5926
+ `;
5927
+ var MoreTrigger = styled10.button`
5928
+ margin: 0 12px;
5929
+ padding: 0 4px;
5930
+ height: 56px;
5931
+ display: inline-flex;
5932
+ align-items: center;
5933
+ gap: 4px;
5934
+ background: none;
5935
+ border: none;
5936
+ cursor: pointer;
5937
+ color: #eaecef;
5938
+ font-weight: 500;
5939
+ font-size: 14px;
5940
+ font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Roboto", "Helvetica Neue", Arial, sans-serif;
5941
+ letter-spacing: 0.2px;
5942
+ transition: color 0.2s ease;
5943
+
5944
+ &:hover,
5945
+ &.active {
5946
+ color: #E6C87E;
5947
+ }
5948
+
5949
+ svg {
5950
+ width: 14px;
5951
+ height: 14px;
5952
+ transition: transform 0.2s ease;
5953
+ }
5954
+ &.open svg {
5955
+ transform: rotate(180deg);
5956
+ }
5957
+ `;
5958
+ var MoreDropdown = styled10.div`
5959
+ position: absolute;
5960
+ top: 100%;
5961
+ right: 0;
5962
+ min-width: 160px;
5963
+ padding: 6px;
5964
+ background: #1e2026;
5965
+ border: 1px solid #2b3139;
5966
+ border-radius: 10px;
5967
+ box-shadow: 0 12px 32px rgba(0, 0, 0, 0.4);
5968
+ display: flex;
5969
+ flex-direction: column;
5970
+ z-index: 1100;
5971
+ `;
5972
+ var MoreItem = styled10.a`
5973
+ padding: 10px 12px;
5974
+ border-radius: 6px;
5975
+ color: #eaecef;
5976
+ font-weight: 500;
5977
+ font-size: 14px;
5978
+ font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Roboto", "Helvetica Neue", Arial, sans-serif;
5979
+ letter-spacing: 0.2px;
5980
+ text-decoration: none;
5981
+ cursor: pointer;
5982
+ transition: background 0.15s ease, color 0.15s ease;
5983
+
5984
+ &:hover {
5985
+ background: #2b3139;
5986
+ color: #E6C87E;
5987
+ }
5988
+ &.active {
5989
+ color: #E6C87E;
5990
+ }
5991
+ `;
6038
5992
  var Button2 = styled10.button.attrs({ type: "button" })`
6039
5993
  padding: 0.5rem 1rem;
6040
5994
  border-radius: 6px;