@orangecheck/app-design 1.2.2 → 1.3.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/chrome.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  import { X, ChevronDown, Menu, ChevronRight, PanelLeft, Sun, Moon, SunMoon, CircleUser, LogOut, ArrowUpRight } from 'lucide-react';
2
- import Link5 from 'next/link.js';
3
- import { forwardRef, createContext, useState, useContext, useMemo, useEffect, useRef, useId, createElement } from 'react';
2
+ import Link5 from 'next/link';
3
+ import { forwardRef, createContext, useState, useContext, useMemo, useEffect, useRef, useId, useSyncExternalStore, createElement } from 'react';
4
4
  import { clsx } from 'clsx';
5
5
  import { extendTailwindMerge } from 'tailwind-merge';
6
6
  import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
@@ -12,6 +12,7 @@ import { cva } from 'class-variance-authority';
12
12
  import * as SeparatorPrimitive from '@radix-ui/react-separator';
13
13
  import 'sonner';
14
14
  import { Slot } from '@radix-ui/react-slot';
15
+ import { useRouter } from 'next/compat/router';
15
16
  import { useTheme } from 'next-themes';
16
17
 
17
18
  var merge = extendTailwindMerge({
@@ -1571,17 +1572,38 @@ function ThemeToggle({ className }) {
1571
1572
  );
1572
1573
  }
1573
1574
  var OCHK_APP_ACCOUNT = "https://ochk.app/me/account";
1575
+ function onHistory(change) {
1576
+ window.addEventListener("popstate", change);
1577
+ return () => window.removeEventListener("popstate", change);
1578
+ }
1579
+ function herePath() {
1580
+ const { href, origin, pathname, search } = window.location;
1581
+ const path = pathname + search;
1582
+ return new URL(path, href).origin === origin ? path : "/";
1583
+ }
1584
+ function routePath(router) {
1585
+ if (!router || router.pathname.includes("[")) return null;
1586
+ return router.basePath && router.pathname === "/" ? router.basePath : router.basePath + router.pathname;
1587
+ }
1588
+ function useSignInHref(path) {
1589
+ const router = useRouter();
1590
+ const here = useSyncExternalStore(onHistory, herePath, () => routePath(router));
1591
+ if (!path) return void 0;
1592
+ return here ? `${path}?return_to=${encodeURIComponent(here)}` : path;
1593
+ }
1574
1594
  function SessionAccountView({
1575
1595
  state,
1576
1596
  name,
1577
1597
  detail,
1578
1598
  items = [],
1579
1599
  signInHref,
1600
+ signInPath,
1580
1601
  signInLabel = "Sign in",
1581
1602
  accountHref = OCHK_APP_ACCOUNT,
1582
1603
  onSignOut,
1583
1604
  nameFrom = "lg"
1584
1605
  }) {
1606
+ const inPlace = useSignInHref(signInPath);
1585
1607
  if (state === "in") {
1586
1608
  return /* @__PURE__ */ jsx(
1587
1609
  AccountMenu,
@@ -1604,13 +1626,13 @@ function SessionAccountView({
1604
1626
  }
1605
1627
  return (
1606
1628
  // No box of its own: it sits exactly where the signed-in chip will. While checking it is only unseen.
1607
- /* @__PURE__ */ jsx("span", { className: state === "checking" ? "contents invisible" : "contents", "aria-hidden": state === "checking" || void 0, children: /* @__PURE__ */ jsx(Button, { asChild: true, size: "sm", variant: "secondary", tabIndex: state === "checking" ? -1 : void 0, children: /* @__PURE__ */ jsx("a", { href: signInHref, children: signInLabel }) }) })
1629
+ /* @__PURE__ */ jsx("span", { className: state === "checking" ? "contents invisible" : "contents", "aria-hidden": state === "checking" || void 0, children: /* @__PURE__ */ jsx(Button, { asChild: true, size: "sm", variant: "secondary", tabIndex: state === "checking" ? -1 : void 0, children: /* @__PURE__ */ jsx("a", { href: signInHref ?? inPlace ?? "https://ochk.io/signin", children: signInLabel }) }) })
1608
1630
  );
1609
1631
  }
1610
1632
  function ToolShell({
1611
1633
  protocol: protocol2,
1612
1634
  tools,
1613
- home = "/",
1635
+ home,
1614
1636
  account,
1615
1637
  rail = false,
1616
1638
  railFooter,
@@ -1649,7 +1671,7 @@ function ToolShell({
1649
1671
  SiteHeader,
1650
1672
  {
1651
1673
  variant: "tool",
1652
- home,
1674
+ home: home ?? p.pageHref,
1653
1675
  product: p.label,
1654
1676
  family: protocol2,
1655
1677
  nav: tools.map((t) => ({ href: t.href, label: t.label, active: t.active })),
@@ -1685,6 +1707,6 @@ function ToolShell({
1685
1707
  ) });
1686
1708
  }
1687
1709
 
1688
- export { AccountMenu, AppShell, DOCS_HEADER_NAV, DocsNav, DocsShell, FamilyMenu, OCHK_APP_ACCOUNT, SessionAccountView, ShellContext, SignInFrame, SiteBanner, SiteFooter, SiteHeader, SkipLink, ThemeToggle, ToolShell, useShellPlace };
1710
+ export { AccountMenu, AppShell, DOCS_HEADER_NAV, DocsNav, DocsShell, FamilyMenu, OCHK_APP_ACCOUNT, SessionAccountView, ShellContext, SignInFrame, SiteBanner, SiteFooter, SiteHeader, SkipLink, ThemeToggle, ToolShell, useShellPlace, useSignInHref };
1689
1711
  //# sourceMappingURL=chrome.mjs.map
1690
1712
  //# sourceMappingURL=chrome.mjs.map