@protobase/ui 0.12.20 → 0.12.21

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.
@@ -2,4 +2,5 @@ import "./bottom-bar.js";
2
2
  import "./nav.js";
3
3
  import "./profile-menu.js";
4
4
  import "./global-search.js";
5
+ import "./breadcrumb.js";
5
6
  import { ReactNode } from "react";
@@ -0,0 +1,12 @@
1
+ //#region src/app-shell/back-target.ts
2
+ /** Where the mobile back button goes: the crumb just before the current page, when it has a page of its own. */
3
+ const backTarget = (parts) => {
4
+ const previous = parts.at(-2);
5
+ if (typeof previous !== "object" || !previous.href || previous.loading) return void 0;
6
+ return {
7
+ label: previous.label,
8
+ href: previous.href
9
+ };
10
+ };
11
+ //#endregion
12
+ export { backTarget };
@@ -0,0 +1 @@
1
+ import "react";
@@ -3,6 +3,7 @@ import { Skeleton } from "../primitives/skeleton.js";
3
3
  import { ChevronRight } from "lucide-react";
4
4
  import { jsx, jsxs } from "react/jsx-runtime";
5
5
  //#region src/app-shell/breadcrumb.tsx
6
+ /** A plain left click, which the app follows itself; others open a new tab. */
6
7
  const inApp = (event) => event.button === 0 && !event.metaKey && !event.ctrlKey && !event.shiftKey && !event.altKey;
7
8
  /** The trail of where you are; the last crumb, the current page, shows on phones too. */
8
9
  const Breadcrumb = ({ parts, onNavigate }) => /* @__PURE__ */ jsx("nav", {
@@ -41,4 +42,4 @@ const Breadcrumb = ({ parts, onNavigate }) => /* @__PURE__ */ jsx("nav", {
41
42
  })
42
43
  });
43
44
  //#endregion
44
- export { Breadcrumb };
45
+ export { Breadcrumb, inApp };
@@ -3,6 +3,7 @@ import "./nav.js";
3
3
  import "./profile-menu.js";
4
4
  import { SidebarMode, sidebarModes } from "./sidebar-mode.js";
5
5
  import "./global-search.js";
6
+ import "./breadcrumb.js";
6
7
  import "./app-shell.js";
7
8
  import "./page-header.js";
8
9
  import "./sidebar.js";
@@ -1,13 +1,15 @@
1
1
  import { cn } from "../lib/cn.js";
2
- import { Breadcrumb } from "./breadcrumb.js";
2
+ import { backTarget } from "./back-target.js";
3
+ import { Breadcrumb, inApp } from "./breadcrumb.js";
3
4
  import { GlobalSearch } from "./global-search.js";
4
5
  import { useEffect, useRef, useState } from "react";
5
- import { Menu, Search, X } from "lucide-react";
6
+ import { ChevronLeft, Menu, Search, X } from "lucide-react";
6
7
  import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
7
8
  //#region src/app-shell/top-bar.tsx
8
9
  const iconButton = "inline-flex size-11 shrink-0 items-center justify-center rounded-md text-muted-foreground hover:bg-muted md:hidden";
9
10
  const TopBar = ({ breadcrumb, onNavigate, actions, onMenu, menuOpen, menuControls, search }) => {
10
11
  const [searchOpen, setSearchOpen] = useState(false);
12
+ const back = backTarget(breadcrumb);
11
13
  const desktopSearch = useRef(null);
12
14
  useEffect(() => {
13
15
  if (!search) return;
@@ -33,6 +35,17 @@ const TopBar = ({ breadcrumb, onNavigate, actions, onMenu, menuOpen, menuControl
33
35
  className: cn(iconButton, "-ml-0.5"),
34
36
  children: /* @__PURE__ */ jsx(Menu, { className: "size-5" })
35
37
  }),
38
+ back && /* @__PURE__ */ jsx("a", {
39
+ href: back.href,
40
+ "aria-label": `Back to ${back.label}`,
41
+ onClick: (event) => {
42
+ if (!onNavigate || !inApp(event)) return;
43
+ event.preventDefault();
44
+ onNavigate(back.href);
45
+ },
46
+ className: cn(iconButton, !onMenu && "-ml-0.5"),
47
+ children: /* @__PURE__ */ jsx(ChevronLeft, { className: "size-5" })
48
+ }),
36
49
  /* @__PURE__ */ jsx(Breadcrumb, {
37
50
  parts: breadcrumb,
38
51
  onNavigate
package/dist/package.js CHANGED
@@ -1,5 +1,5 @@
1
1
  //#region package.json
2
- var version = "0.12.20";
2
+ var version = "0.12.21";
3
3
  var protobase = { "pluginApi": 1 };
4
4
  //#endregion
5
5
  export { protobase, version };