@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/README.md CHANGED
@@ -21,6 +21,12 @@ does nothing on a page without the attribute, and it never imports
21
21
  <Html lang="en" data-oc-app="ochk">
22
22
  ```
23
23
 
24
+ ```ts
25
+ // next.config.ts: required. Next must compile the package so its links share the
26
+ // app's router; left external, a link loses the base path and the build fails.
27
+ transpilePackages: ['@orangecheck/app-design'],
28
+ ```
29
+
24
30
  Light and dark come from plain `next-themes` (`attribute="class"`). Do not mount the
25
31
  family `OcThemeProvider` on the same page: it writes `data-oc-theme` and the shared
26
32
  `oc_skin` cookie.
package/dist/chrome.d.mts CHANGED
@@ -3,7 +3,7 @@ import { ReactNode } from 'react';
3
3
  import { e as FooterColumn, N as NavItem, d as FamilySlug } from './index-DmfyPYe5.mjs';
4
4
  import { T as TocItem } from './hero-Dn37il-9.mjs';
5
5
  import { a as Status } from './status-badge-BJ9Sdsx8.mjs';
6
- export { A as AccountMenu, a as AccountMenuItem, b as AppShell, O as OCHK_APP_ACCOUNT, S as SessionAccountView, c as SessionState, d as ShellNavGroup, e as ShellNavItem, f as ShellSection, T as ThemeToggle, g as ToolShell, h as ToolShellProps } from './tool-shell-kqGWMTep.mjs';
6
+ export { A as AccountMenu, a as AccountMenuItem, b as AppShell, O as OCHK_APP_ACCOUNT, S as SessionAccountView, c as SessionState, d as ShellNavGroup, e as ShellNavItem, f as ShellSection, T as ThemeToggle, g as ToolShell, h as ToolShellProps, u as useSignInHref } from './tool-shell-zncroOEQ.mjs';
7
7
  import './tools-DFIxIj5p.mjs';
8
8
  import './format.mjs';
9
9
 
package/dist/chrome.d.ts CHANGED
@@ -3,7 +3,7 @@ import { ReactNode } from 'react';
3
3
  import { e as FooterColumn, N as NavItem, d as FamilySlug } from './index-DmfyPYe5.js';
4
4
  import { T as TocItem } from './hero-Dn37il-9.js';
5
5
  import { a as Status } from './status-badge-Bt8x3RhO.js';
6
- export { A as AccountMenu, a as AccountMenuItem, b as AppShell, O as OCHK_APP_ACCOUNT, S as SessionAccountView, c as SessionState, d as ShellNavGroup, e as ShellNavItem, f as ShellSection, T as ThemeToggle, g as ToolShell, h as ToolShellProps } from './tool-shell-DLSwUxTD.js';
6
+ export { A as AccountMenu, a as AccountMenuItem, b as AppShell, O as OCHK_APP_ACCOUNT, S as SessionAccountView, c as SessionState, d as ShellNavGroup, e as ShellNavItem, f as ShellSection, T as ThemeToggle, g as ToolShell, h as ToolShellProps, u as useSignInHref } from './tool-shell-Be4Q0cNN.js';
7
7
  import './tools-BggNN5DV.js';
8
8
  import './format.js';
9
9
 
package/dist/chrome.js CHANGED
@@ -1,7 +1,7 @@
1
1
  'use strict';
2
2
 
3
3
  var lucideReact = require('lucide-react');
4
- var Link5 = require('next/link.js');
4
+ var Link5 = require('next/link');
5
5
  var react = require('react');
6
6
  var clsx = require('clsx');
7
7
  var tailwindMerge = require('tailwind-merge');
@@ -14,6 +14,7 @@ var classVarianceAuthority = require('class-variance-authority');
14
14
  var SeparatorPrimitive = require('@radix-ui/react-separator');
15
15
  require('sonner');
16
16
  var reactSlot = require('@radix-ui/react-slot');
17
+ var router = require('next/compat/router');
17
18
  var nextThemes = require('next-themes');
18
19
 
19
20
  function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
@@ -1600,17 +1601,38 @@ function ThemeToggle({ className }) {
1600
1601
  );
1601
1602
  }
1602
1603
  var OCHK_APP_ACCOUNT = "https://ochk.app/me/account";
1604
+ function onHistory(change) {
1605
+ window.addEventListener("popstate", change);
1606
+ return () => window.removeEventListener("popstate", change);
1607
+ }
1608
+ function herePath() {
1609
+ const { href, origin, pathname, search } = window.location;
1610
+ const path = pathname + search;
1611
+ return new URL(path, href).origin === origin ? path : "/";
1612
+ }
1613
+ function routePath(router) {
1614
+ if (!router || router.pathname.includes("[")) return null;
1615
+ return router.basePath && router.pathname === "/" ? router.basePath : router.basePath + router.pathname;
1616
+ }
1617
+ function useSignInHref(path) {
1618
+ const router$1 = router.useRouter();
1619
+ const here = react.useSyncExternalStore(onHistory, herePath, () => routePath(router$1));
1620
+ if (!path) return void 0;
1621
+ return here ? `${path}?return_to=${encodeURIComponent(here)}` : path;
1622
+ }
1603
1623
  function SessionAccountView({
1604
1624
  state,
1605
1625
  name,
1606
1626
  detail,
1607
1627
  items = [],
1608
1628
  signInHref,
1629
+ signInPath,
1609
1630
  signInLabel = "Sign in",
1610
1631
  accountHref = OCHK_APP_ACCOUNT,
1611
1632
  onSignOut,
1612
1633
  nameFrom = "lg"
1613
1634
  }) {
1635
+ const inPlace = useSignInHref(signInPath);
1614
1636
  if (state === "in") {
1615
1637
  return /* @__PURE__ */ jsxRuntime.jsx(
1616
1638
  AccountMenu,
@@ -1633,13 +1655,13 @@ function SessionAccountView({
1633
1655
  }
1634
1656
  return (
1635
1657
  // No box of its own: it sits exactly where the signed-in chip will. While checking it is only unseen.
1636
- /* @__PURE__ */ jsxRuntime.jsx("span", { className: state === "checking" ? "contents invisible" : "contents", "aria-hidden": state === "checking" || void 0, children: /* @__PURE__ */ jsxRuntime.jsx(Button, { asChild: true, size: "sm", variant: "secondary", tabIndex: state === "checking" ? -1 : void 0, children: /* @__PURE__ */ jsxRuntime.jsx("a", { href: signInHref, children: signInLabel }) }) })
1658
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: state === "checking" ? "contents invisible" : "contents", "aria-hidden": state === "checking" || void 0, children: /* @__PURE__ */ jsxRuntime.jsx(Button, { asChild: true, size: "sm", variant: "secondary", tabIndex: state === "checking" ? -1 : void 0, children: /* @__PURE__ */ jsxRuntime.jsx("a", { href: signInHref ?? inPlace ?? "https://ochk.io/signin", children: signInLabel }) }) })
1637
1659
  );
1638
1660
  }
1639
1661
  function ToolShell({
1640
1662
  protocol: protocol2,
1641
1663
  tools,
1642
- home = "/",
1664
+ home,
1643
1665
  account,
1644
1666
  rail = false,
1645
1667
  railFooter,
@@ -1678,7 +1700,7 @@ function ToolShell({
1678
1700
  SiteHeader,
1679
1701
  {
1680
1702
  variant: "tool",
1681
- home,
1703
+ home: home ?? p.pageHref,
1682
1704
  product: p.label,
1683
1705
  family: protocol2,
1684
1706
  nav: tools.map((t) => ({ href: t.href, label: t.label, active: t.active })),
@@ -1731,5 +1753,6 @@ exports.SkipLink = SkipLink;
1731
1753
  exports.ThemeToggle = ThemeToggle;
1732
1754
  exports.ToolShell = ToolShell;
1733
1755
  exports.useShellPlace = useShellPlace;
1756
+ exports.useSignInHref = useSignInHref;
1734
1757
  //# sourceMappingURL=chrome.js.map
1735
1758
  //# sourceMappingURL=chrome.js.map